
#15075: Sometimes '-optl-optl' used for linker options instead of just '-optl' -------------------------------------+------------------------------------- Reporter: jwhite | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Build System | Version: 8.0.2 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: #13091 Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- The build system does not construct some linker options correctly. For some options it doubles the `-optl` switch, resulting in options like {{{ -optl-optl-Wl,-arch -optl-optl-Wl,x86_64 }}} being passed to GHC, instead of {{{ -optl-Wl,-arch -optl-Wl,x86_64 }}} Root cause: in `rules/distdir-way-opts.mk`, `$1_$2_$3_ALL_LD_OPTS` is constructed with {{{ # Options for passing to gcc for linking $1_$2_$3_ALL_LD_OPTS = \ ... \ $$(foreach o,$$(EXTRA_LD_LINKER_OPTS),-optl-Wl$$(comma)$$o) \ $$(foreach o,$$(CONF_LD_LINKER_OPTS_STAGE$4),-optl-Wl$$(comma)$$o) }}} Which is then used in {{{ # Options for passing to GHC when we use it for linking $1_$2_$3_GHC_LD_OPTS = \ $$(addprefix -optl, $$($1_$2_$3_ALL_LD_OPTS)) \ $$($1_$2_$3_MOST_HC_OPTS) }}} The `-optl` in the foreach invocations in `$1_$2_$3_ALL_LD_OPTS` is not necessary, it is handled already by the addprefix call in `$1_$2_$3_GHC_LD_OPTS`. Example link command line generated by the the build system, showing the problem: {{{ "${HOME}/.stack/programs/x86_64-osx/ghc-7.10.3/bin/ghc" -o utils/hsc2hs/dist/build/tmp/hsc2hs -hisuf hi -osuf o -hcsuf hc -static -H32m -O -Wall -package-db libraries/bootstrapping.conf -hide-all-packages -i -iutils/hsc2hs/. -iutils/hsc2hs/dist/build -iutils/hsc2hs/dist/build/autogen -Iutils/hsc2hs/dist/build -Iutils/hsc2hs/dist/build/autogen -optP-include -optPutils/hsc2hs/dist/build/autogen/cabal_macros.h -package-id base-4.8.2.0-cc43d8e06aa74e9c4c0132becc49ee25 -package-id containers-0.5.6.2-68e3ece8a4f91a31e327fe89f8052a53 -package-id directory-1.2.2.0-3b3e1a8d629ccaa6c4588a9bb46bb163 -package-id filepath-1.4.0.0-f97d1e4aebfd7a03be6980454fe31d6e -package-id process-1.2.3.0-a1a69425f3f6c11a82785be7baab3b68 -XHaskell2010 -no-user-package-db -rtsopts -odir utils/hsc2hs/dist/build -hidir utils/hsc2hs/dist/build -stubdir utils/hsc2hs/dist/build -optl-optl-Wl,-arch -optl-optl-Wl,x86_64 -static -H32m -O -Wall -package-db libraries/bootstrapping.conf -hide-all-packages -i -iutils/hsc2hs/. -iutils/hsc2hs/dist/build -iutils/hsc2hs/dist/build/autogen -Iutils/hsc2hs/dist/build -Iutils/hsc2hs/dist/build/autogen -optP-include -optPutils/hsc2hs/dist/build/autogen/cabal_macros.h -package-id base-4.8.2.0-cc43d8e06aa74e9c4c0132becc49ee25 -package-id containers-0.5.6.2-68e3ece8a4f91a31e327fe89f8052a53 -package-id directory-1.2.2.0-3b3e1a8d629ccaa6c4588a9bb46bb163 -package-id filepath-1.4.0.0-f97d1e4aebfd7a03be6980454fe31d6e -package-id process-1.2.3.0-a1a69425f3f6c11a82785be7baab3b68 -XHaskell2010 -no-user-package-db -rtsopts utils/hsc2hs/dist/build/Main.o utils/hsc2hs/dist/build/C.o utils/hsc2hs/dist/build/Common.o utils/hsc2hs/dist/build/CrossCodegen.o utils/hsc2hs/dist/build/DirectCodegen.o utils/hsc2hs/dist/build/Flags.o utils/hsc2hs/dist/build/HSCParser.o utils/hsc2hs/dist/build/UtilsCodegen.o utils/hsc2hs/dist/build/Paths_hsc2hs.o }}} It affects all operating systems as far as I can tell, but only seems to cause a build failure on Solaris, see #13091. Looks like this was introduced in commit [https://phabricator.haskell.org/rGHC87c3b1d4395c3d4fc7a5272717c48f3f525da959 87c3b1d], in release 8.2.1, backported to 8.0.2 in commit [https://phabricator.haskell.org/rGHCc5f375c53671130c79713800b13a1da53d070b84 c5f375c]. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15075 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler