From 3b89cbfdb25a58f88320e489b6426263f1af88be Mon Sep 17 00:00:00 2001 From: Scott Fennell Date: Fri, 28 Aug 2020 14:52:23 -0500 Subject: [PATCH] iss #1009 (#1040) Link correct clang libs based on availability. ICG clang lib link flags are determined by trick/configure --- .github/workflows/test.yml | 6 +- autoconf/configure.ac | 27 ++++ configure | 123 ++++++++++++++++-- share/trick/makefiles/config_user.mk.in | 1 + share/trick/makefiles/config_user_cmake.mk.in | 12 ++ .../codegen/Interface_Code_Gen/makefile | 12 +- trigger | 0 7 files changed, 155 insertions(+), 26 deletions(-) create mode 100644 trigger diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index aeee9a0f..88381fbf 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,7 +19,7 @@ jobs: - { os: centos, tag: 7, arch: rhel } # EOL June 2024 - { os: centos, tag: latest, arch: rhel } # 8 as of April 2020 - { os: fedora, tag: latest, arch: rhel } # 31 as of April 2020 - # - { os: fedora, tag: 32, arch: rhel } # feeling confident? + # - { os: fedora, tag: 33, arch: rhel } # feeling confident? # - { os: fedora, tag: rawhide, arch: rhel } # for thrill-seekers only #-------- Defaults -------------------------- @@ -95,7 +95,11 @@ jobs: #-------- Fedora Only Dependencies ---------------- - cfg: { os: fedora } pkg_mgr: dnf + conf_pkg: > + dnf install -y 'dnf-command(config-manager)' && + dnf config-manager --enable updates-testing os_deps: >- + clang-10.0.1 perl-Text-Balanced python-devel diffutils diff --git a/autoconf/configure.ac b/autoconf/configure.ac index 5fa9571b..667f1887 100644 --- a/autoconf/configure.ac +++ b/autoconf/configure.ac @@ -441,6 +441,33 @@ AC_PATH_PROG(CLANG, clang, noclang, "$LLVM_BIN_DIR:/bin:/usr/bin:/usr/local/bin: AS_IF([test "$ac_cv_path_CLANG" = "noclang"],AC_MSG_ERROR([could not find clang]),[]) AC_SUBST([LLVM_HOME]) +OLD_CLANG_LIBS="-lclangFrontend -lclangDriver -lclangSerialization -lclangParse -lclangSema -lclangAnalysis -lclangEdit -lclangAST -lclangLex -lclangBasic" +NEW_CLANG_LIBS="-lclang-cpp" +AC_CHECK_FILE([$LLVM_LIB_DIR/libclangFrontend.a], + [ + ICG_CLANGLIBS="$OLD_CLANG_LIBS" + ], + AC_CHECK_FILE([$LLVM_LIB_DIR/libclangFrontend.so], + [ + ICG_CLANGLIBS="$OLD_CLANG_LIBS" + ], + AC_CHECK_FILE([$LLVM_LIB_DIR/libclang-cpp.a], + [ + ICG_CLANGLIBS="$NEW_CLANG_LIBS" + ], + AC_CHECK_FILE([$LLVM_LIB_DIR/libclang-cpp.so], + [ + ICG_CLANGLIBS="$NEW_CLANG_LIBS" + ], + AC_MSG_ERROR([could not find clang libs in LLVM library: "$LLVM_LIB_DIR"]) + ) + ) + ) +) + +AC_SUBST([ICG_CLANGLIBS]) + + AC_DEFUN([AX_CLANG_VERSION], [ CLANG_VERSION="" ax_cv_clang_version="`$CLANG --version | grep "version" | sed "s/.*version \([0-9]*\.[0-9]*\.[0-9]*\).*/\1/"`" diff --git a/configure b/configure index 8b2e35fb..6775975c 100755 --- a/configure +++ b/configure @@ -632,6 +632,7 @@ UDUNITS_LDFLAGS UDUNITS_INCLUDES UDUNITS_HOME CLANG_VERSION +ICG_CLANGLIBS LLVM_HOME CLANG LLVM_CONFIG @@ -717,7 +718,6 @@ infodir docdir oldincludedir includedir -runstatedir localstatedir sharedstatedir sysconfdir @@ -812,7 +812,6 @@ datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' -runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' @@ -1065,15 +1064,6 @@ do | -silent | --silent | --silen | --sile | --sil) silent=yes ;; - -runstatedir | --runstatedir | --runstatedi | --runstated \ - | --runstate | --runstat | --runsta | --runst | --runs \ - | --run | --ru | --r) - ac_prev=runstatedir ;; - -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ - | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ - | --run=* | --ru=* | --r=*) - runstatedir=$ac_optarg ;; - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ @@ -1211,7 +1201,7 @@ fi for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir runstatedir + libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. @@ -1364,7 +1354,6 @@ Fine tuning of the installation directories: --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] - --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] @@ -7189,6 +7178,113 @@ if test "$ac_cv_path_CLANG" = "noclang"; then : fi +OLD_CLANG_LIBS="-lclangFrontend -lclangDriver -lclangSerialization -lclangParse -lclangSema -lclangAnalysis -lclangEdit -lclangAST -lclangLex -lclangBasic" +NEW_CLANG_LIBS="-lclang-cpp" +as_ac_File=`$as_echo "ac_cv_file_$LLVM_LIB_DIR/libclangFrontend.a" | $as_tr_sh` +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LLVM_LIB_DIR/libclangFrontend.a" >&5 +$as_echo_n "checking for $LLVM_LIB_DIR/libclangFrontend.a... " >&6; } +if eval \${$as_ac_File+:} false; then : + $as_echo_n "(cached) " >&6 +else + test "$cross_compiling" = yes && + as_fn_error $? "cannot check for file existence when cross compiling" "$LINENO" 5 +if test -r "$LLVM_LIB_DIR/libclangFrontend.a"; then + eval "$as_ac_File=yes" +else + eval "$as_ac_File=no" +fi +fi +eval ac_res=\$$as_ac_File + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +if eval test \"x\$"$as_ac_File"\" = x"yes"; then : + + ICG_CLANGLIBS="$OLD_CLANG_LIBS" + +else + as_ac_File=`$as_echo "ac_cv_file_$LLVM_LIB_DIR/libclangFrontend.so" | $as_tr_sh` +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LLVM_LIB_DIR/libclangFrontend.so" >&5 +$as_echo_n "checking for $LLVM_LIB_DIR/libclangFrontend.so... " >&6; } +if eval \${$as_ac_File+:} false; then : + $as_echo_n "(cached) " >&6 +else + test "$cross_compiling" = yes && + as_fn_error $? "cannot check for file existence when cross compiling" "$LINENO" 5 +if test -r "$LLVM_LIB_DIR/libclangFrontend.so"; then + eval "$as_ac_File=yes" +else + eval "$as_ac_File=no" +fi +fi +eval ac_res=\$$as_ac_File + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +if eval test \"x\$"$as_ac_File"\" = x"yes"; then : + + ICG_CLANGLIBS="$OLD_CLANG_LIBS" + +else + as_ac_File=`$as_echo "ac_cv_file_$LLVM_LIB_DIR/libclang-cpp.a" | $as_tr_sh` +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LLVM_LIB_DIR/libclang-cpp.a" >&5 +$as_echo_n "checking for $LLVM_LIB_DIR/libclang-cpp.a... " >&6; } +if eval \${$as_ac_File+:} false; then : + $as_echo_n "(cached) " >&6 +else + test "$cross_compiling" = yes && + as_fn_error $? "cannot check for file existence when cross compiling" "$LINENO" 5 +if test -r "$LLVM_LIB_DIR/libclang-cpp.a"; then + eval "$as_ac_File=yes" +else + eval "$as_ac_File=no" +fi +fi +eval ac_res=\$$as_ac_File + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +if eval test \"x\$"$as_ac_File"\" = x"yes"; then : + + ICG_CLANGLIBS="$NEW_CLANG_LIBS" + +else + as_ac_File=`$as_echo "ac_cv_file_$LLVM_LIB_DIR/libclang-cpp.so" | $as_tr_sh` +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LLVM_LIB_DIR/libclang-cpp.so" >&5 +$as_echo_n "checking for $LLVM_LIB_DIR/libclang-cpp.so... " >&6; } +if eval \${$as_ac_File+:} false; then : + $as_echo_n "(cached) " >&6 +else + test "$cross_compiling" = yes && + as_fn_error $? "cannot check for file existence when cross compiling" "$LINENO" 5 +if test -r "$LLVM_LIB_DIR/libclang-cpp.so"; then + eval "$as_ac_File=yes" +else + eval "$as_ac_File=no" +fi +fi +eval ac_res=\$$as_ac_File + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +if eval test \"x\$"$as_ac_File"\" = x"yes"; then : + + ICG_CLANGLIBS="$NEW_CLANG_LIBS" + +else + as_fn_error $? "could not find clang libs in LLVM library: \"$LLVM_LIB_DIR\"" "$LINENO" 5 + +fi + + +fi + + +fi + + +fi + + + + + CLANG_VERSION="" @@ -7298,7 +7394,6 @@ then LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib" CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include" fi - ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' diff --git a/share/trick/makefiles/config_user.mk.in b/share/trick/makefiles/config_user.mk.in index 69e92343..2fe8610b 100644 --- a/share/trick/makefiles/config_user.mk.in +++ b/share/trick/makefiles/config_user.mk.in @@ -22,6 +22,7 @@ TRICK_MONGOOSE = @TRICK_MONGOOSE@ USE_X_WINDOWS = @USE_X_WINDOWS@ LLVM_HOME = @LLVM_HOME@ +ICG_CLANGLIBS = @ICG_CLANGLIBS@ PYTHON_INCLUDES = @PYTHON_CPPFLAGS@ PYTHON_LIB = @PYTHON_LIBS@ @PYTHON_EXTRA_LIBS@ diff --git a/share/trick/makefiles/config_user_cmake.mk.in b/share/trick/makefiles/config_user_cmake.mk.in index 8101e3ef..44f7bd76 100644 --- a/share/trick/makefiles/config_user_cmake.mk.in +++ b/share/trick/makefiles/config_user_cmake.mk.in @@ -19,6 +19,18 @@ USE_X_WINDOWS = @USE_X_WINDOWS@ LLVM_HOME = @LLVM_ROOT_DIR@ +ICG_CLANGLIBS = \ + -lclangFrontend \ + -lclangDriver \ + -lclangSerialization \ + -lclangParse \ + -lclangSema \ + -lclangAnalysis \ + -lclangEdit \ + -lclangAST \ + -lclangLex \ + -lclangBasic \ + PYTHON_INCLUDES = -I@PYTHON_INCLUDE_DIRS@ PYTHON_LIB = @PYTHON_LIBRARIES@ diff --git a/trick_source/codegen/Interface_Code_Gen/makefile b/trick_source/codegen/Interface_Code_Gen/makefile index 6a188537..34caae37 100644 --- a/trick_source/codegen/Interface_Code_Gen/makefile +++ b/trick_source/codegen/Interface_Code_Gen/makefile @@ -29,17 +29,7 @@ OBJECTS = $(addprefix $(OBJ_DIR)/, $(subst .cpp,.o,$(SOURCES))) UDUNITS_OBJS = \ $(OBJ_DIR)/map_trick_units_to_udunits.o -CLANGLIBS = \ - -lclangFrontend \ - -lclangDriver \ - -lclangSerialization \ - -lclangParse \ - -lclangSema \ - -lclangAnalysis \ - -lclangEdit \ - -lclangAST \ - -lclangLex \ - -lclangBasic \ +CLANGLIBS = $(ICG_CLANGLIBS) CXXFLAGS += -DLIBCLANG_MAJOR=$(CLANG_MAJOR) -DLIBCLANG_MINOR=$(CLANG_MINOR) ifneq ($(CLANG_PATCHLEVEL),) diff --git a/trigger b/trigger new file mode 100644 index 00000000..e69de29b