Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Driver: look for the runtime object in the SDK #25990

Merged
merged 1 commit into from
Jul 25, 2019

Conversation

compnerd
Copy link
Member

@compnerd compnerd commented Jul 7, 2019

The runtime object is for the host, and is part of the SDK. If -sdk
is passed, look for the runtime support object relative to the SDK root.

Replace this paragraph with a description of your changes and rationale. Provide links to external references/discussions if appropriate.

Resolves SR-NNNN.

@compnerd
Copy link
Member Author

compnerd commented Jul 7, 2019

@swift-ci please test and merge

@compnerd compnerd force-pushed the one-sdk-to-rule-them-all branch from 0c37015 to 945917c Compare July 7, 2019 18:06
@compnerd
Copy link
Member Author

compnerd commented Jul 8, 2019

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Jul 8, 2019

Build failed
Swift Test Linux Platform
Git Sha - 945917ce4ca3011fa40505a93ffcf995687dcbb1

@jrose-apple
Copy link
Contributor

jrose-apple commented Jul 8, 2019

I think you mean "target", not "host". (This looks fine to me.)

@jrose-apple
Copy link
Contributor

…although in the future I don't know if we really want to assume "using a non-Darwin SDK" = "cross-compiling".

@compnerd
Copy link
Member Author

compnerd commented Jul 8, 2019

"target" is the wrong term, "host" is what the binary will run on. "target" is only used when cross-compiling a non-cross-compiling compiler. This is the de-facto terminology used across most Unices: https://www.gnu.org/software/automake/manual/html_node/Cross_002dCompilation.html

Your second point cannot be over-stressed. This is purely intended as a temporary workaround. The problem is that the change to look for the libraries in the SDK was reverted and I am just waiting on that to go back in as that would allow us to drop that invalid condition. I didn't want to break the Darwin target, but I agree that it is incorrect.

@compnerd
Copy link
Member Author

compnerd commented Jul 8, 2019

CC: @brentdax - you may also care about this since you are doing something related to this on the Darwin side. LMK if we can co-ordinate somehow on this.

@jrose-apple
Copy link
Contributor

"Target" is the right term because "target" is the compiler flag (and terminology), and since all three of "build", "host", and "target" are in play for a compiler.

@compnerd
Copy link
Member Author

compnerd commented Jul 8, 2019

target is the flag, though the value of the flag is host as that is what the generated builds run on. Quoting from the reference:

--host=host
        The system where built programs and libraries will run.

@jrose-apple
Copy link
Contributor

--target=target
    When building compiler tools: the system for which the tools will create output.

@compnerd
Copy link
Member Author

compnerd commented Jul 8, 2019

Correct, when building compiler tools. In fact, even when building the compiler, host/build are the correct term. The "target" is there fore the case that you are cross-compiling a non-cross-compiling compiler. That is, you are building clang on x86_64 for ARM64 which will only build binaries for ARMv7. In such a case, the build is x86_64, the host is aarch64, and the target is armv7. In general, when you are compiling any standard package, the terms are build/host.

@compnerd compnerd force-pushed the one-sdk-to-rule-them-all branch from 945917c to f1df50a Compare July 9, 2019 21:55
The runtime object is for the host, and is part of the SDK.  If `-sdk`
is passed, look for the runtime support object relative to the SDK root.
@compnerd compnerd force-pushed the one-sdk-to-rule-them-all branch from f1df50a to e96e7cc Compare July 9, 2019 21:56
@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 945917ce4ca3011fa40505a93ffcf995687dcbb1

@compnerd
Copy link
Member Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 945917ce4ca3011fa40505a93ffcf995687dcbb1

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - e96e7cc

@compnerd
Copy link
Member Author

@swift-ci please test Linux platform

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - e96e7cc

@compnerd
Copy link
Member Author

Please test with following PRs:
apple/swift-lldb#1829

@swift-ci please test Linux platform

@compnerd
Copy link
Member Author

I'm going to merge this for now. I really want to iterate on this a bit more, the !Darwin bit of that check really doesn't sit well with me.

@compnerd compnerd merged commit f82572a into swiftlang:master Jul 25, 2019
@compnerd compnerd deleted the one-sdk-to-rule-them-all branch July 25, 2019 22:32
@vgorloff
Copy link
Contributor

vgorloff commented Aug 14, 2019

Hello,

When making Cross Compilation for Android on macOS Host I have to provide -sdk flag (-sdk /usr/local/ndk/platforms/android-24/arch-arm).

Without -sdk flag there will be following compile error:

/usr/local/ndk/toolchains/llvm/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld.gold: error: cannot open crtbegin_dynamic.o: No such file or directory
/usr/local/ndk/toolchains/llvm/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld.gold: error: cannot open crtend_android.o: No such file or directory

But With -sdk flag (-sdk /usr/local/ndk/platforms/android-24/arch-arm) I am getting another error:

clang: error: no such file or directory: '/usr/local/ndk/platforms/android-24/arch-arm/usr/lib/swift/android/armv7/swiftrt.o'

In this case path to swiftrt.o incorrect: /usr/local/ndk/platforms/android-24/arch-arm/usr/lib/swift/android/armv7/swiftrt.o

Now I am thinking how to solve this error :)

Is -sdk flag can't point anywhere except Swift SDK (which include file swiftrt.o)?

Thank you!

Swift-NoFailures.txt
Swift-WithFailures.txt
Swift-WithoutSDKFlag.txt

@drodriguez
Copy link
Contributor

@vgorloff there's a lot of discussion about what -sdk should mean and should do in the forums thread https://forums.swift.org/t/swift-linux-layout-considerations-aka-linux-is-difficult-lets-go-shopping/27400/2. IIRC, as things are right now, for Android, one might need to pass -sdk pointing to the Swift SDK, and some combination of -Xclang-linker -sysroot -Xclang-linker /foo/bar and -Xcc ... to point to the Android NDK. Look in #26366 for the changes needed for the test suite to run. It might give you a clue.

@vgorloff
Copy link
Contributor

Thank you!

Usage of the flags -Xclang-linker and -Xcc helped to solve issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants