[GHC] #13771: ghc fails to build on openSUSE
#13771: ghc fails to build on openSUSE --------------------------------------+--------------------------------- Reporter: msuchanek | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.2 Keywords: | Operating System: Linux Architecture: x86_64 (amd64) | Type of failure: None/Unknown Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: --------------------------------------+--------------------------------- The gcc on openSUSE defaults to -pie and reverting that fixes the build. The gcc does not set any define with -pie or -no-pie. The -no-pie flag is detected but the build fails nonetheless. Adding the PIC flag does not help: {{{ @@ -3650,6 +3650,7 @@ default_PIC :: Platform -> [GeneralFlag] default_PIC platform = case (platformOS platform, platformArch platform) of (OSDarwin, ArchX86_64) -> [Opt_PIC] + (OSLinux, ArchX86_64) -> [Opt_PIC] (OSOpenBSD, ArchX86_64) -> [Opt_PIC] -- Due to PIE support in -- OpenBSD since 5.3 release -- (1 May 2013) we need to }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13771> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13771: ghc fails to build on openSUSE ---------------------------------+-------------------------------------- Reporter: msuchanek | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.2 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+-------------------------------------- Changes (by msuchanek): * Attachment "_log.txt.xz" added. log of failed build -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13771> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13771: ghc fails to build on openSUSE ---------------------------------+-------------------------------------- Reporter: msuchanek | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.2 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+-------------------------------------- Comment (by bgamari):
The -no-pie flag is detected but the build fails nonetheless.
How in particular are you confirming that `-no-pie` is detected? What does the `settings` file look like in the root of the source tree? -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13771#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13771: ghc fails to build on openSUSE ---------------------------------+-------------------------------------- Reporter: msuchanek | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.2 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+-------------------------------------- Comment (by msuchanek): [ 48s] checking whether GCC supports -no-pie... yes settings (from different machine, unfortunately) - the original machine has been upgraded to gcc7 which fails to build in-tree ghc-pwd during configure and produces no settings anymore. This happens at most once in five years ;-) {{{ [("GCC extra via C opts", " -fwrapv -fno-builtin"), ("C compiler command", "/usr/bin/gcc"), ("C compiler flags", " -fno-stack-protector"), ("C compiler link flags", ""), ("C compiler supports -no-pie", "YES"), ("Haskell CPP command","/usr/bin/gcc"), ("Haskell CPP flags","-E -undef -traditional"), ("ld command", "/usr/bin/ld"), ("ld flags", ""), ("ld supports compact unwind", "YES"), ("ld supports build-id", "YES"), ("ld supports filelist", "NO"), ("ld is GNU ld", "YES"), ("ar command", "/usr/bin/ar"), ("ar flags", "q"), ("ar supports at file", "YES"), ("touch command", "touch"), ("dllwrap command", "/bin/false"), ("windres command", "/bin/false"), ("libtool command", "libtool"), ("perl command", "/usr/bin/perl"), ("cross compiling", "NO"), ("target os", "OSLinux"), ("target arch", "ArchX86_64"), ("target word size", "8"), ("target has GNU nonexec stack", "True"), ("target has .ident directive", "True"), ("target has subsections via symbols", "False"), ("Unregisterised", "NO"), ("LLVM llc command", "llc"), ("LLVM opt command", "opt") ] }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13771#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13771: ghc fails to build on openSUSE ---------------------------------+-------------------------------------- Reporter: msuchanek | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.2 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+-------------------------------------- Comment (by msuchanek): ok, so as I understand the issue distributions are moving towards compiling with -fPIE -pie or whatever is the current flag for whatever reason. It seems on SUSE these flags are added to rpm flags on the build service meaning system binaries are built with them but locally compiled binaries are not. Adding these flags requires that object files must be built with -fPIC and gcc complains if it is not the case and refuses to link binaries. == Issue: gcc started using PIE on system with ghc installed ==== simulation: {{{ # mv /usr/bin/gcc /usr/bin/gcc.real cat > /usr/bin/gcc <<GCC #!/bin/sh function check_pie () { while [ "$#" -gt 0 ] ; do case "$1" in -no-pie) return 1 ;; esac shift done return 0 } pie="" check_pie "$@" && pie="-fPIE -pie" exec /usr/bin/gcc.real $pie "$@" GCC }}} === symptom: {{{ $ cat HelloWorld.hs main = putStrLn "Hello World" }}} {{{ $ ghc HelloWorld.hs [1 of 1] Compiling Main ( HelloWorld.hs, HelloWorld.o ) Linking HelloWorld ... /usr/lib64/gcc/x86_64-suse-linux/6/../../../../x86_64-suse-linux/bin/ld: HelloWorld.o: relocation R_X86_64_32S against `stg_bh_upd_frame_info' can not be used when making a shared object; recompile with -fPIC HelloWorld.o: error adding symbols: Bad value collect2: error: ld returned 1 exit status }}} HelloWorld.o is not relocatable. Doing as asked gives this: {{{ ghc -fPIC HelloWorld.hs [1 of 1] Compiling Main ( HelloWorld.hs, HelloWorld.o ) Linking HelloWorld ... /usr/lib64/gcc/x86_64-suse-linux/6/../../../../x86_64-suse-linux/bin/ld: /usr/lib64/ghc-7.10.3/base_HQfYBxpPvuw8OunzQu6JGM/libHSbase-4.8.2.0-HQfYBxpPvuw8OunzQu6JGM.a(Base__116.o): relocation R_X86_64_32S against `stg_bh_upd_frame_info' can not be used when making a shared object; recompile with -fPIC /usr/lib64/ghc-7.10.3/base_HQfYBxpPvuw8OunzQu6JGM/libHSbase-4.8.2.0-HQfYBxpPvuw8OunzQu6JGM.a: error adding symbols: Bad value collect2: error: ld returned 1 exit status }}} HelloWorld.o is relocatable but system libraries are not. === workaround (provided gcc supports -no-pie): {{{ ghc -optl -no-pie HelloWorld.hs [1 of 1] Compiling Main ( HelloWorld.hs, HelloWorld.o ) Linking HelloWorld ... }}} This issue should be detected at bootstrap time before building in-tree ghc-pwd and workaround applied if possible. Otherwise build fails and user is left with broken ghc installed and no possibility to rebuild it. == Issue: gcc uses PIE by default while building/installing ghc This probably arises from -fPIC not being the default ghc option while it is the default gcc option. ==== simulation: {{{ cat hello_world.c #include <stdio.h> int main(int argc, char** argv) { puts("Hello World!"); } }}} {{{ $ gcc -fno-pic -c -Wall hello_world.c -o hello_world.o $ gcc hello_world.o -o hello_world /usr/lib64/gcc/x86_64-suse-linux/6/../../../../x86_64-suse-linux/bin/ld: hello_world.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC hello_world.o: error adding symbols: Bad value collect2: error: ld returned 1 exit status $ gcc -no-pie hello_world.o -o hello_world $ ./hello_world Hello World! }}} So gcc defaulting to PIE should be detected at bootstrap and at binary distribution installation and -fPIC should be added as default ghc flag. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13771#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC