Ticket #7720 (closed feature request: fixed)

Opened 3 months ago

Last modified 3 weeks ago

iOS patch no 9: Linking

Reported by: StephenBlackheath Owned by:
Priority: normal Milestone: 7.8.1
Component: Compiler Version: 7.7
Keywords: Cc:
Operating System: Other Architecture: arm
Type of failure: None/Unknown Difficulty: Unknown
Test Case: Blocked By:
Blocking: #7724 Related Tickets:

Description

These are all the changes necessary to make the iOS cross compiler link in the right way for iOS.

Attachments

ios-patch-9a-linking.patch Download (8.0 KB) - added by StephenBlackheath 3 months ago.
iOS patch 9 rev a: Linking
ios-patch-9b-linking.patch Download (4.5 KB) - added by igloo 4 weeks ago.

Change History

Changed 3 months ago by StephenBlackheath

iOS patch 9 rev a: Linking

Changed 3 months ago by StephenBlackheath

  • status changed from new to patch

Changed 3 months ago by StephenBlackheath

  • blocking 7724 added

Changed 3 months ago by ian@…

commit ff1de4cf60be4defda1945eb1dea55d056895c64

Author: Ian Lynagh <ian@well-typed.com>
Date:   Sat Mar 2 13:57:10 2013 +0000

    Add OSiOS, and define and use platformUsesFrameworks; part of #7720

 compiler/ghci/Linker.lhs        |   31 +++++++++---------
 compiler/main/DriverPipeline.hs |   65 +++++++++++++++++----------------------
 compiler/utils/Platform.hs      |   13 +++++++-
 3 files changed, 55 insertions(+), 54 deletions(-)

Changed 3 months ago by igloo

  • difficulty set to Unknown

I've applied the frameworks parts of this patch.

I'm a little confused by the rest, though. Does compiling a program on iOS result in a .a file? Does the user then have to manually do something else with that?

Changed 3 months ago by StephenBlackheath

That's correct. Xcode wants to generate the executable itself, packaged up with resources (graphics, etc) and then signed. What we do is have ghc generate a .a file which we then manually link into an Xcode project.

Changed 6 weeks ago by igloo

  • milestone set to 7.8.1

Changed 4 weeks ago by igloo

Changed 4 weeks ago by igloo

9b is the remainder of the patch

Changed 4 weeks ago by igloo

This bit is a rather unpleasant kludge, and will presumably fail with packages that use other libraries:

opt `notElem` ["-ldl", "-liconv", "-lm", "-lpthread"]

In main/DriverPipeline.hs, linkBinary does

pkg_link_opts <- getPackageLinkOpts dflags dep_packages

which ultimately gives us

map ("-l" ++) (packageHsLibs dflags p ++ extraLibraries p) ++ ldOptions p

If you instead use [], instead of calling getPackageLinkOpts, on iOS, then does that work?

Changed 4 weeks ago by StephenBlackheath

igloo: Yes, it is an unpleasant kludge. getPackageLinkOpts could be modified to give [], and I think that would be very likely to work (currently it gives some -l options, which doesn't make any sense, since none of them will work.) So I think your idea is a much better one than mine.

So, are you prepared to do that? I'll re-test it and see if any -l's are creeping in from other places. If you want me to prepare a patch for this, let me know.

Changed 3 weeks ago by ian@…

commit e5944d9f04bc6f6e62367be71d5b76e7d0473ee2

Author: Ian Lynagh <ian@well-typed.com>
Date:   Sat Apr 27 12:45:04 2013 +0100

    Don't use getPackageLinkOpts on iOS; fixes #7720.
    
    On iOS, binaries are really static libraries, so we don't want to use
    flags like -lm when linking them.

 compiler/main/DriverPipeline.hs |    8 +++++++-
 compiler/utils/Platform.hs      |    8 ++++++++
 2 files changed, 15 insertions(+), 1 deletions(-)

Changed 3 weeks ago by igloo

  • status changed from patch to closed
  • resolution set to fixed

OK, done. Let me know if you still have problems.

Changed 3 weeks ago by StephenBlackheath

Thanks - I'll re-test.

Note: See TracTickets for help on using tickets.