Added '-Blinker' frontend driver option for cross-linker search path#2483
Added '-Blinker' frontend driver option for cross-linker search path#2483karwa wants to merge 1 commit intoswiftlang:masterfrom
Conversation
to be specified. This means swift can now cross-compile executables for linux.
|
Thanks for looking at this! That's not a very Swifty flag name though (we don't really do the prefix thing), and I'm leery of adding Linux-only options. How is this flag used, i.e. what is |
|
I think we should actually design the proper cross-toolchain solution as a real feature. That said, I don't think it is reasonable to block all progress on getting ports going on tackling such a large design topic. In the meantime, how about we carve out a namespace for "experimental" command line options and put them under that? @jrose-apple what do you think about that? |
|
${gcc-toolchain-path} is the directory where ld.gold is (or whichever linker); It's the directory and not the exact path, because of the way it gets forwarded to clang. I liked the name blinker, it's strange yet appropriate; we have -I and -L and -use-ld (with the equals and everything), Xlinker and so on, so I went for familiarity. I'm all for renaming, though; sticking this feature behind the "-B" flag isn't obvious, even for clang/gcc. As for sticking it in an 'experimental' scope; this flag is basically the counterpart to I would support renaming both options, |
|
Alternative: -use-ld actually takes a full path in recent Clangs, doesn't it? I'm not sure we've pulled that change into apple/swift-clang's "stable" branch yet, but that would be good enough to make progress, right? |
|
Yes, I didn't know that, but you're right: http://reviews.llvm.org/rL262996 We haven't pulled that in, but it would be great if we did. I'd also want to rename -use-ld, because it is a bit legacy, but that's less important than having the functionality there. |
|
It's already in the |
|
This is no longer needed, absolute paths in clang is now in |
What's in this pull request?
Added a -Blinker fronted driver option. This works like clang/gcc's "-B" flag (which allows specifying an alternate toolchain location).
Currently, you can cross-compile with swift (assuming you've got a copy of the standard library compiled for the target), like so:
swiftc -target armv7-unknown-linux-gnueabihf -sdk ${sysroot} -resource-dir ${sdk-location} main.swiftHowever, this only works for modules (swiftmodules), not for executables. The host swift generates a link command to clang++ with
-fuse-ld=gold, as it should, but there is currently no way to tell it where to find the gold cross-linker. Normally, you would put this information behind the '-B' switch, so we provide the same kind of functionality here.Adding
-Blinker ${gcc-toolchain-path}to the above command allows swift to cross-compile executables.Before merging this pull request to apple/swift repository:
Triggering Swift CI
The swift-ci is triggered by writing a comment on this PR addressed to the GitHub user @swift-ci. Different tests will run depending on the specific comment that you use. The currently available comments are:
Smoke Testing
Validation Testing
Note: Only members of the Apple organization can trigger swift-ci.