Skip to content

Commit 5d72984

Browse files
authored
Merge pull request #41669 from grynspan/jgrynspan/SR-15938-imagebase-linkage
[SR-15938] Error when referencing #dsohandle in a Swift test on Windows
2 parents 92a63b9 + 34a4d66 commit 5d72984

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

lib/FrontendTool/TBD.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,27 @@ bool swift::writeTBD(ModuleDecl *M, StringRef OutputFilename,
5656
return false;
5757
}
5858

59+
/// Determine if a symbol name is ignored when validating the TBD's contents
60+
/// against the IR's.
61+
///
62+
/// \param name The name of the symbol in question.
63+
/// \param IRModule The module being validated.
64+
///
65+
/// \returns Whether or not the presence or absence of the symbol named \a name
66+
/// should be ignored (instead of potentially producing a diagnostic.)
67+
static bool isSymbolIgnored(const StringRef& name,
68+
const llvm::Module &IRModule) {
69+
if (llvm::Triple(IRModule.getTargetTriple()).isOSWindows()) {
70+
// (SR-15938) Error when referencing #dsohandle in a Swift test on Windows
71+
// On Windows, ignore the lack of __ImageBase in the TBD file.
72+
if (name == "__ImageBase") {
73+
return true;
74+
}
75+
}
76+
77+
return false;
78+
}
79+
5980
static bool validateSymbols(DiagnosticEngine &diags,
6081
const std::vector<std::string> &symbols,
6182
const llvm::Module &IRModule,
@@ -77,6 +98,11 @@ static bool validateSymbols(DiagnosticEngine &diags,
7798
// with what TBDGen created.
7899
auto unmangledName = nameValue.getKey();
79100

101+
if (isSymbolIgnored(unmangledName, IRModule)) {
102+
// This symbol should not affect validation. Skip it.
103+
continue;
104+
}
105+
80106
SmallString<128> name;
81107
llvm::Mangler::getNameWithPrefix(name, unmangledName,
82108
IRModule.getDataLayout());
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// RUN: %target-run-simple-swift
2+
// REQUIRES: executable_test
3+
4+
// (SR-15938) Error when referencing #dsohandle in a Swift test on Windows
5+
// This file tests that #dsohandle is fully usable from the built test. The
6+
// precise value of #dsohandle is uninteresting.
7+
8+
import StdlibUnittest
9+
10+
var tests = TestSuite("#dsohandle usable")
11+
12+
tests.test("#dsohandle usable") {
13+
expectNotNil(#dsohandle as UnsafeRawPointer?)
14+
}
15+
16+
runAllTests()

validation-test/execution/dsohandle-multi-module.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
// REQUIRES: executable_test
1010

1111
// UNSUPPORTED: linux
12-
// XFAIL: windows
1312

1413
import first
1514
import second

0 commit comments

Comments
 (0)