From cf03b0dac3903a988ba8b0538ca858f4ef4159b0 Mon Sep 17 00:00:00 2001 From: Artem Shinkarov Date: Sat, 27 Oct 2018 02:00:29 +0000 Subject: [PATCH 1/4] Properly porapagate BUILDGENERIC into runtime libraries. Previously we didn't compile runtime libraries like libsac, sacprelude, etc. with -mtune=generic. As a consequence, all our packages are (very likely) incompatible with cpus other than of the host system. This commit fixes it. Signed-off-by: Hans-Nikolai Viessmann --- CMakeLists.txt | 1 + cmake/runtime/CMakeLists.txt | 7 +++++++ cmake/runtime/sac2c-variables.cmake | 7 +++++++ src/tools/saccc.in | 8 +++++++- 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c6067abb3..40af31918 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -129,6 +129,7 @@ ExternalProject_Add(runtime_libraries -DSHARED_LIB_EXT=${SHARED_LIB_EXT} -DLINKSETSIZE=${LINKSETSIZE} -DRT_TARGETS:STRING=${_TARGETS} + -DBUILDGENERIC=${BUILDGENERIC} ) # We set dependencies on the configure step, this makes sure we propogate # certain values (such as from sac2crc). diff --git a/cmake/runtime/CMakeLists.txt b/cmake/runtime/CMakeLists.txt index a51925117..b76e1c28e 100644 --- a/cmake/runtime/CMakeLists.txt +++ b/cmake/runtime/CMakeLists.txt @@ -72,6 +72,13 @@ MACRO (ADD_LIBSAC_TARGET SRC_DIR VARIANT_TARGET) # NOTE (hans) we use the `rmod` target which uses compiler and linker specified # through the RCC and RLD sac2crc variables (additionally we use SET (SACCC "${SAC2C_BUILD_DIR}/saccc ${SAC2C_EXEC} rmod ${TARGET}") + + # In case we are using BUILDGENERIC, we need to propagate -mtune=generic + # flag to all the C files that we compile. + IF (BUILDGENERIC) + SET (SACCC "${SACCC} -Xc '-mtune=generic'") + ENDIF () + SET (CMAKE_C_COMPILE_OBJECT "${SACCC} -o -c ") # -o -c ") diff --git a/cmake/runtime/sac2c-variables.cmake b/cmake/runtime/sac2c-variables.cmake index de2918fd1..f62c148dc 100644 --- a/cmake/runtime/sac2c-variables.cmake +++ b/cmake/runtime/sac2c-variables.cmake @@ -1,5 +1,12 @@ # Create local variant of the SAC2C flags SET (SAC2C_T ${SAC2C_EXEC} -target ${TARGET}) + +# In case of BUILDGENERIC we need to propagate the -mtune=generic flag +# to all the sac libraries. +IF (BUILDGENERIC) + SET (SAC2C_T ${SAC2C_T} -Xc "\"-mtune=generic\"") +ENDIF () + SET (SAC2C ${SAC2C_T} -Xc "\"${SAC2C_EXTRA_INC}\"" -Xtc "\"${SAC2C_EXTRA_INC}\"") SET (SAC2C_NT ${SAC2C_EXEC} -Xc "\"${SAC2C_EXTRA_INC}\"" -Xtc "\"${SAC2C_EXTRA_INC}\"") # defaults to SEQ diff --git a/src/tools/saccc.in b/src/tools/saccc.in index 25feb68b8..02445ceee 100755 --- a/src/tools/saccc.in +++ b/src/tools/saccc.in @@ -37,7 +37,13 @@ for arg in "$@"; do act=$followaction followaction= case $act in - ccarg) cmdline+=(-Xc "$ccarg" -Xc "$arg" -Xl "$ccarg" -Xl "$arg"); continue;; + ccarg) + if test x"$ccarg" = x; then + cmdline+=(-Xc "$arg" -Xl "$arg") + else + cmdline+=(-Xc "$ccarg" -Xc "$arg" -Xl "$ccarg" -Xl "$arg") + fi + continue;; ldarg) cmdline+=(-Xl "$arg"); continue;; sacarg) cmdline+=("$arg"); continue;; esac -- GitLab From 8497c5ef579035aaf7d2a97787b1e6504b5b6b85 Mon Sep 17 00:00:00 2001 From: Hans-Nikolai Viessmann Date: Thu, 5 Sep 2019 18:12:50 +0200 Subject: [PATCH 2/4] add -generic flag to sac2c We have had issues with the build system using mtune=native to compile the libsac2c and the runtime libraries, making it impossible to create distributable packages without it breaking due to ISA incompatibilities. Changing the build system to not use mtune=native is doable, but involves having to filter out the mtune=native flag at the right points in the build. Additionally, when using different C compilers (such as with NVCC) we need to account for this, which may require a different solution for each compiler. This is non-trivial to achieve as in some instances the compiler is not applicable to build sac2c, but only a runtime lib or two. This commit uses a different method, which encodes the mtune=native flag into sac2crc and adds a sac2c flag (`-generic`) to toggle the effect. The advantage here is that we can define different flags for different SBIs, without affecting the build system. Furthermore, the changes to the build system are minimal, which involves propagating the flags to sac2crc and change whether libsac2c is built with mtune=native or not. --- cmake/runtime/CMakeLists.txt | 6 ++-- cmake/runtime/sac2c-variables.cmake | 4 +-- cmake/sac2c/config.cmake | 53 +++++++++++++++++------------ setup/sac2crc.backend.cuda.in | 2 ++ setup/sac2crc.pre.in | 17 ++++++++- src/libsac2c/global/globals.mac | 5 +++ src/libsac2c/global/options.c | 1 + src/libsac2c/global/usage.c | 7 ++++ src/libsac2c/modules/cctools.c | 18 +++++++--- src/libsac2c/types/types.h | 2 ++ src/tools/saccc.in | 2 +- 11 files changed, 83 insertions(+), 34 deletions(-) diff --git a/cmake/runtime/CMakeLists.txt b/cmake/runtime/CMakeLists.txt index b76e1c28e..e1678cd28 100644 --- a/cmake/runtime/CMakeLists.txt +++ b/cmake/runtime/CMakeLists.txt @@ -72,11 +72,11 @@ MACRO (ADD_LIBSAC_TARGET SRC_DIR VARIANT_TARGET) # NOTE (hans) we use the `rmod` target which uses compiler and linker specified # through the RCC and RLD sac2crc variables (additionally we use SET (SACCC "${SAC2C_BUILD_DIR}/saccc ${SAC2C_EXEC} rmod ${TARGET}") - - # In case we are using BUILDGENERIC, we need to propagate -mtune=generic + + # In case we are using BUILDGENERIC, we need propogate the sac2c `-generic` # flag to all the C files that we compile. IF (BUILDGENERIC) - SET (SACCC "${SACCC} -Xc '-mtune=generic'") + SET (SACCC "${SACCC} -Xs '-generic'") ENDIF () SET (CMAKE_C_COMPILE_OBJECT diff --git a/cmake/runtime/sac2c-variables.cmake b/cmake/runtime/sac2c-variables.cmake index f62c148dc..9ffc25d05 100644 --- a/cmake/runtime/sac2c-variables.cmake +++ b/cmake/runtime/sac2c-variables.cmake @@ -1,10 +1,10 @@ # Create local variant of the SAC2C flags SET (SAC2C_T ${SAC2C_EXEC} -target ${TARGET}) -# In case of BUILDGENERIC we need to propagate the -mtune=generic flag +# In case of BUILDGENERIC we need to propagate the -generic flag # to all the sac libraries. IF (BUILDGENERIC) - SET (SAC2C_T ${SAC2C_T} -Xc "\"-mtune=generic\"") + SET (SAC2C_T ${SAC2C_T} -generic) ENDIF () SET (SAC2C ${SAC2C_T} -Xc "\"${SAC2C_EXTRA_INC}\"" -Xtc "\"${SAC2C_EXTRA_INC}\"") diff --git a/cmake/sac2c/config.cmake b/cmake/sac2c/config.cmake index f9d592d68..fedf0579f 100644 --- a/cmake/sac2c/config.cmake +++ b/cmake/sac2c/config.cmake @@ -560,6 +560,7 @@ SET (INCS "${SAC2CRC_INCS_STR}:") # all variables need to be colon separa IF ((CMAKE_COMPILER_IS_GNUCC OR CLANG) AND (NOT MACC)) SET (GCC_FLAGS "") SET (GCC_NATIVE_FLAGS "") + SET (GCC_GENERIC_FLAGS "") CHECK_CC_FLAG ("-Wall" GCC_FLAGS) CHECK_CC_FLAG ("-Wextra" GCC_FLAGS) CHECK_CC_FLAG ("-Wstrict-prototypes" GCC_FLAGS) @@ -578,19 +579,15 @@ IF ((CMAKE_COMPILER_IS_GNUCC OR CLANG) AND (NOT MACC)) CHECK_CC_FLAG ("-Wno-strict-overflow" GCC_FLAGS) # allow fall through by virtue of comment CHECK_CC_FLAG ("-Wimplicit-fallthrough=3" GCC_FLAGS) - CHECK_CC_FLAG ("-march=native" GCC_NATIVE_FLAGS) - CHECK_CC_FLAG ("-mtune=native" GCC_NATIVE_FLAGS) # allow for vardic macros to have zero arguments CHECK_CC_FLAG ("-Wno-gnu-zero-variadic-macro-arguments" GCC_FLAGS) # give warnings if we are doing things that don't conform with C standard CHECK_CC_FLAG ("-pedantic" GCC_FLAGS) - # If the BUILDGENERIC flag is on, we build a compiler with -mtune=generic - # but we pass -march=native (if supported) to RCCCFLAGS. - SET (GCC_NATIVE_OR_GENERIC "${GCC_NATIVE_FLAGS}") - IF (BUILDGENERIC) - SET (GCC_NATIVE_OR_GENERIC "-mtune=generic") - ENDIF () + # check that this tune flags work + CHECK_CC_FLAG ("-march=native" GCC_NATIVE_FLAGS) + CHECK_CC_FLAG ("-mtune=native" GCC_NATIVE_FLAGS) + CHECK_CC_FLAG ("-mtune=generic" GCC_GENERIC_FLAGS) # FIXME(artem) Can we get these flags from the Pthread checking macro? EXECUTE_PROCESS ( @@ -606,13 +603,18 @@ IF ((CMAKE_COMPILER_IS_GNUCC OR CLANG) AND (NOT MACC)) SET (OPT_O2 "-O2") SET (OPT_O3 "-O3") SET (OPT_g "-g") - # FIXME (hans): we currently are using these flags for building the compiler as well as - # the SAC sources - which it not optimal for packaging - SET (RCCCFLAGS "${GCC_FLAGS} ${GCC_NATIVE_FLAGS} -std=gnu99 -pedantic -Wno-unused -fno-builtin") + SET (TUNE_native "${GCC_NATIVE_FLAGS}") + SET (TUNE_generic "${GCC_GENERIC_FLAGS}") + SET (RCCCFLAGS "${GCC_FLAGS} -std=gnu99 -pedantic -Wno-unused -fno-builtin") # FIXME (artem): This hack allows us to avoid propagating -Wconversion into default sac2c flags. STRING (REGEX REPLACE "-Wconversion" "" RCCCFLAGS ${RCCCFLAGS}) - SET (DEV_FLAGS "${GCC_FLAGS} ${GCC_NATIVE_OR_GENERIC} -std=gnu99 -g ${FLAGS_LTO}") - SET (PROD_FLAGS "${GCC_FLAGS} ${GCC_NATIVE_OR_GENERIC} -std=gnu99 -g -O3 ${FLAGS_LTO}") + IF (BUILDGENERIC) + SET (DEV_FLAGS "${GCC_FLAGS} ${GCC_GENERIC_FLAGS} -std=gnu99 -g ${FLAGS_LTO}") + SET (PROD_FLAGS "${GCC_FLAGS} ${GCC_GENERIC_FLAGS} -std=gnu99 -g -O3 ${FLAGS_LTO}") + ELSE () + SET (DEV_FLAGS "${GCC_FLAGS} ${GCC_NATIVE_FLAGS} -std=gnu99 -g ${FLAGS_LTO}") + SET (PROD_FLAGS "${GCC_FLAGS} ${GCC_NATIVE_FLAGS} -std=gnu99 -g -O3 ${FLAGS_LTO}") + ENDIF () SET (GENPIC "-fPIC") SET (DEPSFLAG "-M") SET (CPPFILE "${CPP_CMD} -C -x c") @@ -625,6 +627,8 @@ ELSEIF (SUNC) SET (OPT_O2 "-xO4") SET (OPT_O3 "-xO5") SET (OPT_g "-g") + SET (TUNE_native "") + SET (TUNE_generic "") SET (RCLDFLAGS "") SET (RCCCFLAGS "-dalign -fsimple -xsafe=mem -xc99=all") SET (DEV_FLAGS "-erroff=E_CAST_DOESNT_YIELD_LVALUE -g -xc99=all") @@ -641,6 +645,8 @@ ELSEIF (DECC) SET (OPT_O2 "-O2") SET (OPT_O3 "-O3") SET (OPT_g "-g") + SET (TUNE_native "") + SET (TUNE_generic "") SET (RCLDFLAGS "") SET (RCCCFLAGS "") SET (DEV_FLAGS "-g") @@ -654,6 +660,7 @@ ELSEIF (DECC) ELSEIF (MACC) SET (MACCC_FLAGS "") SET (MACCC_NATIVE_FLAGS "") + SET (MACCC_GENERIC_FLAGS "") # TODO(artem) Check whether this helps to handle the bracket error! IF ("${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang") CHECK_CC_FLAG ("-fbracket-depth=2048" MACCC_FLAGS) @@ -715,21 +722,23 @@ ELSEIF (MACC) #CHECK_CC_FLAG ("-Wconversion" MACCC_FLAGS) CHECK_CC_FLAG ("-march=native" MACCC_NATIVE_FLAGS) CHECK_CC_FLAG ("-mtune=native" MACCC_NATIVE_FLAGS) - - # but we pass -march=native (if supported) to RCCCFLAGS. - SET (MACCC_NATIVE_OR_GENERIC "${MACCC_NATIVE_FLAGS}") - IF (BUILDGENERIC) - SET (MACCC_NATIVE_OR_GENERIC "-mtune=generic") - ENDIF () + CHECK_CC_FLAG ("-mtune=generic" MACCC_GENERIC_FLAGS) SET (OPT_O0 "") SET (OPT_O1 "-O1") SET (OPT_O2 "-O2") SET (OPT_O3 "-O3") SET (OPT_g "-g") - SET (RCCCFLAGS "${MACCC_FLAGS} ${MACCC_NATIVE_FLAGS} -std=gnu99 -pedantic -Wno-unused -fno-builtin") - SET (DEV_FLAGS "${MACCC_FLAGS} ${MACCC_NATIVE_OR_GENERIC} -std=gnu99 -pedantic -g ${FLAGS_LTO}") - SET (PROD_FLAGS "${MACCC_FLAGS} ${MACCC_NATIVE_OR_GENERIC} -std=gnu99 -pedantic -g -O3 ${FLAGS_LTO}") + SET (TUNE_native "${MACCC_NATIVE_FLAGS}") + SET (TUNE_generic "${MACCC_GENERIC_FLAGS}") + SET (RCCCFLAGS "${MACCC_FLAGS} -std=gnu99 -pedantic -Wno-unused -fno-builtin") + IF (BUILDGENERIC) + SET (DEV_FLAGS "${MACCC_FLAGS} ${MACCC_GENERIC_FLAGS} -std=gnu99 -pedantic -g ${FLAGS_LTO}") + SET (PROD_FLAGS "${MACCC_FLAGS} ${MACCC_GENERIC_FLAGS} -std=gnu99 -pedantic -g -O3 ${FLAGS_LTO}") + ELSE () + SET (DEV_FLAGS "${MACCC_FLAGS} ${MACCC_NATIVE_FLAGS} -std=gnu99 -pedantic -g ${FLAGS_LTO}") + SET (PROD_FLAGS "${MACCC_FLAGS} ${MACCC_NATIVE_FLAGS} -std=gnu99 -pedantic -g -O3 ${FLAGS_LTO}") + ENDIF () SET (GENPIC "") SET (DEPSFLAG "-M") SET (CPPFILE "${CPP_CMD} -C -x c") diff --git a/setup/sac2crc.backend.cuda.in b/setup/sac2crc.backend.cuda.in index d861f50f7..3451efeeb 100644 --- a/setup/sac2crc.backend.cuda.in +++ b/setup/sac2crc.backend.cuda.in @@ -20,6 +20,8 @@ CUDA_ARCH := "@CUDA_ARCH@" USE_PHM_API := 0 CEXT := ".cu" CC := "@NVCC_PATH@/nvcc" +TUNE_native := "" +TUNE_generic := "" CFLAGS := "--maxrregcount 20 -Xcompiler -Wall -Xcompiler -fPIC " "-Xcompiler -Wno-unused -Xcompiler -fno-builtin " "-Xcudafe '--diag_suppress=set_but_not_used --diag_suppress=declared_but_not_referenced --diag_suppress=expr_has_no_effect' " diff --git a/setup/sac2crc.pre.in b/setup/sac2crc.pre.in index 98b6b7bf9..f115bfa36 100644 --- a/setup/sac2crc.pre.in +++ b/setup/sac2crc.pre.in @@ -78,7 +78,8 @@ * * %cc% Current value of CC * - * %opt% Which OPT_Ox value was selected with -O on the sac2c command line + * %opt% Which OPT_Ox value was selected with -O on the sac2c command line, + * additionally the TUNE_x flags are appended here. * * %dbg% OPT_g if -g was provided on the sac2c command line, empty otherwise * @@ -310,6 +311,16 @@ * into the generated machine code for later usage by a debugger. * This is triggered by the sac2c option -g. * + * TUNE_native The flag here instructs the C compiler to aggressively optimise + * the program, making use of extensions that are typically unique + * to the underlying architecture. Code compiled this way can typically + * not be run on other systems! + * + * TUNE_generic The flag here instructs the C compiler to apply optimisations that + * are applicable to most x86_64 architectures. Vectorisation and + * other architecture specific optimisations are not applied by the + * C compiler. + * * CEXT File name extension for generated Module/Program C source files. * * OBJEXT File name extension for Module/Program object files. @@ -448,6 +459,8 @@ OPT_O1 := "XXXXX" OPT_O2 := "XXXXX" OPT_O3 := "XXXXX" OPT_g := "XXXXX" +TUNE_native := "XXXXX" +TUNE_generic := "XXXXX" LDPATH := "XXXXX" LINK_MOD := "XXXXX" LINK_RMOD := "XXXXX" @@ -487,6 +500,8 @@ OPT_O1 := "@OPT_O1@" OPT_O2 := "@OPT_O2@" OPT_O3 := "@OPT_O3@" OPT_g := "@OPT_g@" +TUNE_native := "@TUNE_native@" +TUNE_generic := "@TUNE_generic@" LINK_MOD := "%ld% %objects% %linkflags% @LD_DYNAMIC@ @LD_PATH@ -o %target%" LINK_RMOD := "%ld% %objects% %linkflags% @LD_DYNAMIC@ @LD_PATH@ -o %target%" diff --git a/src/libsac2c/global/globals.mac b/src/libsac2c/global/globals.mac index 39afab9fa..ce6b00e16 100644 --- a/src/libsac2c/global/globals.mac +++ b/src/libsac2c/global/globals.mac @@ -592,6 +592,11 @@ GLOBAL (int, cc_optimize, 0, xfree_dummy, ) * C compiler level of optimization */ +GLOBAL (bool, cc_tune_generic, FALSE, xfree_dummy, ) +/* On true, we wil build using the C compilers tune=generic + * flag, instead of its tune=native or similar flag. + */ + /* * Optimization counters */ diff --git a/src/libsac2c/global/options.c b/src/libsac2c/global/options.c index e77bcfd5e..9c51ed1c7 100644 --- a/src/libsac2c/global/options.c +++ b/src/libsac2c/global/options.c @@ -828,6 +828,7 @@ AnalyseCommandlineSac2c (int argc, char *argv[]) */ ARGS_FLAG ("g", global.cc_debug = TRUE); + ARGS_FLAG ("generic", global.cc_tune_generic = TRUE); ARGS_FLAG ("gg", global.cc_debug = TRUE; global.cc_debug_extra = TRUE); /* diff --git a/src/libsac2c/global/usage.c b/src/libsac2c/global/usage.c index 729ca6373..6dbd4764b 100644 --- a/src/libsac2c/global/usage.c +++ b/src/libsac2c/global/usage.c @@ -1115,6 +1115,13 @@ PrintCCompilerOptions (void) " 3: full C compiler optimizations.\n" " (default: %d)\n" "\n" + " -generic Build the SaC source with C compilers 'tune=generic'\n" + " flag. This is particularly useful when compiling for\n" + " other systems that use a x86_64 processor, but whose model\n" + " is different from the current system. *NOTE* if this\n" + " flag is not given, all SaC code is compiled with\n" + " 'tune=native' or equivalent.\n" + "\n" " NOTE:\n" " The actual effects of these options are specific to " "the\n" diff --git a/src/libsac2c/modules/cctools.c b/src/libsac2c/modules/cctools.c index d8e7d3e3d..078bfdb49 100644 --- a/src/libsac2c/modules/cctools.c +++ b/src/libsac2c/modules/cctools.c @@ -172,22 +172,27 @@ CCTperformTask (ccm_task_t task) /******************* compilation flags ***********************/ // %opt% - const char *opt_subst = ""; + const char *p_opt_subst = ""; switch (global.cc_optimize) { case 0: - opt_subst = global.config.opt_o0; + p_opt_subst = global.config.opt_o0; break; case 1: - opt_subst = global.config.opt_o1; + p_opt_subst = global.config.opt_o1; break; case 2: - opt_subst = global.config.opt_o2; + p_opt_subst = global.config.opt_o2; break; case 3: - opt_subst = global.config.opt_o3; + p_opt_subst = global.config.opt_o3; break; } + // concat the tune flags + char *opt_subst = global.cc_tune_generic + ? STRcatn (3, p_opt_subst, " ", global.config.tune_generic) + : STRcatn (3, p_opt_subst, " ", global.config.tune_native); + // %dbg% const char *dbg_subst = global.cc_debug ? global.config.opt_g : ""; @@ -226,6 +231,7 @@ CCTperformTask (ccm_task_t task) = STRcatn (7, opt_subst, " ", dbg_subst, " ", cflags_subst, " ", sacincludes_subst); if (task == CCT_compileflags) { + MEMfree (opt_subst); MEMfree (cflags_subst); DBUG_RETURN (compileflags_subst); } @@ -290,6 +296,7 @@ CCTperformTask (ccm_task_t task) extlibdirs_subst, " ", saclibs_subst, " ", libs_subst); // Normally this should only be called by sac4c if (task == CCT_linkflags) { + MEMfree (opt_subst); MEMfree (cflags_subst); MEMfree (extlibdirs_subst); MEMfree (modlibdirs_subst); @@ -522,6 +529,7 @@ CCTperformTask (ccm_task_t task) } // Release all non-const strings allocated + MEMfree (opt_subst); MEMfree (cflags_subst); MEMfree (extlibdirs_subst); MEMfree (modlibdirs_subst); diff --git a/src/libsac2c/types/types.h b/src/libsac2c/types/types.h index 73a4a7b4c..e402d543f 100644 --- a/src/libsac2c/types/types.h +++ b/src/libsac2c/types/types.h @@ -785,6 +785,8 @@ typedef struct TARGET_LIST_T { DEF_RESOURCE (OPT_O2, opt_o2, char *, str) \ DEF_RESOURCE (OPT_O3, opt_o3, char *, str) \ DEF_RESOURCE (OPT_g, opt_g, char *, str) \ + DEF_RESOURCE (TUNE_native, tune_native, char *, str) \ + DEF_RESOURCE (TUNE_generic, tune_generic, char *, str) \ DEF_RESOURCE (COMPILE_MOD, compile_mod, char *, str) \ DEF_RESOURCE (COMPILE_PROG, compile_prog, char *, str) \ DEF_RESOURCE (LINK_MOD, link_mod, char *, str) \ diff --git a/src/tools/saccc.in b/src/tools/saccc.in index 02445ceee..11e1363f9 100755 --- a/src/tools/saccc.in +++ b/src/tools/saccc.in @@ -37,7 +37,7 @@ for arg in "$@"; do act=$followaction followaction= case $act in - ccarg) + ccarg) if test x"$ccarg" = x; then cmdline+=(-Xc "$arg" -Xl "$arg") else -- GitLab From d6eb03976c9b0fd4c596c3ab179e94fb59b1af64 Mon Sep 17 00:00:00 2001 From: Hans-Nikolai Viessmann Date: Thu, 5 Sep 2019 21:47:49 +0200 Subject: [PATCH 3/4] Fix up usage text --- src/libsac2c/global/usage.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/libsac2c/global/usage.c b/src/libsac2c/global/usage.c index 6dbd4764b..77febe5e8 100644 --- a/src/libsac2c/global/usage.c +++ b/src/libsac2c/global/usage.c @@ -1115,23 +1115,21 @@ PrintCCompilerOptions (void) " 3: full C compiler optimizations.\n" " (default: %d)\n" "\n" - " -generic Build the SaC source with C compilers 'tune=generic'\n" - " flag. This is particularly useful when compiling for\n" - " other systems that use a x86_64 processor, but whose model\n" - " is different from the current system. *NOTE* if this\n" - " flag is not given, all SaC code is compiled with\n" - " 'tune=native' or equivalent.\n" + " -generic Specify that the generated C code should be compiled\n" + " without any architecture specific optimisations. This\n" + " is useful when compiling for other systems.\n" + " NOTE: if this flag is not given, the C code will be\n" + " aggresively optimised to take advantage of the\n" + " current architecture.\n" "\n" " NOTE:\n" - " The actual effects of these options are specific to " - "the\n" - " C compiler used for code generation. Both the choice " - "of\n" - " a C compiler as well as the mapping of these generic\n" - " options to compiler-specific optimization options are\n" - " are determined via the sac2crc configuration file.\n" - " For details concerning sac2crc files see below under\n" - " \"customization\".\n", + " The actual effects of these options are specific to\n" + " the C compiler used for code generation. Both the\n" + " choice of a C compiler as well as the mapping of these\n" + " generic options to compiler-specific optimization\n" + " options are determined via the sac2crc configuration\n" + " file. For details concerning sac2crc files see below\n" + " under \"customization\".\n", global.cc_optimize); DBUG_RETURN (); -- GitLab From 2a66b3c588f02e70f4ba16e2d8adc172119b0328 Mon Sep 17 00:00:00 2001 From: Hans-Nikolai Viessmann Date: Fri, 6 Sep 2019 13:18:51 +0200 Subject: [PATCH 4/4] Add comment to saccc explaining C flag handling --- src/tools/saccc.in | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/tools/saccc.in b/src/tools/saccc.in index 11e1363f9..54497daf3 100755 --- a/src/tools/saccc.in +++ b/src/tools/saccc.in @@ -38,6 +38,13 @@ for arg in "$@"; do followaction= case $act in ccarg) + # when handling a C argument, we need check if the flag has an argument + # such as in the case of `-MF` which expects some filename or of `--param` + # which expects some name and value pair. If so, we append to the cmdline + # the flag and its argument as shown in the else-branch. If instead we have + # some C flag like `-install_name=name.so`, though this flag has an argument, + # it is not seperate from the flag given the `=`. As such we append it to + # cmdline as is, see the then-branch. if test x"$ccarg" = x; then cmdline+=(-Xc "$arg" -Xl "$arg") else -- GitLab