-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Fix multi-arch cross-compiling #13108
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
Conversation
@@ -327,7 +327,7 @@ function(_add_variant_link_flags) | |||
${ARGN}) | |||
|
|||
precondition(LFLAGS_SDK MESSAGE "Should specify an SDK") | |||
precondition(LFLAGS_SDK MESSAGE "Should specify an architecture") | |||
precondition(LFLAGS_ARCH MESSAGE "Should specify an architecture") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed an unrelated copy/paste bug with this arg.
cmake/modules/AddSwift.cmake
Outdated
"${SWIFT_NATIVE_SWIFT_TOOLS_PATH}/../lib/swift/${SWIFTLIB_SINGLE_SUBDIR}" | ||
"${SWIFT_NATIVE_SWIFT_TOOLS_PATH}/../lib/swift/${SWIFTLIB_SINGLE_SUBDIR}") | ||
|
||
if("${SWIFT_SDK_${SWIFTLIB_SINGLE_SDK}_OBJECT_FORMAT}" STREQUAL "ELF") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if I should gate on elf or gate on mach. @compnerd windows?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PE/COFF doesn't have fat binaries either. I think that we should make this a Mach check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 1650 and 1743 use an IS_DARWIN
check instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I can switch to that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Driver parts look okay to me. I'll let Ross and others comment on the CMake.
lib/Driver/ToolChains.cpp
Outdated
@@ -1016,6 +1016,17 @@ static void getRuntimeLibraryPath(SmallVectorImpl<char> &runtimeLibPath, | |||
getPlatformNameForTriple(TC.getTriple())); | |||
} | |||
|
|||
/// On Darwin we link fat libs in the root of the library path and on other OS | |||
/// targets we look up libraries in the target arch's subfolder. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: This comment doesn't really describe the function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah true. What I was thinking when I changed where we used it and not what the function does.
cmake/modules/AddSwift.cmake
Outdated
# Note this thin library. | ||
list(APPEND THIN_INPUT_TARGETS ${VARIANT_NAME}) | ||
if (SWIFTLIB_IS_STDLIB AND SWIFTLIB_STATIC) | ||
# Add dependencies on the (not-yet-created) custom lipo target. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment can't be right. This is inside the non-Darwin no-lipo case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah good catch. Copy-pasta.
I will try to take a closer look at this soon. But, we should try to get this patch taken care of soon. There is at least one patch from me (#12480) and one from @troughton (#13140) which is trying to address the problems caused by the fat vs thin binary handling in the build. |
@compnerd Yeah, I see what you are doing in that other patch. I'll try to fix this one up really quick. |
Fixed issues. can someone kick off the CI bot for me? I can't test locally this weekend. |
@swift-ci please test |
Build failed |
Build failed |
@swift-ci please test |
Build failed |
Build failed |
@swift-ci please test |
Build failed |
Build failed |
not sure how to invoke @swift-ci so it compiles this PR with foundation using this PR together swiftlang/swift-corelibs-foundation#1354 |
please test with the following pull request: @swift-ci please test |
Build failed |
Build failed |
doh. dependency in unit tests was broken. fixed |
please test with the following pull request: @swift-ci please test |
Build failed |
Build failed |
Funny linker error in foundation:
Curious why this worked on a previous build. Demangle says it's: Swift._AnyCollectionBox._index(Swift._AnyIndexBox, offsetBy: Swift.Int64) -> Swift._AnyIndexBox I'm wondering if this is supposed to get generated by libswiftSwiftOnoneSupport.so and it's not picking it up now. |
updated this branch to current master. I'm wondering if this is just the branch foundation is on is out of sync with this one. should be ok to test again. |
please test with the following pull request: @swift-ci please test |
Build failed |
@@ -1016,6 +1016,17 @@ static void getRuntimeLibraryPath(SmallVectorImpl<char> &runtimeLibPath, | |||
getPlatformNameForTriple(TC.getTriple())); | |||
} | |||
|
|||
/// Get the runtime library link path with the target triple's specific arch | |||
/// library folder. | |||
static void getRuntimeLibraryPathWithArch(SmallVectorImpl<char> &runtimeLibPath, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you call this getRuntimeSharedLibraryPathWithArch
to match getRuntimeStaticLibraryPathWithArch
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the non "WithArch" variant above this one calls doesn't use the "Shared" prefix. I could rename everything but it seemed more invasive.
// directory for searching for binaries. This is the same as the import | ||
// path for modules. | ||
SearchPathOpts.RuntimeLibraryPath = LibPath.str(); | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not sink the LibPath calculation into the Triple.isOSDarwin()
or else
case respectively?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. I'll look at writing this be more clear with one branch instead of two. I was over optimizing trying to avoid creating two string allocs for the non-Darwin path at the sake of some clarity.
Basically:
if Darwin:
RuntimeLibraryPath = /lib/swift/(platform)
else:
RuntimeLibraryPath = /lib/swift/(platform)/(arch)
RuntimeLibraryImportPath = /lib/swift/(platform)/(arch)
Please test with the following pull request: @swift-ci please test |
Build failed |
Build failed |
I think one of the tests failed because it's not cleaning. A previous version created a symlink in an unfortunate spot that will confuse the "RUN: ln -s" statements in the test. The other test I'm not sure why it fails. It's not failing that way locally on my Ubuntu 14.04 machine. |
// RUN: ln -s %t/libabc.so %t/rsrc/%target-sdk-name/%target-cpu | ||
// RUN: ln -s %platform-module-dir/../* %t/rsrc/%target-sdk-name/%target-cpu | ||
// RUN: ln -s %platform-module-dir/../%target_cpu/* %t/rsrc/%target-sdk-name/%target-cpu |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doh. %target-cpu and not %target_cpu
Seems like a regression to something discussed in #282 |
On platforms without fat binaries (anything but Darwin), we now build and install stdlibs for each arch in it's own folder. Namely lib/swift/<platform>/<arch> instead of lib/swift/<platform>.
squashed and rebased this branch so I can update my fuchsia branch based on these commits |
Please test with the following pull request: @swift-ci please test |
Build failed |
Please test with the following pull request: @swift-ci please smoke test linux |
I'm not sure what this test is doing that is failing on the linux bot. The module maps generated are working on debain machines I've tested just fine but the test fails. |
@swift-ci please test |
Drive-by log restoration. Don’t mind me |
Please test with the following pull request: @swift-ci please smoke test Linux platform |
Do we want to split this up and get in part of the patch earlier? The build portion would be extremely useful for me as it allows me to build just part of the windows targets (e.g. just the x86_64 or ARM target). |
@compnerd it's very intertwined and already split up a lot so far. going to try and investigate this last test that is failing. it's some kind of intermediate thing testing some kind of module metadata that I don't really understand or something but the final product seems to working fine on all archs so it's weird. |
@swift-ci please test linux |
Build failed |
I have some changes to swiftpm, libdispatch, and xctest (in additional to the current foundation change already) that go along with this change to teach them about the linux arch folder. Still not sure what is broken this unit test though. |
Closing this due to age and inactivity, both here and on the corresponding Foundation PR. |
On platforms without fat binaries (anything but Darwin), we now build
and install stdlibs for each arch in it's own folder. Namely
lib/swift/<platform>/<arch> instead of lib/swift/<platform>.
(Split from #12955)