Skip to content

GHC drops -optl flags

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
Trac metadata
Trac field Value
Version 8.0.1
Type Bug
TypeOfFailure OtherFailure
Priority high
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC ezyang, simonmar
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information