[GHC] #8127: iOS patch no 19: Linking

#8127: iOS patch no 19: Linking -------------------------------------+------------------------------------- Reporter: StephenBlackheath | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.7 Keywords: | Operating System: Other Architecture: arm | Type of failure: GHC doesn't work Difficulty: Moderate (less | at all than a day) | Test Case: Blocked By: | Blocking: 7724 Related Tickets: | -------------------------------------+------------------------------------- Fix linking for cross compiler to iOS. This patch does these things: 1. use libtool to link to a static library in place of an executable (because on iOS the final link must be done in Xcode), 2. for packages, keep only the HS package libraries and throw out other options (because libtool doesn't accept them), 3. fail if you try to link a dynamic library on iOS because it isn't supported (not really needed but there for completeness). Note that there is a minor risk here, because in the normal case, the order of options passed to the linker is slightly different: The options relating to each dependent package are separated into three different kinds, but they're still in the same relative order per package. This should be perfectly OK. The name of "libtool" is hard-coded and can't be set by options. Is this OK? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8127 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8127: iOS patch no 19: Linking -------------------------------------+------------------------------------- Reporter: | Owner: StephenBlackheath | Status: patch Type: bug | Milestone: Priority: normal | Version: 7.7 Component: Compiler | Keywords: Resolution: | Architecture: arm Operating System: Other | Difficulty: Moderate (less Type of failure: GHC doesn't work | than a day) at all | Blocked By: Test Case: | Related Tickets: Blocking: 7724 | -------------------------------------+------------------------------------- Changes (by StephenBlackheath): * status: new => patch -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8127#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8127: iOS patch no 19: Linking -------------------------------------+------------------------------------- Reporter: | Owner: StephenBlackheath | Status: patch Type: bug | Milestone: Priority: normal | Version: 7.7 Component: Compiler | Keywords: Resolution: | Architecture: arm Operating System: Other | Difficulty: Moderate (less Type of failure: GHC doesn't work | than a day) at all | Blocked By: Test Case: | Related Tickets: Blocking: 7724 | -------------------------------------+------------------------------------- Comment (by maxs): This patch adds an option to link everything into a static archive on Mac. I.e. {{{ ghc -staticlib Foo.hs # -> liba.a }}} You can then link liba.a with with some C object files with gcc. Since GHC iOS requires this, it will always use this. It uses Mac's libtool and will require changes to work on Linux and Windows. (I think Windows users would prefer the DLL option instead anyway) Libtool will also emit a lot of warnings, I think this is because libtool doesn't understand the contents of the haskell archives. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8127#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8127: iOS patch no 19: Linking -------------------------------------+------------------------------------- Reporter: | Owner: StephenBlackheath | Status: patch Type: bug | Milestone: Priority: normal | Version: 7.7 Component: Compiler | Keywords: Resolution: | Architecture: arm Operating System: Other | Difficulty: Moderate (less Type of failure: GHC doesn't work | than a day) at all | Blocked By: Test Case: | Related Tickets: Blocking: 7724 | -------------------------------------+------------------------------------- Comment (by maxs): This patch still needs the --help and man page for -staticlib implemented and documented. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8127#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8127: iOS patch no 19: Linking -------------------------------------+------------------------------------- Reporter: | Owner: StephenBlackheath | Status: patch Type: bug | Milestone: Priority: normal | Version: 7.7 Component: Compiler | Keywords: Resolution: | Architecture: arm Operating System: Other | Difficulty: Moderate (less Type of failure: GHC doesn't work | than a day) at all | Blocked By: Test Case: | Related Tickets: Blocking: 7724 | -------------------------------------+------------------------------------- Comment (by thoughtpolice): LGTM for the most part. A few notes: * Does `-staticlib` make sense on other systems? Could I also, for example create a `.a` on Linux and link it into something there with a foreign build system. If so, it should be clear. If not, I'd at least like a defensive warning that `-staticlib` is only supported when the OS is `OSiOS`. * On that note, I'd prefer it if 'libtool' was overrideable, since we may not be sure what libtool someone is exactly using, and breaking this convention seems awkward. I'm not very picky on a flag name, but 'libtool' is certinly a fine default (and requires no more effort for iOS.) * If it's actually possible to do this, can we see some tests? The build system should support you creating an '.a' file and linking it, but if this is too complicated please say so. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8127#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8127: iOS patch no 19: Linking -------------------------------------+------------------------------------- Reporter: | Owner: StephenBlackheath | Status: patch Type: bug | Milestone: Priority: normal | Version: 7.7 Component: Compiler | Keywords: Resolution: | Architecture: arm Operating System: Other | Difficulty: Moderate (less Type of failure: GHC doesn't work | than a day) at all | Blocked By: Test Case: | Related Tickets: Blocking: 7724 | -------------------------------------+------------------------------------- Comment (by maxs): I'm not sure how to add this as a test. Do you know an example test somewhere that builds and checks output? I have a script I have used for testing: https://gist.github.com/maxpow4h/5363900 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8127#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8127: iOS patch no 19: Linking
-------------------------------------+-------------------------------------
Reporter: | Owner:
StephenBlackheath | Status: patch
Type: bug | Milestone:
Priority: normal | Version: 7.7
Component: Compiler | Keywords:
Resolution: | Architecture: arm
Operating System: Other | Difficulty: Moderate (less
Type of failure: GHC doesn't work | than a day)
at all | Blocked By:
Test Case: | Related Tickets:
Blocking: 7724 |
-------------------------------------+-------------------------------------
Comment (by Austin Seipp

#8127: iOS patch no 19: Linking -------------------------------------+------------------------------------- Reporter: | Owner: StephenBlackheath | Status: patch Type: bug | Milestone: Priority: normal | Version: 7.7 Component: Compiler | Keywords: Resolution: | Architecture: arm Operating System: Other | Difficulty: Moderate (less Type of failure: GHC doesn't work | than a day) at all | Blocked By: Test Case: | Related Tickets: Blocking: 7724 | -------------------------------------+------------------------------------- Comment (by thoughtpolice): Merged, thanks. Luke, earlier on IRC you said you had a test of some sort. If you could post it here, that's be great so I can finally close it. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8127#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8127: iOS patch no 19: Linking -------------------------------------+------------------------------------- Reporter: | Owner: StephenBlackheath | Status: patch Type: bug | Milestone: Priority: normal | Version: 7.7 Component: Compiler | Keywords: Resolution: | Architecture: arm Operating System: Other | Difficulty: Moderate (less Type of failure: GHC doesn't work | than a day) at all | Blocked By: Test Case: | Related Tickets: Blocking: 7724 | -------------------------------------+------------------------------------- Comment (by StephenBlackheath): This is indeed the last piece of the iOS cross compiler, announcement at http://www.reddit.com/r/haskell/comments/1lboh4/announcing_ghc_ios/ Thanks very much for your work Austin, Ian & Simon M! I have not forgotten that I promised to review #7723. I will do that soon. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8127#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8127: iOS patch no 19: Linking -------------------------------------+------------------------------------- Reporter: | Owner: StephenBlackheath | Status: patch Type: bug | Milestone: Priority: normal | Version: 7.7 Component: Compiler | Keywords: Resolution: | Architecture: arm Operating System: Other | Difficulty: Moderate (less Type of failure: GHC doesn't work | than a day) at all | Blocked By: Test Case: | Related Tickets: Blocking: 7724 | -------------------------------------+------------------------------------- Comment (by lukexi): Hi Austin — here's a fixed up copy of Max's patch. I just tested it and it seems to work happily; let me know if it looks ok! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8127#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8127: iOS patch no 19: Linking
-------------------------------------+-------------------------------------
Reporter: | Owner:
StephenBlackheath | Status: closed
Type: bug | Milestone:
Priority: normal | Version: 7.7
Component: Compiler | Keywords:
Resolution: fixed | Architecture: arm
Operating System: Other | Difficulty: Moderate (less
Type of failure: GHC doesn't work | than a day)
at all | Blocked By:
Test Case: | Related Tickets:
Blocking: 7724 |
-------------------------------------+-------------------------------------
Changes (by thoughtpolice):
* status: patch => closed
* resolution: => fixed
Comment:
Merged, thanks!
{{{
commit 629f393175b3800e714671b3e4a07b25d2a8edf3
Author: Luke Iannini

#8127: iOS patch no 19: Linking
--------------------------------------------+-----------------------
Reporter: StephenBlackheath | Owner:
Type: bug | Status: closed
Priority: normal | Milestone:
Component: Compiler | Version: 7.7
Resolution: fixed | Keywords:
Operating System: Other | Architecture: arm
Type of failure: GHC doesn't work at all | Test Case:
Blocked By: | Blocking: 7724
Related Tickets: |
--------------------------------------------+-----------------------
Comment (by Thomas Miedema

#8127: iOS patch no 19: Linking -------------------------------------+------------------------------------- Reporter: | Owner: StephenBlackheath | Status: new Type: bug | Milestone: Priority: normal | Version: 7.7 Component: Compiler | Keywords: Resolution: | Architecture: arm Operating System: MacOS X | Test Case: Type of failure: GHC doesn't work | Blocking: 7724 at all | Differential Revisions: Blocked By: | Related Tickets: | -------------------------------------+------------------------------------- Changes (by thomie): * status: closed => new * resolution: fixed => * os: Other => MacOS X Comment: Reopening this ticket so that we don't forget to fix the test. In commit cd3e3455d4c5307ab4f089209181d7c8e457173d: {{{ Author: Austin Seipp <> Date: Mon Jan 13 08:40:28 2014 -0600 Mark static001 as failing Right now the stderr output doesn't match because we don't suppress some libtool errors, but these seem to be benign... }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8127#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8127: iOS patch no 19: Linking -------------------------------------+------------------------------------- Reporter: | Owner: StephenBlackheath | Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.7 (Linking) | Resolution: | Keywords: Operating System: MacOS X | Architecture: arm Type of failure: GHC doesn't work | Test Case: at all | Blocked By: | Blocking: 7724 Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by ezyang): * component: Compiler => Compiler (Linking) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8127#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8127: iOS patch no 19: Linking -------------------------------------+------------------------------------- Reporter: | Owner: StephenBlackheath | Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.7 (Linking) | Resolution: | Keywords: easy Operating System: MacOS X | Architecture: arm Type of failure: GHC doesn't work | Test Case: at all | Blocked By: | Blocking: 7724 Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by ezyang): * keywords: => easy -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8127#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC