[GHC] #9524: GHC uses wrong linker when cross compiling

#9524: GHC uses wrong linker when cross compiling -------------------------------------+------------------------------------- Reporter: Kritzefitz | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (FFI) | Version: 7.8.3 Keywords: | Operating System: Architecture: Unknown/Multiple | Unknown/Multiple Difficulty: Unknown | Type of failure: Building Blocked By: | GHC failed Related Tickets: | Test Case: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Greetings, I tried to compile a cross compiler for x86_64-w64-mingw32. Most of GHC compiles fine. However, after a while there's an error that ld can't find a reference to "GetModuleFileNameW". I tried compiling a dummy C program with that symbol and it compiles fine. My guess is that GHC is using the wrong linker during cross-compiling, whereas GCC uses the right one. But I may be totally wrong, so please don't rely on that judgement. The log of the make run is attached. Regards Sven -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9524 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9524: GHC uses wrong linker when cross compiling -------------------------------------+------------------------------------- Reporter: Kritzefitz | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Build | Version: 7.8.3 System | Keywords: Cross compiling Resolution: | Architecture: x86 Operating System: Linux | Difficulty: Unknown Type of failure: Building | Blocked By: GHC failed | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by Kritzefitz): * keywords: => Cross compiling * os: Unknown/Multiple => Linux * component: Compiler (FFI) => Build System * architecture: Unknown/Multiple => x86 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9524#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9524: GHC uses wrong linker when cross compiling -------------------------------------+------------------------------------- Reporter: Kritzefitz | Owner: rwbarton Type: bug | Status: new Priority: normal | Milestone: Component: Build | Version: 7.8.3 System | Keywords: Cross compiling Resolution: | Architecture: x86 Operating System: Linux | Difficulty: Unknown Type of failure: Building | Blocked By: GHC failed | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by rwbarton): * owner: => rwbarton Comment: It's not that GHC is using the wrong linker, it's that GHC built the wrong code: this hsc2hs is supposed to run on your host system which is Linux (you can tell because it is being built by `/usr/bin/ghc`, which is not a cross-compiler), so it should not be calling `GetModuleFileNameW`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9524#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9524: GHC uses wrong linker when cross compiling -------------------------------------+------------------------------------- Reporter: Kritzefitz | Owner: rwbarton Type: bug | Status: new Priority: normal | Milestone: Component: Build | Version: 7.8.4 System | Keywords: Cross compiling Resolution: | Architecture: x86 Operating System: Linux | Difficulty: Unknown Type of failure: Building | Blocked By: GHC failed | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by Kritzefitz): * version: 7.8.3 => 7.8.4 Comment: That makes sense. Thanks for clarification, I just reproduces this with GHC 7.8.4 and had the same result. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9524#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9524: GHC uses wrong linker when cross compiling -------------------------------------+------------------------------------- Reporter: Kritzefitz | Owner: rwbarton Type: bug | Status: new Priority: normal | Milestone: Component: Build | Version: 7.8.4 System | Keywords: Cross compiling Resolution: | Architecture: x86 Operating System: Linux | Difficulty: Unknown Type of failure: Building | Blocked By: GHC failed | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by rwbarton): I suspect the fix is just to delete the first three non-comment lines of hsc2hs's Main.hs, but my GHC HEAD cross-compiling setup is failing for an unrelated reason so I can't test it right now. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9524#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9524: GHC uses wrong linker when cross compiling -------------------------------------+------------------------------------- Reporter: Kritzefitz | Owner: rwbarton Type: bug | Status: new Priority: normal | Milestone: Component: Build | Version: 7.8.4 System | Keywords: Cross compiling Resolution: | Architecture: x86 Operating System: Linux | Difficulty: Unknown Type of failure: Building | Blocked By: GHC failed | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by Kritzefitz): I tested it (with 7.8.4) and the problem with `GetModuleFileNameW` went away. It's now failing with the failure message that threads aren't supported. Is this related or should I open another ticket? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9524#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9524: GHC uses wrong linker when cross compiling -------------------------------------+------------------------------------- Reporter: Kritzefitz | Owner: rwbarton Type: bug | Status: new Priority: normal | Milestone: Component: Build | Version: 7.8.4 System | Keywords: Cross compiling Resolution: | Architecture: x86 Operating System: Linux | Difficulty: Unknown Type of failure: Building | Blocked By: GHC failed | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by rwbarton): It looks like a different bug (probably of the same type) so please open another ticket, thanks. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9524#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9524: GHC uses wrong linker when cross compiling -------------------------------------+------------------------------------- Reporter: Kritzefitz | Owner: rwbarton Type: bug | Status: new Priority: normal | Milestone: Component: Build | Version: 7.8.4 System | Keywords: Cross compiling Resolution: | Architecture: x86 Operating System: Linux | Difficulty: Unknown Type of failure: Building | Blocked By: GHC failed | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by Kritzefitz): done: #9932 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9524#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9524: GHC uses wrong linker when cross compiling -------------------------------------+------------------------------------- Reporter: Kritzefitz | Owner: rwbarton Type: bug | Status: new Priority: normal | Milestone: Component: Build System | Version: 7.8.4 Resolution: | Keywords: Cross Operating System: Linux | compiling Type of failure: Building GHC | Architecture: x86 failed | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by erikd): Working on a patch for this. Have actually made is past the `hsc2hs` part, but don't have a complete build yet. @rwbarton : Mind if I steal this ticket ? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9524#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9524: GHC uses wrong linker when cross compiling -------------------------------------+------------------------------------- Reporter: Kritzefitz | Owner: rwbarton Type: bug | Status: new Priority: normal | Milestone: Component: Build System | Version: 7.8.4 Resolution: | Keywords: Cross Operating System: Linux | compiling Type of failure: Building GHC | Architecture: x86 failed | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by erikd): The problem was that the `hsc2hs` code has a number of code blocks wrapped in: {{{ #if defined(mingw_HOST_OS) }}} and `mingw_HOST_OS` is defined when cross compiling from Linux/OSX to Windows. If I change the above to: {{{ #if (defined(mingw32_HOST_OS) && HostPlatform_TYPE == mingw32_HOST_OS) }}} the cross-compile process proceeds past this issue and runs into other issues later in the compile process. I don't have a Windows machine to test that this doesn't break MinGW native builds but the above certainly seems sensible. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9524#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9524: GHC uses wrong linker when cross compiling -------------------------------------+------------------------------------- Reporter: Kritzefitz | Owner: rwbarton Type: bug | Status: new Priority: normal | Milestone: Component: Build System | Version: 7.8.4 Resolution: | Keywords: Cross Operating System: Linux | compiling Type of failure: Building GHC | Architecture: x86 failed | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by rwbarton): Oh, I was going to batch this with some other hsc2hs fixes, and then I got sidetracked. I think the fix of simply removing the `#include "../../includes/ghcconfig.h"` is better though. #including that file in a Haskell program is risky business, since the `foo_HOST_OS` CPP symbol it defines is in the same namespace as the `bar_HOST_OS` CPP symbol that is automatically defined by any run of GHC. For example, in the case under discussion here, both `linux_HOST_OS` and `mingw_HOST_OS` are defined since hsc2hs is being built with the bootstrap compiler. There should be no need for hsc2hs to know about the eventual target machine type, only the machine type that it is being built to run on. Or in other words, it is sensible to build hsc2hs independently of the GHC build process. So, let's just remove that #include to ensure that we only get the right versions of the `foo_HOST_OS` symbols, the ones that come from whatever GHC is building hsc2hs, and which are correct for the machine hsc2hs is to run on. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9524#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9524: GHC uses wrong linker when cross compiling -------------------------------------+------------------------------------- Reporter: Kritzefitz | Owner: rwbarton Type: bug | Status: patch Priority: normal | Milestone: Component: Build System | Version: 7.8.4 Resolution: | Keywords: Cross Operating System: Linux | compiling Type of failure: Building GHC | Architecture: x86 failed | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by erikd): * status: new => patch -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9524#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9524: GHC uses wrong linker when cross compiling -------------------------------------+------------------------------------- Reporter: Kritzefitz | Owner: rwbarton Type: bug | Status: patch Priority: normal | Milestone: Component: Build System | Version: 7.8.4 Resolution: | Keywords: Cross Operating System: Linux | compiling Type of failure: Building GHC | Architecture: x86 failed | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by rwbarton): Yep, looks good to me. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9524#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9524: GHC uses wrong linker when cross compiling -------------------------------------+------------------------------------- Reporter: Kritzefitz | Owner: rwbarton Type: bug | Status: merge Priority: normal | Milestone: Component: Build System | Version: 7.8.4 Resolution: | Keywords: Cross Operating System: Linux | compiling Type of failure: Building GHC | Architecture: x86 failed | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by erikd): * status: patch => merge -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9524#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9524: GHC uses wrong linker when cross compiling
-------------------------------------+-------------------------------------
Reporter: Kritzefitz | Owner: rwbarton
Type: bug | Status: merge
Priority: normal | Milestone:
Component: Build System | Version: 7.8.4
Resolution: | Keywords: Cross
Operating System: Linux | compiling
Type of failure: Building GHC | Architecture: x86
failed | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Revisions:
-------------------------------------+-------------------------------------
Comment (by Austin Seipp

#9524: GHC uses wrong linker when cross compiling -------------------------------------+------------------------------------- Reporter: Kritzefitz | Owner: rwbarton Type: bug | Status: closed Priority: normal | Milestone: 7.12.1 Component: Build System | Version: 7.8.4 Resolution: fixed | Keywords: Cross Operating System: Linux | compiling Type of failure: Building GHC | Architecture: x86 failed | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by thoughtpolice): * status: merge => closed * resolution: => fixed * milestone: => 7.12.1 Comment: Merged, thanks Eric! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9524#comment:15 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC