Frontend: Fix -target-variant subarch normalization.

In https://github.com/swiftlang/swift/pull/77156, normalization was introduced
for -target-variant triples. That PR also caused -target-variant arguments to
be inherited from the main compilation options whenever building dependency
modules from their interfaces, which is incorrect. The -target-variant option
must only be specified when compiling a "zippered" module, but the dependencies
of zippered modules are not necessarily zippered themselves and
indiscriminantly propagating the option can cause miscompilation.

The new, more targeted approach to normalizing arm64e triples simply uses the
arch and subarch of the -target argument of the main compile to decide whether
the subarch of both the -target and -target-variant arguments of a dependency
need adjustment.

Resolves rdar://135322077 and rdar://141640919.
This commit is contained in:
Allan Shortlidge
2024-12-20 16:10:16 -08:00
parent 0b6ab9a866
commit 3f0eb8ce2c
10 changed files with 203 additions and 42 deletions

View File

@@ -573,8 +573,7 @@ public:
bool extractCompilerFlagsFromInterface(
StringRef interfacePath, StringRef buffer, llvm::StringSaver &ArgSaver,
SmallVectorImpl<const char *> &SubArgs,
std::optional<llvm::Triple> PreferredTarget = std::nullopt,
std::optional<llvm::Triple> PreferredTargetVariant = std::nullopt);
std::optional<llvm::Triple> PreferredTarget = std::nullopt);
/// Extract the user module version number from an interface file.
llvm::VersionTuple extractUserModuleVersionFromInterface(StringRef moduleInterfacePath);