Problems with the planned new cross-compilation model #79657
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
cross-compilation
Area → utils: Cross-compilation of project sources
Description
@compnerd put together a document on a planned new cross-compilation model last summer, which replaces the flags
-sdk
and-resource-dir
with the flags-sdk
and-sysroot
instead. I've since seen some issues with this new model, in order of importance:-sdk
has a bunch of bugs and doesn't work very well. The most common way to ship Swift core modules and runtime libraries is next to the compiler instead and explicitly specifying an external-resource-dir
works reasonably, though bugs have crept in there too. However, explicitly specifying an external-sdk
, particularly a full SDK that contains both a C/C++ sysroot and a Swift resource directory, has historically been the least used configuration and comes with a lot of bugs.For example, I just saw that the Windows CI tries to build the Foundation macros for the Windows host by using a 6.0.3 Windows SDK with the trunk 6.2 Swift compiler. As explained there, that works fine now because the Swift 6.2 compiler likely quietly ignores the 6.0.3 resource directory in that 6.0.3 SDK and uses the 6.2 stdlib modules next to the compiler instead, but when I enforced that it must use the 6.0.3 SDK alone in that pull, the compile failed as expected. We will need to shake out all such
-sdk
leaks before we can rely on this flag for cross-compilation.-sdk
/-resource-dir
flags look directly in those paths for the C sysroot and Swift runtime resources, but when using-sdk
/-sysroot
instead,-sdk
looks in<sdkPath>/usr/lib/swift
instead for the Swift-specific files. I understand why this was done, for backward compatibility of the-sdk
flag, but this means you cannot specify an arbitrary Swift resource path anymore.For example, when building the compiler tools themselves in this repo, you will often see the flags
-sdk / -resource-dir /home/finagolfin/build/Ninja-Release/swift-linux-aarch64/lib/swift/
used to compile against the system C/C++ sysroot and the freshly-built Swift stdlib. How do you replace that with-sdk
/-sysroot
? We'll probably have to add a third hidden flag-sdk-runtime
that works just like-resource-dir
currently does, if we ever want to remove the-resource-dir
flag from building this repo itself.-sysroot
flag is brand new and barely used, I see a couple bugs in its implementation already. This is easiest to remedy since it's new.Regarding 1., since all current approaches use
-sdk
, we have no choice but to make it better. My in-progress work on making it work properly in #79621 is shaking out more bugs, which I will file and fix as I'm able. At the very least, this suggests we might have to go slower with cross-compilation SDKs while these problems are shaken out.@compnerd, let me know your thoughts.
@al45tair, as PSG chair, maybe you have some input.
@etcwilde, you deal with these cross-compilation issues more than most, thoughts welcome.
@MaxDesiatov, the SDK bundles feature you helped create uses the current
-sdk
/-resource-dir
flags a lot, perhaps you have some input.The text was updated successfully, but these errors were encountered: