Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions stdlib/public/Platform/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ add_swift_target_library(swiftCRT ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_OVE
${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}
${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS}
-Xcc -D_USE_MATH_DEFINES
-Xfrontend -disable-force-load-symbols
${swift_platform_compile_flags}
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
TARGET_SDKS WINDOWS
Expand Down
1 change: 1 addition & 0 deletions stdlib/public/Windows/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ add_swift_target_library(swiftWinSDK ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_
WinSDK.swift

SWIFT_COMPILE_FLAGS ${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS} ${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS}
-Xfrontend -disable-force-load-symbols
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
TARGET_SDKS WINDOWS
INSTALL_IN_COMPONENT sdk-overlay)
Expand Down
55 changes: 55 additions & 0 deletions utils/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3328,6 +3328,7 @@ function Test-Compilers([Hashtable] $Platform, [string] $Variant, [switch] $Test
# No watchpoint support on windows: https://github.com/llvm/llvm-project/issues/24820
LLDB_TEST_USER_ARGS = "--skip-category=watchpoint;--sysroot=$SwiftSDK";
LLDB_TEST_SWIFT_DRIVER_EXTRA_FLAGS = "-sdk '$SwiftSDK'"
LLDB_TEST_INFERIOR_RUNTIME_BIN = "$SwiftRuntime";
# gtest sharding breaks llvm-lit's --xfail and LIT_XFAIL inputs: https://github.com/llvm/llvm-project/issues/102264
LLVM_LIT_ARGS = "-v --no-gtest-sharding --time-tests";
# LLDB Unit tests link against this library
Expand Down Expand Up @@ -3416,6 +3417,36 @@ function Test-Compilers([Hashtable] $Platform, [string] $Variant, [switch] $Test
}
}

if ($TestLLDB -or $TestLLDBSwift) {
Build-CMakeProject @BuildCMakeArgs -BuildTargets @(
"lldb",
"lldb-dap",
"lldb-server",
"repl_swift"
)

foreach ($Tool in @("lldb.exe", "lldb-dap.exe", "lldb-server.exe", "repl_swift.exe")) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we share a list of the tools perhaps?

$Path = Join-Path $Stage2BinDir $Tool
if (-not (Test-Path $Path)) {
throw "Test-Compilers: '$Path' missing after explicit Build-CMakeProject; cannot SxS-bind a non-existent EXE"
}
}

Invoke-IsolatingEnvVars {
Invoke-VsDevShell $BuildPlatform
Set-WindowsSxSToolchainRuntime `
-BinaryDir $Stage2BinDir `
-RuntimeSourceDir $RuntimeSource `
-ProcessorArchitecture $BuildPlatform.Architecture.VSName `
-Tools @(
"lldb.exe",
"lldb-dap.exe",
"lldb-server.exe",
"repl_swift.exe"
)
}
}

# TODO(roman-bcny): Workaround for https://github.com/swiftlang/swift/issues/87970
# Stdlib DLLs must be fully linked before swift-frontend compilations
# that load them, otherwise the linker races with memory-mapped DLLs
Expand Down Expand Up @@ -5502,6 +5533,21 @@ function Stage-WindowsToolchainSxS([Hashtable] $Platform,
}
Write-Host "Stage-WindowsToolchainSxS: built runtime graph with $($RuntimeDependencies.Count) DLL(s)"

# Some EXEs do not statically import the Swift runtime DLLs they need
# at runtime: lldb's expression evaluator JIT-loads the Swift stdlib +
# Foundation overlays via LoadLibrary, so the static-import scan below
# only discovers swiftCore for them, but the per-DLL SxS manifests on
# the dynamically-loaded DLLs require the consumer EXE to declare a
# matching activation context. Without this override, `expr` in any
# Swift API test fails with ERROR_MOD_NOT_FOUND. Extend such EXEs to
# the full runtime set so they can satisfy any per-DLL SxS dependency.
$DynamicRuntimeImports = @{
"lldb.exe" = $RuntimeBaseNames
"lldb-dap.exe" = $RuntimeBaseNames
"lldb-server.exe" = $RuntimeBaseNames
"repl_swift.exe" = $RuntimeBaseNames
}
Comment on lines +5544 to +5549

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we consider /delayload: instead?


$EXEDependencies = @{}
$EXEPackageClosures = @{}
$DLLDependencies = @{}
Expand All @@ -5518,6 +5564,15 @@ function Stage-WindowsToolchainSxS([Hashtable] $Platform,
-BinaryDir $BinDir `
-RuntimeSet $RuntimeSet
)
if ($DynamicRuntimeImports.ContainsKey($_.Name)) {
$Augmented = [System.Collections.Generic.HashSet[string]]::new(
[System.StringComparer]::OrdinalIgnoreCase
)
foreach ($D in $StaticRuntimeDeps) { [void]$Augmented.Add($D) }
foreach ($D in $DynamicRuntimeImports[$_.Name]) { [void]$Augmented.Add($D) }
$StaticRuntimeDeps = @($Augmented | Sort-Object)
Write-Host "Stage-WindowsToolchainSxS: augmenting '$($_.Name)' with dynamic-load runtime imports ($($StaticRuntimeDeps.Count) DLL(s))"
}
$EXEDependencies[$_.FullName] = @(
Get-RuntimeImportClosure `
-Roots $StaticRuntimeDeps `
Expand Down