When specifying a -resource-dir
and an -sdk
, the swift-frontend
still looks in the latter for runtime modules to import
#73445
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
cross-compilation
Area → utils: Cross-compilation of project sources
Frontend
Area → compiler: Frontend
Description
I was testing #72161 and #72634 natively on Android last week, by building those pulls in the Termux app with an older, prebuilt host trunk Swift toolchain installed. Those pulls remove the
Glibc
module on Android, replacing it with a new module calledAndroid
. This would cause build errors when building the SwiftPrivate module in the stdlib:The issue is that when both
-resource-dir
and-sdk
flags are supplied, theswift-frontend
looks in both for the runtime modules to import, so not findingGlibc
in the new build directory passed in as the-resource-dir
, it also looks forGlibc
in the-sdk
, where the prebuilt host toolchain happens to be installed, then errors because that is a different Swift version.I think that if a
-resource-dir
is specified, the compiler should only look in there for runtime modules, not in-sdk
also.This patch does that and fixes the problem for me:
Now that a prebuilt host Swift toolchain is pretty much required to build trunk, and it will often be installed in the same sysroot as the
-sdk
, this problem could hit on any platform, though only likely when moving runtime modules like this. I think this is an edge case worth closing up on all platforms.Reproduction
Something like this may show it on linux too, haven't tried it:
-sdk
path, usually/
.Glibc
module, as shown in the linked Android pulls.Glibc
module instead and fail.Expected behavior
Only look in the
-resource-dir
specified for Swift runtime modulesEnvironment
Building the March 1 trunk snapshot natively on Android 13 AArch64 using a prebuilt February 2 trunk snapshot toolchain
Additional information
This issue probably hasn't been hit before because both paths have the same set of runtime modules most of the time, and the compiler looks in
-resource-dir
first. On Unix, I'm fairly certain it should only look in-resource-dir
, if that flag is specified, but I'm not sure about Darwin and Windows, having never built Swift for those platforms.Pinging @etcwilde and @compnerd, to see what you think of the proposed fix and whether a specified
-resource-dir
should be the only place to look on all platforms.The text was updated successfully, but these errors were encountered: