Sven Tennie pushed to branch wip/supersven/correctly_propagate_host-build-target at Glasgow Haskell Compiler / GHC Commits: 449962e7 by Sven Tennie at 2026-03-25T07:27:44+01:00 Respect user set CFLAGS, CXXFLAGS and LDFLAGS These were ignored on installs. - - - - - e60c93b6 by Sven Tennie at 2026-03-25T07:32:17+01:00 Only add flags if they are new This prevents duplicated when the user already set the arguments in CXXFLAGS or CFLAGS. - - - - - 3 changed files: - distrib/configure.ac.in - utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cpp.hs - utils/ghc-toolchain/src/GHC/Toolchain/Tools/Link.hs Changes: ===================================== distrib/configure.ac.in ===================================== @@ -159,6 +159,13 @@ AC_PROG_CXX([c++ g++ clang++]) MOVE_TO_FLAGS([CC],[CFLAGS]) MOVE_TO_FLAGS([CXX],[CXXFLAGS]) +dnl Initialize CONF_* variables with user-provided environment variables +dnl so that subsequent configure checks modify them and both autoconf and +dnl ghc-toolchain see the same values +CONF_CC_OPTS_STAGE2="$CFLAGS" +CONF_CXX_OPTS_STAGE2="$CXXFLAGS" +CONF_GCC_LINKER_OPTS_STAGE2="$LDFLAGS" + dnl ** figure out how to invoke the C preprocessor (i.e. `gcc -E`) AC_PROG_CPP @@ -424,6 +431,11 @@ checkMake380() { checkMake380 make checkMake380 gmake +# Respect user provided values +USER_CONF_CC_OPTS_STAGE2="$CFLAGS" +USER_CONF_CXX_OPTS_STAGE2="$CXXFLAGS" +USER_CONF_GCC_LINKER_OPTS_STAGE2="$LDFLAGS" + # Toolchain target files FIND_GHC_TOOLCHAIN_BIN([YES]) PREP_TARGET_FILE ===================================== utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cpp.hs ===================================== @@ -61,7 +61,7 @@ findHsCpp progOpt cc = checking "for Haskell C preprocessor" $ do let rawHsCppProgram = addFlagIfNew "-E" foundHsCppProg -- Always try to add the Haskell-specific CPP flags, regardless of the user options hppArgs <- findHsCppArgs rawHsCppProgram - let hsCppProgram = over _prgFlags (++hppArgs) rawHsCppProgram + let hsCppProgram = foldr addFlagIfNew rawHsCppProgram (reverse hppArgs) return HsCpp{hsCppProgram} -- | Given a C preprocessor, figure out how it should be invoked to preprocess ===================================== utils/ghc-toolchain/src/GHC/Toolchain/Tools/Link.hs ===================================== @@ -393,7 +393,7 @@ addNoAsNeeded archOs cc ccLink | os <- archOS_OS archOs , osElfTarget os = checking "that --no-as-needed works" $ do - let ccLink' = over _prgFlags (++["-Wl,--no-as-needed"]) ccLink + let ccLink' = addFlagIfNew "-Wl,--no-as-needed" ccLink checkLinkWorks cc ccLink' return ccLink' | otherwise = return ccLink View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e69759d74df3f781b46cb38c4ae7406... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e69759d74df3f781b46cb38c4ae7406... You're receiving this email because of your account on gitlab.haskell.org.