mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Merge pull request #81697 from bnbarham/use-toolchain-version
Add the distribution tag to `-print-target-info`
This commit is contained in:
@@ -336,6 +336,8 @@ set(SWIFT_COMPILER_VERSION "" CACHE STRING
|
||||
"The internal version of the Swift compiler")
|
||||
set(CLANG_COMPILER_VERSION "" CACHE STRING
|
||||
"The internal version of the Clang compiler")
|
||||
set(SWIFT_TOOLCHAIN_VERSION "" CACHE STRING
|
||||
"The Swift compiler tag")
|
||||
|
||||
option(SWIFT_DISABLE_DEAD_STRIPPING
|
||||
"Turn off Darwin-specific dead stripping for Swift host tools." FALSE)
|
||||
|
||||
@@ -171,11 +171,6 @@ std::string getSwiftFullVersion(Version effectiveLanguageVersion =
|
||||
/// this Swift was built.
|
||||
StringRef getSwiftRevision();
|
||||
|
||||
/// Is the running compiler built with a version tag for distribution?
|
||||
/// When true, \c version::getCurrentCompilerVersion returns a valid version
|
||||
/// and \c getCurrentCompilerTag returns the version tuple in string format.
|
||||
bool isCurrentCompilerTagged();
|
||||
|
||||
/// Retrieves the distribution tag of the running compiler, if any.
|
||||
StringRef getCurrentCompilerTag();
|
||||
|
||||
|
||||
@@ -134,10 +134,8 @@ if(NOT "${SWIFT_VENDOR}" STREQUAL "")
|
||||
" -DSWIFT_VENDOR=\"\\\"${SWIFT_VENDOR}\\\"\"")
|
||||
endif()
|
||||
|
||||
set(SWIFT_COMPILER_VERSION "" CACHE STRING
|
||||
"The string that identifies the SCM commit(s) for this build")
|
||||
|
||||
message(STATUS "Swift compiler version: ${SWIFT_COMPILER_VERSION}")
|
||||
message(STATUS "Swift toolchain version: ${SWIFT_TOOLCHAIN_VERSION}")
|
||||
message(STATUS "Embedded clang compiler version: ${CLANG_COMPILER_VERSION}")
|
||||
|
||||
if(SWIFT_COMPILER_VERSION)
|
||||
@@ -150,3 +148,7 @@ if(CLANG_COMPILER_VERSION)
|
||||
" -DCLANG_COMPILER_VERSION=\"\\\"${CLANG_COMPILER_VERSION}\\\"\"")
|
||||
endif()
|
||||
|
||||
if(SWIFT_TOOLCHAIN_VERSION)
|
||||
set_property(SOURCE Version.cpp APPEND_STRING PROPERTY COMPILE_FLAGS
|
||||
" -DSWIFT_TOOLCHAIN_VERSION=\"\\\"${SWIFT_TOOLCHAIN_VERSION}\\\"\"")
|
||||
endif()
|
||||
|
||||
@@ -65,6 +65,14 @@ void printTargetInfo(const CompilerInvocation &invocation,
|
||||
writeEscaped(version::getSwiftFullVersion(version::Version::getCurrentLanguageVersion()), out);
|
||||
out << "\",\n";
|
||||
|
||||
// Distribution tag, if any.
|
||||
StringRef tag = version::getCurrentCompilerTag();
|
||||
if (!tag.empty()) {
|
||||
out << " \"swiftCompilerTag\": \"";
|
||||
writeEscaped(tag, out);
|
||||
out << "\",\n";
|
||||
}
|
||||
|
||||
// Target triple and target variant triple.
|
||||
auto runtimeVersion =
|
||||
invocation.getIRGenOptions().AutolinkRuntimeCompatibilityLibraryVersion;
|
||||
|
||||
@@ -304,17 +304,9 @@ StringRef getSwiftRevision() {
|
||||
#endif
|
||||
}
|
||||
|
||||
bool isCurrentCompilerTagged() {
|
||||
#ifdef SWIFT_COMPILER_VERSION
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
StringRef getCurrentCompilerTag() {
|
||||
#ifdef SWIFT_COMPILER_VERSION
|
||||
return SWIFT_COMPILER_VERSION;
|
||||
#ifdef SWIFT_TOOLCHAIN_VERSION
|
||||
return SWIFT_TOOLCHAIN_VERSION;
|
||||
#else
|
||||
return StringRef();
|
||||
#endif
|
||||
|
||||
@@ -932,7 +932,7 @@ class ModuleInterfaceLoaderImpl {
|
||||
return std::make_error_code(std::errc::not_supported);
|
||||
} else if (isInResourceDir(adjacentMod) &&
|
||||
loadMode == ModuleLoadingMode::PreferSerialized &&
|
||||
!version::isCurrentCompilerTagged() &&
|
||||
version::getCurrentCompilerSerializationTag().empty() &&
|
||||
rebuildInfo.getOrInsertCandidateModule(adjacentMod)
|
||||
.serializationStatus !=
|
||||
serialization::Status::SDKMismatch &&
|
||||
|
||||
@@ -392,7 +392,7 @@ static ValidationInfo validateControlBlock(
|
||||
// env var is set (for testing).
|
||||
static const char* forceDebugPreSDKRestriction =
|
||||
::getenv("SWIFT_DEBUG_FORCE_SWIFTMODULE_PER_SDK");
|
||||
if (!version::isCurrentCompilerTagged() &&
|
||||
if (version::getCurrentCompilerSerializationTag().empty() &&
|
||||
!forceDebugPreSDKRestriction) {
|
||||
break;
|
||||
}
|
||||
@@ -433,10 +433,12 @@ static ValidationInfo validateControlBlock(
|
||||
::getenv("SWIFT_DEBUG_FORCE_SWIFTMODULE_REVISION");
|
||||
|
||||
StringRef moduleRevision = blobData;
|
||||
StringRef serializationTag =
|
||||
version::getCurrentCompilerSerializationTag();
|
||||
if (forcedDebugRevision ||
|
||||
(requiresRevisionMatch && version::isCurrentCompilerTagged())) {
|
||||
StringRef compilerRevision = forcedDebugRevision ?
|
||||
forcedDebugRevision : version::getCurrentCompilerSerializationTag();
|
||||
(requiresRevisionMatch && !serializationTag.empty())) {
|
||||
StringRef compilerRevision =
|
||||
forcedDebugRevision ? forcedDebugRevision : serializationTag;
|
||||
if (moduleRevision != compilerRevision) {
|
||||
// The module versions are mismatching, record it and diagnose later.
|
||||
result.problematicRevision = moduleRevision;
|
||||
|
||||
Reference in New Issue
Block a user