Skip to content

Commit af3c522

Browse files
committed
Use the cached Windows linker directly
2 parents 241e438 + 2638054 commit af3c522

5 files changed

Lines changed: 18 additions & 21 deletions

File tree

metadata/LLVM_MINGW_TOOLCHAIN

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ llvm 22
44
crt ucrt
55
x64_sha256 b9b68a4d276e16fa25802aaba458e4638f64b3884c290aaccdc2d87083b6ca35
66
arm64_sha256 312593669435bd0bfc1a43ac3fba23c8b27e0610bade88b2738e5a01702a99ba
7-
schema 3
7+
schema 2

scripts/llvm-mingw-toolchain.ps1

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function Read-LlvmMingwMetadata {
4040
if ($metadata.release -notmatch '^[0-9]{8}$' -or $metadata.llvm -notmatch '^[0-9]+$') {
4141
throw "LLVM MinGW release and LLVM version fields are invalid."
4242
}
43-
if ($metadata.crt -ne "ucrt" -or $metadata.schema -ne "3") {
43+
if ($metadata.crt -ne "ucrt" -or $metadata.schema -ne "2") {
4444
throw "LLVM MinGW CRT or metadata schema is unsupported."
4545
}
4646
foreach ($checksumField in "x64_sha256", "arm64_sha256") {
@@ -102,8 +102,6 @@ function Assert-LlvmMingwLayout {
102102
"LICENSE.TXT",
103103
"bin\cc.exe",
104104
"bin\clang-$LlvmVersion.exe",
105-
"bin\mingw32-common.cfg",
106-
"bin\$TargetArchitecture-w64-windows-gnu.cfg",
107105
"bin\llvm-ar.exe",
108106
"bin\ld.lld.exe",
109107
"bin\libLLVM-$LlvmVersion.dll",
@@ -144,24 +142,27 @@ function Install-LlvmMingwToolchain {
144142
$archivePath = Join-Path $archiveDirectory $assetName
145143
$toolchainRoot = Join-Path $cacheRoot "$($metadata.release)-$($metadata.crt)-$($hostConfiguration.AssetArchitecture)"
146144
$markerPath = Join-Path $toolchainRoot ".dynlex-llvm-mingw"
147-
$markerFields = @(
145+
$markerContents = @(
146+
"schema=$($metadata.schema)",
148147
"release=$($metadata.release)",
149148
"sha256=$expectedChecksum",
150149
"host=$($hostConfiguration.AssetArchitecture)",
151150
"target=$($hostConfiguration.TargetTriple)"
152-
)
153-
$markerContents = (@("schema=$($metadata.schema)") + $markerFields) -join "`n"
154-
$previousMarkerContents = @(
155-
(@("schema=1") + $markerFields) -join "`n"
156-
(@("schema=2") + $markerFields) -join "`n"
157-
)
151+
) -join "`n"
152+
$schemaOneMarkerContents = @(
153+
"schema=1",
154+
"release=$($metadata.release)",
155+
"sha256=$expectedChecksum",
156+
"host=$($hostConfiguration.AssetArchitecture)",
157+
"target=$($hostConfiguration.TargetTriple)"
158+
) -join "`n"
158159

159160
if (Test-Path $toolchainRoot) {
160161
if (-not (Test-Path -PathType Leaf $markerPath)) {
161162
throw "LLVM MinGW cache directory exists without its integrity marker: $toolchainRoot"
162163
}
163164
$actualMarkerContents = (Get-Content $markerPath -Raw).TrimEnd()
164-
if ($previousMarkerContents -contains $actualMarkerContents) {
165+
if ($actualMarkerContents -eq $schemaOneMarkerContents) {
165166
Remove-Item -Recurse -Force $toolchainRoot
166167
} elseif ($actualMarkerContents -ne $markerContents) {
167168
throw "LLVM MinGW cache integrity marker does not match the pinned toolchain."
@@ -209,8 +210,6 @@ function Install-LlvmMingwToolchain {
209210
foreach ($fileName in @(
210211
"cc.exe",
211212
"clang-$($metadata.llvm).exe",
212-
"mingw32-common.cfg",
213-
"$($hostConfiguration.TargetArchitecture)-w64-windows-gnu.cfg",
214213
"llvm-ar.exe",
215214
"ld.lld.exe",
216215
"libLLVM-$($metadata.llvm).dll",

scripts/stage-windows-toolchain.ps1

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ New-Item -ItemType Directory -Path $destinationRuntime, $destinationVcpkgLicense
4747
foreach ($fileName in @(
4848
"cc.exe",
4949
"clang-$LlvmVersion.exe",
50-
"mingw32-common.cfg",
51-
"$TargetArchitecture-w64-windows-gnu.cfg",
5250
"ld.lld.exe",
5351
"libLLVM-$LlvmVersion.dll",
5452
"libclang-cpp.dll",

scripts/test_windows_toolchain.ps1

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ $llvmMingwMetadata = Read-LlvmMingwMetadata -ProjectRoot $projectRoot
129129
if (
130130
$llvmMingwMetadata.release -ne "20260616" -or
131131
$llvmMingwMetadata.llvm -ne "22" -or
132-
$llvmMingwMetadata.schema -ne "3" -or
132+
$llvmMingwMetadata.schema -ne "2" -or
133133
$llvmMingwMetadata.x64_sha256 -ne "b9b68a4d276e16fa25802aaba458e4638f64b3884c290aaccdc2d87083b6ca35" -or
134134
$llvmMingwMetadata.arm64_sha256 -ne "312593669435bd0bfc1a43ac3fba23c8b27e0610bade88b2738e5a01702a99ba"
135135
) {
@@ -169,8 +169,6 @@ try {
169169
"LICENSE.TXT",
170170
"bin\cc.exe",
171171
"bin\clang-22.exe",
172-
"bin\mingw32-common.cfg",
173-
"bin\x86_64-w64-windows-gnu.cfg",
174172
"bin\llvm-ar.exe",
175173
"bin\ld.lld.exe",
176174
"bin\libLLVM-22.dll",
@@ -215,8 +213,6 @@ try {
215213
-DependencyRoot $dependencyRoot
216214
foreach ($relativePath in @(
217215
"lib\dynlex\toolchain\bin\cc.exe",
218-
"lib\dynlex\toolchain\bin\mingw32-common.cfg",
219-
"lib\dynlex\toolchain\bin\x86_64-w64-windows-gnu.cfg",
220216
"lib\dynlex\toolchain\lib\clang\22\include\stdbool.h",
221217
"lib\dynlex\toolchain\lib\clang\22\include\stddef.h",
222218
"lib\dynlex\toolchain\lib\clang\22\include\x86intrin.h",

src/cpp/compiler/codegen/native.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,10 @@ bool emitNativeExecutable(ParseContext &context) {
497497
commandStorage.push_back(linkerProgram);
498498
#ifdef _WIN32
499499
commandStorage.push_back("--target=" DYNLEX_WINDOWS_TARGET_TRIPLE);
500+
commandStorage.push_back("-rtlib=compiler-rt");
501+
commandStorage.push_back("-unwindlib=libunwind");
502+
commandStorage.push_back("-stdlib=libc++");
503+
commandStorage.push_back("-fuse-ld=lld");
500504
commandStorage.push_back("-L" + toolchain.targetLibraries.string());
501505
commandStorage.push_back("-L" + toolchain.dependencyLibraries.string());
502506
#elif defined(__APPLE__)

0 commit comments

Comments
 (0)