[GHC] #9895: No -mtriple param being passed to opt/llc when cross compiling

#9895: No -mtriple param being passed to opt/llc when cross compiling -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: feature request | Status: new Priority: normal | Milestone: 7.10.1 Component: Compiler | Version: 7.9 Keywords: | Operating System: Architecture: Unknown/Multiple | Unknown/Multiple Difficulty: Moderate (less | Type of failure: than a day) | None/Unknown Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Currently trying to build an x86_64-linu to arm64-linux cross-compiler. After fixing some code in `rts/StgCRun.c` i ran into an issue where ghc was calling `llc` and generating `x86_64` assembly instead of `aarch64` assembly. For now, I've hacked `compiler/main/SysTools.hs` to add `-mtriple=aarch64 -linux-gnu` to the `opt` and `llc` command lines and that allows me to get a bit further in the compile process. For cross-compiling, passing something like this `-mtriple=...` is pretty much mandatory. I suggest adding it by doing the following: * Add a `crossCompiling :: Bool` field to `DynFlags`. * Add the `-mtriple=...` string to the `sOpt_lo` and `sOpt_lc` fields of `Settings` when we are cross-compiling. * Possibly also store the triple string in the `Platform` struct. Comments? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9895 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9895: No -mtriple param being passed to opt/llc when cross compiling -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: feature | Status: new request | Milestone: 7.10.1 Priority: normal | Version: 7.9 Component: Compiler | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Moderate (less Unknown/Multiple | than a day) Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by erikd): Luite clued me in on the existance of a "settings" file which is read by the function `initSysTools` in the `SysTools` module. Currently the extra options for LLVM's `opt` and `llc` are initialized as: {{{#!hs sOpt_lo = [], sOpt_lc = [], }}} Adding the `-mtriple=...` option here seems the obvious place. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9895#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9895: No -mtriple param being passed to opt/llc when cross compiling -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: feature | Status: new request | Milestone: 7.10.1 Priority: normal | Version: 7.9 Component: Compiler | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Moderate (less Unknown/Multiple | than a day) Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by erikd): Checking the LLVM docs, it seems that `-mtriple=....` is supported at least as far back as LLVM 3.2. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9895#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9895: No -mtriple param being passed to opt/llc when cross compiling -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: feature | Status: patch request | Milestone: 7.10.1 Priority: normal | Version: 7.9 Component: Compiler | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Moderate (less Unknown/Multiple | than a day) Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | Differential Revisions: D576 | -------------------------------------+------------------------------------- Changes (by erikd): * status: new => patch * differential: => D576 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9895#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9895: No -mtriple param being passed to opt/llc when cross compiling -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: feature | Status: patch request | Milestone: 7.10.1 Priority: normal | Version: 7.9 Component: Compiler | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Moderate (less Unknown/Multiple | than a day) Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | Differential Revisions: Phab:D576 | -------------------------------------+------------------------------------- Changes (by rwbarton): * differential: D576 => Phab:D576 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9895#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9895: No -mtriple param being passed to opt/llc when cross compiling
-------------------------------------+-------------------------------------
Reporter: erikd | Owner: erikd
Type: feature | Status: patch
request | Milestone: 7.12.1
Priority: normal | Version: 7.9
Component: Compiler | Keywords:
Resolution: | Architecture: Unknown/Multiple
Operating System: | Difficulty: Moderate (less
Unknown/Multiple | than a day)
Type of failure: | Blocked By:
None/Unknown | Related Tickets:
Test Case: |
Blocking: |
Differential Revisions: Phab:D576 |
-------------------------------------+-------------------------------------
Comment (by Erik de Castro Lopo

#9895: No -mtriple param being passed to opt/llc when cross compiling -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: feature request | Status: closed Priority: normal | Milestone: 7.12.1 Component: Compiler (LLVM) | Version: 7.9 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: GHC doesn't work | Unknown/Multiple at all | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: Phab:D576, | Phab:D585 -------------------------------------+------------------------------------- Changes (by thoughtpolice): * status: patch => closed * failure: None/Unknown => GHC doesn't work at all * differential: Phab:D576 => Phab:D576, Phab:D585 * component: Compiler => Compiler (LLVM) * resolution: => fixed Comment: Closing due to the patch being merged. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9895#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9895: No -mtriple param being passed to opt/llc when cross compiling -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: feature request | Status: merge Priority: normal | Milestone: 7.10.2 Component: Compiler (LLVM) | Version: 7.9 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: GHC doesn't work | Unknown/Multiple at all | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: Phab:D576, | Phab:D585 -------------------------------------+------------------------------------- Changes (by erikd): * status: closed => merge * milestone: 7.12.1 => 7.10.2 Comment: Please merge this patch to `ghc-7.10` branch as it fixes `x86_64/linux` to `armhf/linux` cross compiling. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9895#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9895: No -mtriple param being passed to opt/llc when cross compiling -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: feature request | Status: closed Priority: normal | Milestone: 7.10.2 Component: Compiler (LLVM) | Version: 7.9 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: GHC doesn't work | Unknown/Multiple at all | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: Phab:D576, | Phab:D585 -------------------------------------+------------------------------------- Changes (by thoughtpolice): * status: merge => closed Comment: Merged to `ghc-7.10`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9895#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC