
#12738: GHC drops -optl flags -------------------------------------+------------------------------------- Reporter: niteria | Owner: Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 8.0.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- This is a regression between GHC 7.10 and GHC 8.0. Repro script: {{{ GHC_ROOT=$HOME/local/ghc-8.0.1-facebook # built 8.0.1 branch, fails with recent HEAD as well GHC=$GHC_ROOT/inplace/bin/ghc-stage2 GPP=g++ touch build_info.o # irrelevant "$GHC" -no-auto-link-packages -pgml"$GPP" -o a.out build_info.o -optl- Xlinker -optl$GHC_ROOT/libraries/ghc-prim/dist-install/build/libHSghc- prim-0.5.0.0.a -optl-Xlinker -optl-u -optl-Xlinker -optlghczmprim_GHCziTypes_Izh_static_info -v }}} Output from GHC 7.10 (expected): {{{ Glasgow Haskell Compiler, Version 7.10.2, stage 2 booted by GHC version 7.8.4 Using binary package database: /usr/local/haskell/ghc-7.10.2-x86_64/lib/ghc-7.10.2/package.conf.d/package.cache Using binary package database: /home/bnitka/.ghc/x86_64-linux-7.10.2/package.conf.d/package.cache wired-in package ghc-prim mapped to ghc- prim-0.4.0.0-af16264bc80979d06e37ac63e3ba9a21 wired-in package integer-gmp mapped to integer- gmp-1.0.0.0-8e0f14d0262184533b417ca1f8b44482 wired-in package base mapped to base-4.8.1.0-4f7206fd964c629946bb89db72c80011 wired-in package rts mapped to builtin_rts wired-in package template-haskell mapped to template- haskell-2.10.0.0-90e8393d65f4ae44cb2026177a257f28 wired-in package ghc mapped to ghc-7.10.2-787f1a784665fb3ac2a1be1d9d85245b wired-in package dph-seq not found. wired-in package dph-par not found. Hsc static flags: Created temporary directory: /tmp/ghc2775839_0 *** C Compiler: /usr/bin/gcc -fno-stack-protector -DTABLES_NEXT_TO_CODE -c /tmp/ghc2775839_0/ghc_1.c -o /tmp/ghc2775839_0/ghc_2.o -I/usr/local/haskell/ghc-7.10.2-x86_64/lib/ghc-7.10.2/include *** C Compiler: /usr/bin/gcc -fno-stack-protector -DTABLES_NEXT_TO_CODE -c /tmp/ghc2775839_0/ghc_3.s -o /tmp/ghc2775839_0/ghc_4.o -I/usr/local/haskell/ghc-7.10.2-x86_64/lib/ghc-7.10.2/include *** Linker: 'g++' '-Wl,--hash-size=31' -Wl,--reduce-memory-overheads -Wl,--no-as- needed -Xlinker /home/bnitka/local/ghc-8.0.1-facebook/libraries/ghc-prim /dist-install/build/libHSghc-prim-0.5.0.0.a -Xlinker -u -Xlinker ghczmprim_GHCziTypes_Izh_static_info -o a.out build_info.o /tmp/ghc2775839_0/ghc_2.o /tmp/ghc2775839_0/ghc_4.o build_info.o: file not recognized: File truncated collect2: ld returned 1 exit status *** Deleting temp files: Deleting: /tmp/ghc2775839_0/ghc_4.o /tmp/ghc2775839_0/ghc_3.s /tmp/ghc2775839_0/ghc_2.o /tmp/ghc2775839_0/ghc_1.c *** Deleting temp dirs: Deleting: /tmp/ghc2775839_0 }}} Output from GHC 8.0: {{{ Glasgow Haskell Compiler, Version 8.0.1.20160729, stage 2 booted by GHC version 7.10.2 Using binary package database: /data/users/bnitka/ghc-8.0.1-facebook/inplace/lib/package.conf.d/package.cache loading package database /data/users/bnitka/ghc-8.0.1-facebook/inplace/lib/package.conf.d wired-in package ghc-prim mapped to ghc-prim-0.5.0.0 wired-in package integer-gmp mapped to integer-gmp-1.0.0.1 wired-in package base mapped to base-4.9.0.0 wired-in package rts mapped to rts wired-in package template-haskell mapped to template-haskell-2.11.0.0 wired-in package ghc mapped to ghc-8.0.1.20160729 wired-in package dph-seq not found. wired-in package dph-par not found. Hsc static flags: Created temporary directory: /tmp/ghc2778573_0 *** C Compiler: /usr/bin/gcc -fno-stack-protector -DTABLES_NEXT_TO_CODE -c /tmp/ghc2778573_0/ghc_1.c -o /tmp/ghc2778573_0/ghc_2.o -I/data/users/bnitka/ghc-8.0.1-facebook/rts/dist/build -I/data/users/bnitka/ghc-8.0.1-facebook/includes -I/data/users/bnitka/ghc-8.0.1-facebook/includes/dist- derivedconstants/header *** C Compiler: /usr/bin/gcc -fno-stack-protector -DTABLES_NEXT_TO_CODE -c /tmp/ghc2778573_0/ghc_4.s -o /tmp/ghc2778573_0/ghc_5.o *** Linker: 'g++' '-Wl,--hash-size=31' -Wl,--reduce-memory-overheads -Wl,--no-as- needed -Xlinker -Xlinker -u -Xlinker ghczmprim_GHCziTypes_Izh_static_info -o a.out -Wl,--gc-sections build_info.o /tmp/ghc2778573_0/ghc_2.o /tmp/ghc2778573_0/ghc_5.o /home/bnitka/local/ghc-8.0.1-facebook/libraries /ghc-prim/dist-install/build/libHSghc-prim-0.5.0.0.a g++: ghczmprim_GHCziTypes_Izh_static_info: No such file or directory *** Deleting temp files: Deleting: /tmp/ghc2778573_0/ghc_7.rsp /tmp/ghc2778573_0/ghc_6.rsp /tmp/ghc2778573_0/ghc_5.o /tmp/ghc2778573_0/ghc_4.s /tmp/ghc2778573_0/ghc_3.rsp /tmp/ghc2778573_0/ghc_2.o /tmp/ghc2778573_0/ghc_1.c *** Deleting temp dirs: Deleting: /tmp/ghc2778573_0 `g++' failed in phase `Linker'. (Exit code: 1) }}} The relevant difference is in the flags passed to `g++`. {{{ 'g++' '-Wl,--hash-size=31' -Wl,--reduce-memory-overheads -Wl,--no-as- needed -Xlinker /home/bnitka/local/ghc-8.0.1-facebook/libraries/ghc-prim /dist-install/build/libHSghc-prim-0.5.0.0.a -Xlinker -u -Xlinker ghczmprim_GHCziTypes_Izh_static_info -o a.out build_info.o /tmp/ghc2775839_0/ghc_2.o /tmp/ghc2775839_0/ghc_4.o }}} vs {{{ 'g++' '-Wl,--hash-size=31' -Wl,--reduce-memory-overheads -Wl,--no-as- needed -Xlinker -Xlinker -u -Xlinker ghczmprim_GHCziTypes_Izh_static_info -o a.out -Wl,--gc-sections build_info.o /tmp/ghc2778573_0/ghc_2.o /tmp/ghc2778573_0/ghc_5.o /home/bnitka/local/ghc-8.0.1-facebook/libraries /ghc-prim/dist-install/build/libHSghc-prim-0.5.0.0.a }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12738 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12738: GHC drops -optl flags -------------------------------------+------------------------------------- Reporter: niteria | Owner: Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonmar): * cc: Phyx- (added) Comment: I'm suspicious of this: https://phabricator.haskell.org/diffusion/GHC/browse/master/compiler/main/Sy... -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12738#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12738: GHC drops -optl flags -------------------------------------+------------------------------------- Reporter: niteria | Owner: Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Phyx-): Yes that function does not recognize libraries passed to the linker via `-optl` or `-Xlinker` flags, only `-l` and giving the archive file as a normal argument. This was an oversight on my part. The whole reason this is even needed is because of how GHC is combining arguments from packages and libraries and commandline (https://phabricator.haskell.org/diffusion/GHC/browse/master/compiler/main/Sy...). Especially when a core package has library dependencies like base and rts. What it was attempting to prevent, is for symbols from libraries which the user didn't specify but are added due to another dependency are used during linking to resolve symbols instead of ones you provide in your link command (or vice versa). Particularly without this you would always link against the wrong `main` on Windows. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12738#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12738: GHC drops -optl flags -------------------------------------+------------------------------------- Reporter: niteria | Owner: niteria Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by niteria): * owner: => niteria Comment: I have a patch that retains `-Xlinker` flags, in the same way that 8c1ceddd50158f79f9ff103f8f34be9856d4da1d does. I'm just crafting a test now. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12738#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12738: GHC drops -optl flags -------------------------------------+------------------------------------- Reporter: niteria | Owner: niteria Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Phyx-): Thanks, Sorry for the breakage. Do you know if there are any other ways to pass library arguments to the linker than these 4? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12738#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12738: GHC drops -optl flags
-------------------------------------+-------------------------------------
Reporter: niteria | Owner: niteria
Type: bug | Status: new
Priority: high | Milestone:
Component: Compiler | Version: 8.0.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Simon Marlow

#12738: GHC drops -optl flags -------------------------------------+------------------------------------- Reporter: niteria | Owner: niteria Type: bug | Status: merge Priority: high | Milestone: 8.0.2 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonmar): * status: new => merge * milestone: => 8.0.2 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12738#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12738: GHC drops -optl flags -------------------------------------+------------------------------------- Reporter: niteria | Owner: niteria Type: bug | Status: closed Priority: high | Milestone: 8.0.2 Component: Compiler | Version: 8.0.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed Comment: Merged to `ghc-8.0` as 5c91d076c8017a89ceb43811506b9427ab85ad7e. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12738#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC