[GHC] #9873: Use CONF_GCC_LINKER_OPTS_STAGE2 only in stage2

#9873: Use CONF_GCC_LINKER_OPTS_STAGE2 only in stage2 -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Build System | Version: 7.9 Keywords: | Operating System: Architecture: Unknown/Multiple | Unknown/Multiple Difficulty: Unknown | Type of failure: Blocked By: | None/Unknown Related Tickets: | Test Case: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- On ARM, we want to make sure that GHC uses the gold linker. In order to achieve that, we need to get `-fuse-ld=gold` into SettingsCCompilerLinkFlags in the settings. This field is filled with only CONF_GCC_LINKER_OPTS_STAGE2. So we want that flag to show up there. But this variable is used in other places as well. For example, the configuration of tinfo fails: {{{ $ make libraries/terminfo/dist-boot/package-data.mk ===--- building phase 0 make -r --no-print-directory -f ghc.mk phase=0 phase_0_builds libraries/terminfo/ghc.mk:3: libraries/terminfo/dist-boot/package-data.mk: Datei oder Verzeichnis nicht gefunden "inplace/bin/ghc-cabal" configure libraries/terminfo dist-boot "" --with- ghc="/usr/bin/ghc" --with-ghc-pkg="/usr/bin/ghc-pkg" --package- db=/home/jojo/build/haskell/ghc/libraries/bootstrapping.conf --disable- library-for-ghci --enable-library-vanilla --disable-library-profiling --disable-shared --with-hscolour="/usr/bin/HsColour" --configure- option=CFLAGS=" -fno-stack-protector " --configure-option=LDFLAGS=" -fuse-ld=gold " --configure-option=CPPFLAGS=" " --gcc-options=" -fno- stack-protector -fuse-ld=gold " --constraint "binary == 0.7.1.0" --constraint "Cabal == 1.21.1.0" --constraint "hpc == 0.6.0.2" --constraint "bin-package-db == 0.0.0.0" --constraint "hoopl == 3.10.0.2" --constraint "transformers == 0.4.2.0" --constraint "terminfo == 0.4.0.0" --with-gcc="/usr/bin/gcc" --configure-option=--with- cc="/usr/bin/gcc" --with-ar="/usr/bin/ar" --with-alex="/usr/bin/alex" --with-happy="/usr/bin/happy" Configuring terminfo-0.4.0.0... configure: WARNING: unrecognized options: --with-compiler, --with-gcc checking for gcc... /usr/bin/gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether /usr/bin/gcc accepts -g... yes checking for /usr/bin/gcc option to accept ISO C89... none needed checking how to run the C preprocessor... /usr/bin/gcc -E checking for grep that handles long lines and -e... /bin/grep checking for egrep... /bin/grep -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking ncurses.h usability... yes checking ncurses.h presence... yes checking for ncurses.h... yes checking for setupterm in -ltinfo... yes configure: creating ./config.status config.status: creating terminfo.buildinfo configure: WARNING: unrecognized options: --with-compiler, --with-gcc ghc-cabal: Missing dependency on a foreign library: * Missing C library: tinfo This problem can usually be solved by installing the system package that provides this library (you may need the "-dev" version). If the library is already installed but in a non-standard location then you can use the flags --extra-include-dirs= and --extra-lib-dirs= to specify where it is. libraries/terminfo/ghc.mk:3: recipe for target 'libraries/terminfo/dist- boot/package-data.mk' failed make[1]: *** [libraries/terminfo/dist-boot/package-data.mk] Error 1 Makefile:71: recipe for target 'libraries/terminfo/dist-boot/package- data.mk' failed make: *** [libraries/terminfo/dist-boot/package-data.mk] Error 2 }}} The problem (unfortunately, not very visible) is that `ghc-cabal` calls `gcc` to test if the C libaries are available. It uses the linker flags that it’s being told to use from the host GHC (here: 7.6.3), which contains the usual: {{{ $ ghc --info |fgrep 'C compiler flags' ,("C compiler flags"," -fno-stack-protector -Wl,--hash-size=31 -Wl ,--reduce-memory-overheads") }}} But to that it adds `-fuse-ld-gold` because `ghc-cabal` is gets `" --gcc- options=" -fno-stack-protector -fuse-ld=gold "` passed. So the build system should not pass flags from `CONF_GCC_LINKER_OPTS_STAGE2` anywhere besides gcc when used *by the stage 2 ghc* during linking. The chain of variables leading to this can be seen here: {{{ $ git grep CONFIGURE_LDFLAGS rules/build-package-data.mk:$1_$2_CONFIGURE_LDFLAGS = $$(SRC_LD_OPTS) $$(CONF_GCC_LINKER_OPTS_STAGE$3) $$($1_LD_OPTS) $$($1_$2_LD_OPTS) rules/build-package-data.mk:$1_$2_CONFIGURE_OPTS += --configure- option=LDFLAGS="$$($1_$2_CONFIGURE_LDFLAGS)" rules/build-package-data.mk:$1_$2_CONFIGURE_OPTS += --gcc- options="$$($1_$2_CONFIGURE_CFLAGS) $$($1_$2_CONFIGURE_LDFLAGS)" }}} I’m currently experimenting with a patch that simply does not use `CONF_GCC_LINKER_OPTS_STAGE` anywhere besides when defining `SettingsCCompilerLinkFlags`, but I’m afraid that this might introduce new unwanted behaviour. But since `ghc-cabal` reads gcc-flags from `ghc --info`, maybe that channel of information is sufficient. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9873 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9873: Use CONF_GCC_LINKER_OPTS_STAGE2 only in stage2 -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Build | Version: 7.9 System | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by nomeata): This is the patch I use in the Debian package for now. Maybe it is good enough already? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9873#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9873: Use CONF_GCC_LINKER_OPTS_STAGE2 only in stage2 -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Build | Version: 7.9 System | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by nomeata): Did you also apply the patch that actually makes it use `gold`? {{{ Index: ghc-7.8.3.20141119/aclocal.m4 =================================================================== --- ghc-7.8.3.20141119.orig/aclocal.m4 2014-12-08 18:49:28.207171714+0100 +++ ghc-7.8.3.20141119/aclocal.m4 2014-12-08 19:03:06.815522917+0100 @@ -553,6 +553,10 @@ $3="$$3 -D_HPUX_SOURCE" $5="$$5 -D_HPUX_SOURCE" ;; + arm*) + # On arm, link using gold + $3="$$3 -fuse-ld=gold" + ;; esac # If gcc knows about the stack protector, turn it off. }}} And how does it fail? Did it run `dll-split` successfully? Might be a different issue. You should talk to gamari about it. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9873#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9873: Use CONF_GCC_LINKER_OPTS_STAGE2 only in stage2 -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Build | Version: 7.9 System | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by erikd): Nope missed that bit. Retrying now. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9873#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9873: Use CONF_GCC_LINKER_OPTS_STAGE2 only in stage2 -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Build | Version: 7.9 System | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by erikd): It fails the first time it tries to run an executable generated by the stage1 compiler. During some earlier testing I had disabled compiling the `dyn` way, so the first failure was with the `inplace/bin/ghc-stage2` binary. If I re-enable the `dyn` way, the first failure is when the build tries to run `inplace/bin/dll-split`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9873#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9873: Use CONF_GCC_LINKER_OPTS_STAGE2 only in stage2 -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Build | Version: 7.9 System | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by nomeata): Without a build logs, it’s hard to help here. Any please open a new ticket or discuss it on ghc-dev, this on is about a deficiency in the build system. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9873#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9873: Use CONF_GCC_LINKER_OPTS_STAGE2 only in stage2 -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Build | Version: 7.9 System | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by erikd): Mine was a separate problem so I raised ticket #9920. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9873#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9873: Use CONF_GCC_LINKER_OPTS_STAGE2 only in stage2 -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: bug | Status: patch Priority: normal | Milestone: Component: Build System | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by thomie): * status: new => patch -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9873#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9873: Use CONF_GCC_LINKER_OPTS_STAGE2 only in stage2
-------------------------------------+-------------------------------------
Reporter: nomeata | Owner:
Type: bug | Status: patch
Priority: normal | Milestone:
Component: Build System | Version: 7.9
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: None/Unknown | Unknown/Multiple
Blocked By: | Test Case:
Related Tickets: | Blocking:
| Differential Revisions:
-------------------------------------+-------------------------------------
Comment (by Erik de Castro Lopo

#9873: Use CONF_GCC_LINKER_OPTS_STAGE2 only in stage2 -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Build System | Version: 7.9 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by erikd): * status: patch => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9873#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9873: Use CONF_GCC_LINKER_OPTS_STAGE2 only in stage2 -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: bug | Status: merge Priority: normal | Milestone: Component: Build System | Version: 7.9 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by erikd): * status: closed => merge -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9873#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9873: Use CONF_GCC_LINKER_OPTS_STAGE2 only in stage2 -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: bug | Status: closed Priority: normal | Milestone: 7.10.1 Component: Build System | Version: 7.9 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by thoughtpolice): * status: merge => closed * milestone: => 7.10.1 Comment: Merged via a86fe8a4602e8e57f3aff3f2bc78055a8fa8fe2e & 072cc766016bf4a09a477f98bb16cf55b253c4f6. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9873#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC