summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@well-typed.com>2022-12-14 17:15:08 -0500
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-12-24 00:41:05 -0500
commit5eb357d905c63cfbe6287a99fbaa8d83289d1a22 (patch)
tree7d44ccf527f093987fa9eee1e3f24a8b71c2e726
parentaebef31cd8857749c7e25fe4b0d3ce4e12ae225a (diff)
downloadhaskell-5eb357d905c63cfbe6287a99fbaa8d83289d1a22.tar.gz
compiler: Ensure that GHC toolchain is first in search path
As noted in #22561, it is important that GHC's toolchain look first for its own headers and libraries to ensure that the system's are not found instead. If this happens things can break in surprising ways (e.g. see #22561).
-rw-r--r--compiler/GHC/Settings/IO.hs10
-rw-r--r--m4/fp_settings.m48
2 files changed, 9 insertions, 9 deletions
diff --git a/compiler/GHC/Settings/IO.hs b/compiler/GHC/Settings/IO.hs
index 074b9a791c..06952774fd 100644
--- a/compiler/GHC/Settings/IO.hs
+++ b/compiler/GHC/Settings/IO.hs
@@ -79,11 +79,11 @@ initSettings top_dir = do
myExtraGccViaCFlags <- getSetting "GCC extra via C opts"
cc_prog <- getToolSetting "C compiler command"
cxx_prog <- getToolSetting "C++ compiler command"
- cc_args_str <- getSetting "C compiler flags"
- cxx_args_str <- getSetting "C++ compiler flags"
+ cc_args_str <- getToolSetting "C compiler flags"
+ cxx_args_str <- getToolSetting "C++ compiler flags"
gccSupportsNoPie <- getBooleanSetting "C compiler supports -no-pie"
cpp_prog <- getToolSetting "Haskell CPP command"
- cpp_args_str <- getSetting "Haskell CPP flags"
+ cpp_args_str <- getToolSetting "Haskell CPP flags"
platform <- either pgmError pure $ getTargetPlatform settingsFile mySettings
@@ -123,13 +123,13 @@ initSettings top_dir = do
-- Other things being equal, as and ld are simply gcc
- cc_link_args_str <- getSetting "C compiler link flags"
+ cc_link_args_str <- getToolSetting "C compiler link flags"
let as_prog = cc_prog
as_args = map Option cc_args
ld_prog = cc_prog
ld_args = map Option (cc_args ++ words cc_link_args_str)
ld_r_prog <- getToolSetting "Merge objects command"
- ld_r_args <- getSetting "Merge objects flags"
+ ld_r_args <- getToolSetting "Merge objects flags"
let ld_r
| null ld_r_prog = Nothing
| otherwise = Just (ld_r_prog, map Option $ words ld_r_args)
diff --git a/m4/fp_settings.m4 b/m4/fp_settings.m4
index 0b75cf8d35..d179e1013a 100644
--- a/m4/fp_settings.m4
+++ b/m4/fp_settings.m4
@@ -10,12 +10,12 @@ AC_DEFUN([FP_SETTINGS],
# See Note [tooldir: How GHC finds mingw on Windows]
mingw_bin_prefix='$$tooldir/mingw/bin/'
SettingsCCompilerCommand="${mingw_bin_prefix}clang.exe"
- SettingsCCompilerFlags="$CONF_CC_OPTS_STAGE2"
+ SettingsCCompilerFlags="$CONF_CC_OPTS_STAGE2 -I$$tooldir/mingw/include"
SettingsCxxCompilerCommand="${mingw_bin_prefix}clang++.exe"
- SettingsCxxCompilerFlags="$CONF_CXX_OPTS_STAGE2"
- SettingsCCompilerLinkFlags="$CONF_GCC_LINKER_OPTS_STAGE2"
+ SettingsCxxCompilerFlags="$CONF_CXX_OPTS_STAGE2 -I$$tooldir/mingw/include"
+ SettingsCCompilerLinkFlags="$CONF_GCC_LINKER_OPTS_STAGE2 -L$$tooldir/mingw/lib -L$$tooldir/mingw/x86_64-w64-mingw32/lib"
SettingsHaskellCPPCommand="${mingw_bin_prefix}clang.exe"
- SettingsHaskellCPPFlags="$HaskellCPPArgs"
+ SettingsHaskellCPPFlags="$HaskellCPPArgs -I$$tooldir/mingw/include"
SettingsLdCommand="${mingw_bin_prefix}ld.lld.exe"
SettingsLdFlags=""
# LLD does not support object merging (#21068)