diff options
-rw-r--r-- | aclocal.m4 | 41 | ||||
-rw-r--r-- | compiler/GHC/Settings/IO.hs | 2 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | hadrian/cfg/system.config.in | 9 | ||||
-rw-r--r-- | hadrian/src/Builder.hs | 2 | ||||
-rw-r--r-- | mk/config.mk.in | 10 | ||||
-rw-r--r-- | rules/build-package-way.mk | 3 |
7 files changed, 45 insertions, 24 deletions
diff --git a/aclocal.m4 b/aclocal.m4 index 1921304ed7..b1f52cb7e1 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -532,6 +532,10 @@ AC_DEFUN([FP_SETTINGS], SettingsHaskellCPPCommand="${mingw_bin_prefix}gcc.exe" SettingsHaskellCPPFlags="$HaskellCPPArgs" SettingsLdCommand="${mingw_bin_prefix}ld.exe" + # Overrides FIND_MERGE_OBJECTS in order to avoid hard-coding linker + # path on Windows (#18550). + SettingsMergeObjectsCommand="${SettingsLdCommand}" + SettingsMergeObjectsFlags="-r --oformat=pe-bigobj-x86-64" SettingsArCommand="${mingw_bin_prefix}ar.exe" SettingsRanlibCommand="${mingw_bin_prefix}ranlib.exe" SettingsDllWrapCommand="${mingw_bin_prefix}dllwrap.exe" @@ -545,6 +549,8 @@ AC_DEFUN([FP_SETTINGS], SettingsHaskellCPPCommand="$(basename $HaskellCPPCmd)" SettingsHaskellCPPFlags="$HaskellCPPArgs" SettingsLdCommand="$(basename $LdCmd)" + SettingsMergeObjectsCommand="$(basename $MergeObjsCmd)" + SettingsMergeObjectsFlags="$MergeObjsArgs" SettingsArCommand="$(basename $ArCmd)" SettingsDllWrapCommand="$(basename $DllWrapCmd)" SettingsWindresCommand="$(basename $WindresCmd)" @@ -554,6 +560,8 @@ AC_DEFUN([FP_SETTINGS], SettingsHaskellCPPCommand="$HaskellCPPCmd" SettingsHaskellCPPFlags="$HaskellCPPArgs" SettingsLdCommand="$LdCmd" + SettingsMergeObjectsCommand="$MergeObjsCmd" + SettingsMergeObjectsFlags="$MergeObjsArgs" SettingsArCommand="$ArCmd" SettingsRanlibCommand="$RanlibCmd" if test -z "$DllWrapCmd" @@ -609,6 +617,8 @@ AC_DEFUN([FP_SETTINGS], AC_SUBST(SettingsCCompilerSupportsNoPie) AC_SUBST(SettingsLdCommand) AC_SUBST(SettingsLdFlags) + AC_SUBST(SettingsMergeObjectsCommand) + AC_SUBST(SettingsMergeObjectsFlags) AC_SUBST(SettingsArCommand) AC_SUBST(SettingsRanlibCommand) AC_SUBST(SettingsDllWrapCommand) @@ -2625,7 +2635,7 @@ AC_DEFUN([CHECK_FOR_GOLD_T22266],[ ]) $CC -c -o conftest.a.o conftest.a.c || AC_MSG_ERROR([Failed to compile test]) - $SettingsMergeObjectsCommand $SettingsMergeObjectsFlags -T conftest.t conftest.a.o -o conftest.ar.o || AC_MSG_ERROR([Failed to merge test object]) + $MergeObjsCmd $MergeObjsArgs -T conftest.t conftest.a.o -o conftest.ar.o || AC_MSG_ERROR([Failed to merge test object]) $CC -c -o conftest.main.o conftest.main.c || AC_MSG_ERROR([Failed to compile test driver]) $CC conftest.ar.o conftest.main.o -o conftest || AC_MSG_ERROR([Failed to link test driver]) @@ -2645,33 +2655,30 @@ AC_DEFUN([CHECK_FOR_GOLD_T22266],[ # ------------------ # Find which linker to use to merge object files. # +# See Note [Merging object files for GHCi] in GHC.Driver.Pipeline. AC_DEFUN([FIND_MERGE_OBJECTS],[ AC_REQUIRE([FIND_LD]) - if test -z "$SettingsMergeObjectsCommand"; then - SettingsMergeObjectsCommand="$LD" + if test -z "$MergeObjsCmd"; then + MergeObjsCmd="$LD" fi - if test -z "$SettingsMergeObjectsFlags"; then - SettingsMergeObjectsFlags="-r" + if test -z "$MergeObjsArgs"; then + MergeObjsArgs="-r" fi - CHECK_FOR_GOLD_T22266($SettingsMergeObjectsCommand) + CHECK_FOR_GOLD_T22266($MergeObjsCmd) if test "$result" = "1"; then - AC_MSG_NOTICE([$SettingsMergeObjectsCommand is broken due to binutils 22266, looking for another linker...]) - SettingsMergeObjectsCommand="" - AC_CHECK_TARGET_TOOL([SettingsMergeObjectsCommand], [ld]) - CHECK_FOR_GOLD_T22266($SettingsMergeObjectsCommand) + AC_MSG_NOTICE([$MergeObjsCmd is broken due to binutils 22266, looking for another linker...]) + MergeObjsCmd="" + AC_CHECK_TARGET_TOOL([MergeObjsCmd], [ld]) + CHECK_FOR_GOLD_T22266($MergeObjsCmd) if test "$result" = "1"; then - AC_MSG_ERROR([Linker is affected by binutils 22266 but couldn't find another unaffected linker. Please set the SettingsMergeObjectsCommand variable to a functional linker.]) + AC_MSG_ERROR([Linker is affected by binutils 22266 but couldn't find another unaffected linker. Please set the MergeObjsCmd variable to a functional linker.]) fi fi - if test "$windows" = YES -a "$EnableDistroToolchain" = "NO" -a "$WORD_SIZE" = 64; then - SettingsMergeObjectsFlags="$SettingsMergeObjectsFlags --oformat=pe-bigobj-x86-64" - fi - - AC_SUBST(SettingsMergeObjectsCommand) - AC_SUBST(SettingsMergeObjectsFlags) + AC_SUBST([MergeObjsCmd]) + AC_SUBST([MergeObjsArgs]) ]) # FIND_PYTHON diff --git a/compiler/GHC/Settings/IO.hs b/compiler/GHC/Settings/IO.hs index b5defa0ee2..82f0b6b2d9 100644 --- a/compiler/GHC/Settings/IO.hs +++ b/compiler/GHC/Settings/IO.hs @@ -137,7 +137,7 @@ initSettings top_dir = do as_args = map Option cc_args ld_prog = cc_prog ld_args = map Option (cc_args ++ words cc_link_args_str) - ld_r_prog <- getSetting "Merge objects command" + ld_r_prog <- getToolSetting "Merge objects command" ld_r_args <- getSetting "Merge objects flags" llvmTarget <- getSetting "LLVM target" diff --git a/configure.ac b/configure.ac index 5e3dfa5470..f080b296bf 100644 --- a/configure.ac +++ b/configure.ac @@ -449,6 +449,8 @@ then NM="${mingwbin}nm.exe" RANLIB="${mingwbin}ranlib.exe" OBJDUMP="${mingwbin}objdump.exe" + MergeObjsCmd="$LD" + MergeObjsArgs="-r --oformat=pe-bigobj-x86-64" fp_prog_ar="${mingwbin}ar.exe" AC_PATH_PROG([Genlib],[genlib]) diff --git a/hadrian/cfg/system.config.in b/hadrian/cfg/system.config.in index 5abcb96b7e..adc244fa7d 100644 --- a/hadrian/cfg/system.config.in +++ b/hadrian/cfg/system.config.in @@ -14,6 +14,7 @@ hs-cpp = @HaskellCPPCmd@ ld = @LdCmd@ make = @MakeCmd@ nm = @NmCmd@ +merge-objects = @MergeObjsCmd@ objdump = @ObjdumpCmd@ ranlib = @REAL_RANLIB_CMD@ sphinx-build = @SPHINXBUILD@ @@ -117,10 +118,10 @@ conf-ld-linker-args-stage1 = @CONF_LD_LINKER_OPTS_STAGE1@ conf-ld-linker-args-stage2 = @CONF_LD_LINKER_OPTS_STAGE2@ conf-ld-linker-args-stage3 = @CONF_LD_LINKER_OPTS_STAGE3@ -conf-merge-objects-args-stage0 = @SettingsMergeObjectsFlags@ -conf-merge-objects-args-stage1 = @SettingsMergeObjectsFlags@ -conf-merge-objects-args-stage2 = @SettingsMergeObjectsFlags@ -conf-merge-objects-args-stage3 = @SettingsMergeObjectsFlags@ +conf-merge-objects-args-stage0 = @MergeObjsArgs@ +conf-merge-objects-args-stage1 = @MergeObjsArgs@ +conf-merge-objects-args-stage2 = @MergeObjsArgs@ +conf-merge-objects-args-stage3 = @MergeObjsArgs@ # Settings: diff --git a/hadrian/src/Builder.hs b/hadrian/src/Builder.hs index 072a2edd73..e4b16e5156 100644 --- a/hadrian/src/Builder.hs +++ b/hadrian/src/Builder.hs @@ -317,7 +317,7 @@ systemBuilderPath builder = case builder of Happy -> fromKey "happy" HsCpp -> fromKey "hs-cpp" Ld _ -> fromKey "ld" - MergeObjects _ -> fromKey "settings-merge-objects-command" + MergeObjects _ -> fromKey "merge-objects" Make _ -> fromKey "make" Makeinfo -> fromKey "makeinfo" Nm -> fromKey "nm" diff --git a/mk/config.mk.in b/mk/config.mk.in index 11760686ea..2c30a7f501 100644 --- a/mk/config.mk.in +++ b/mk/config.mk.in @@ -545,6 +545,16 @@ LD_STAGE1 = $(LD) LD_STAGE2 = $(LD) LD_STAGE3 = $(LD) +MERGE_OBJS_STAGE0 = @MergeObjsCmd@ +MERGE_OBJS_STAGE1 = @MergeObjsCmd@ +MERGE_OBJS_STAGE2 = @MergeObjsCmd@ +MERGE_OBJS_STAGE3 = @MergeObjsCmd@ + +MERGE_OBJS_STAGE0_FLAGS = @MergeObjsArgs@ +MERGE_OBJS_STAGE1_FLAGS = @MergeObjsArgs@ +MERGE_OBJS_STAGE2_FLAGS = @MergeObjsArgs@ +MERGE_OBJS_STAGE3_FLAGS = @MergeObjsArgs@ + # Cross-compiling options # See Note [CrossCompiling vs Stage1Only] CrossCompiling = @CrossCompiling@ diff --git a/rules/build-package-way.mk b/rules/build-package-way.mk index a2a1e9a8fe..c1b95032ac 100644 --- a/rules/build-package-way.mk +++ b/rules/build-package-way.mk @@ -107,6 +107,7 @@ endif endif # Build the GHCi library +# See Note [Merging object files for GHCi] in GHC.Driver.Pipeline. ifneq "$(filter $3, v p)" "" $1_$2_$3_GHCI_LIB = $1/$2/build/HS$$($1_$2_COMPONENT_ID).$$($3_osuf) ifeq "$$($1_$2_BUILD_GHCI_LIB)" "YES" @@ -116,7 +117,7 @@ BINDIST_LIBS += $$($1_$2_$3_GHCI_LIB) endif endif $$($1_$2_$3_GHCI_LIB) : $$($1_$2_$3_HS_OBJS) $$($1_$2_$3_CMM_OBJS) $$($1_$2_$3_C_OBJS) $$($1_$2_$3_S_OBJS) $$($1_$2_EXTRA_OBJS) $$($1_$2_LD_SCRIPT) - $$(call cmd,SettingsMergeObjectsCommand) $(SettingsMergeObjectsFlags) $$(if $$($1_$2_LD_SCRIPT),$$($1_$2_LD_SCRIPT_CMD) $$($1_$2_LD_SCRIPT)) -o $$@ $$(EXTRA_LD_LINKER_OPTS) $$($1_$2_$3_HS_OBJS) $$($1_$2_$3_CMM_OBJS) $$($1_$2_$3_C_OBJS) $$($1_$2_$3_S_OBJS) $$($1_$2_EXTRA_OBJS) + $$(call cmd,MERGE_OBJS_STAGE$4) $(MERGE_OBJS_STAGE$4_FLAGS) $$(if $$($1_$2_LD_SCRIPT),$$($1_$2_LD_SCRIPT_CMD) $$($1_$2_LD_SCRIPT)) -o $$@ $$(EXTRA_LD_LINKER_OPTS) $$($1_$2_$3_HS_OBJS) $$($1_$2_$3_CMM_OBJS) $$($1_$2_$3_C_OBJS) $$($1_$2_$3_S_OBJS) $$($1_$2_EXTRA_OBJS) ifeq "$$($1_$2_BUILD_GHCI_LIB)" "YES" # Don't bother making ghci libs for bootstrapping packages ifneq "$4" "0" |