Skip to content

Commit 124b96f

Browse files
committed
Use windows-11-arm on all jobs
1 parent 026e2b4 commit 124b96f

File tree

2 files changed

+95
-108
lines changed

2 files changed

+95
-108
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
name: CI
44
on:
55
push: # test + build + release
6-
branches: [ master ]
6+
branches: [ master, arm64-windows ]
77
pull_request: # test + build
88
branches: [ master ]
99
release: # test + build + release
1010
types: [ published ]
1111
env:
12-
DC: ldc-1.41.0-beta1
12+
DC: ldc-1.41.0
1313

1414
defaults:
1515
run:
@@ -20,7 +20,7 @@ jobs:
2020
name: Build vanilla D
2121
strategy:
2222
matrix:
23-
os: [ubuntu-latest, macos-15-intel, windows-latest]
23+
os: [windows-11-arm]
2424
build: [debug-fast, release-fast]
2525
runs-on: ${{ matrix.os }}
2626
steps:
@@ -30,67 +30,25 @@ jobs:
3030
compiler: ${{ env.DC }}
3131
- name: Build
3232
run: |
33+
vswhere
3334
./build/setup.sh
3435
./build/builder --action=build --remove-build \
3536
--build=${{matrix.build}} \
37+
--target=windows-arm64 \
3638
--config=nih-cli,nih-static,nih-shared,vbe-static,vbe-shared \
3739
--compiler=ldc2 --print-commands --print-total-time \
38-
--print-callees --pretty --color
40+
--print-callees --pretty --color --verbose-callees
3941
build_no_deps:
4042
strategy:
4143
matrix:
4244
os:
43-
- runner: ubuntu-latest
44-
target: x64-linux
45-
- runner: macos-15-intel
46-
target: x64-macos
47-
#- runner: macos-14
48-
# target: arm64-macos
49-
- runner: windows-latest
50-
target: x64-windows
45+
- runner: windows-11-arm
46+
target: arm64-windows
5147
v:
5248
- build: debug-fast,release-fast
5349
config: nih-cli,nih-static,nih-shared,vbe-static,vbe-shared
5450
- build: debug
5551
config: testsuite
56-
include:
57-
- os:
58-
runner: ubuntu-latest
59-
target: wasm32-wasi
60-
v:
61-
build: debug
62-
config: testsuite
63-
- os:
64-
runner: ubuntu-latest
65-
target: wasm32-wasi
66-
v:
67-
build: release-fast
68-
config: nih-cli
69-
- os:
70-
runner: ubuntu-latest
71-
target: arm64-linux
72-
v:
73-
build: debug
74-
config: testsuite
75-
- os:
76-
runner: ubuntu-latest
77-
target: arm64-linux
78-
v:
79-
build: release-fast
80-
config: nih-cli,nih-static,nih-shared,vbe-static,vbe-shared
81-
- os:
82-
runner: ubuntu-latest
83-
target: wasm32-unknown
84-
v:
85-
build: release-fast
86-
config: nih-cli,nih-shared,vbe-shared
87-
exclude:
88-
# https://github.com/ldc-developers/ldc/issues/4696
89-
- os:
90-
runner: ubuntu-latest
91-
target: arm64-linux
92-
v:
93-
build: debug-fast
9452
name: Build ${{ matrix.os.target }}-${{ matrix.v.build }}-${{ matrix.v.config }}
9553
runs-on: ${{ matrix.os.runner }}
9654
steps:
@@ -116,70 +74,17 @@ jobs:
11674
strategy:
11775
matrix:
11876
os:
119-
- runner: ubuntu-latest
120-
target: x64-linux
121-
- runner: macos-15-intel
122-
target: x64-macos
123-
#- runner: macos-14
124-
# target: arm64-macos
125-
- runner: windows-latest
126-
target: x64-windows
12777
- runner: windows-11-arm
12878
target: arm64-windows
129-
- runner: ubuntu-latest
130-
target: wasm32-wasi
131-
- runner: ubuntu-latest
132-
target: arm64-linux
13379
runs-on: ${{ matrix.os.runner }}
13480
steps:
13581
- uses: actions/checkout@v4
13682
- uses: dlang-community/setup-dlang@v1
13783
with:
13884
compiler: ${{ env.DC }}
139-
- uses: jcbhmr/setup-wasmtime@v2
140-
if: ${{ matrix.os.target == 'wasm32-wasi' }}
141-
- if: ${{ matrix.os.target == 'arm64-linux' }}
142-
run: |
143-
sudo apt update
144-
sudo apt install qemu-user
14585
- name: Test
14686
run: |
14787
./build/setup.sh
148-
./build/builder --action=run --remove-build --no-deps --build=debug \
88+
"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat" arm64 && ./build/builder --action=run --remove-build --no-deps --build=debug \
14989
--target-relaxed=${{ matrix.os.target }} --config=testsuite \
15090
--compiler=ldc2 --print-commands --print-callees --pretty --color
151-
upload:
152-
name: Upload build
153-
if: github.event_name != 'pull_request'
154-
runs-on: ubuntu-latest
155-
needs: [build_no_deps, test]
156-
steps:
157-
# Cloning is needed for `gh release create` to work. It looks repository up in .git folder
158-
- uses: actions/checkout@v4
159-
# Download build artifacts of other jobs
160-
- uses: actions/download-artifact@v4
161-
with:
162-
pattern: artifact-*
163-
merge-multiple: true
164-
path: bin/
165-
# Update tag, so that we get proper date and commit on github
166-
- name: Update CI tag
167-
uses: richardsimko/[email protected]
168-
if: github.ref == 'refs/heads/master'
169-
with:
170-
tag_name: CI
171-
env:
172-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
173-
# Create CI release and upload builds
174-
- name: Upload
175-
env:
176-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
177-
run: |
178-
ls -R
179-
tag=`basename ${{ github.ref }}`
180-
if [ $tag = 'master' ]; then
181-
tag='CI'
182-
fi
183-
184-
# --clobber Overwrite existing assets of the same name
185-
gh release upload $tag bin/*.zip --clobber

build/builder.d

Lines changed: 86 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@ struct GlobalSettings
244244

245245
// settings parser
246246
void setTarget(string option, string target) {
247+
stderr.writefln("Start os: %s arch: %s", targetOs, targetArch);
248+
247249
foreach(component; target.asLowerCase.text.splitter('-')) {
248250
auto aliasIndex = countUntil(targetAliases[].map!(a => a.from), component);
249251
if (aliasIndex >= 0) {
@@ -268,6 +270,7 @@ struct GlobalSettings
268270
stderr.writeln;
269271
needsHelp = true;
270272
}
273+
stderr.writefln("End os: %s arch: %s", targetOs, targetArch);
271274
}
272275
}
273276

@@ -345,6 +348,9 @@ GlobalSettings parseSettings(string[] args, const(Config)[] configs) {
345348

346349
arraySep = ",";
347350

351+
stderr.writefln("Start os: %s arch: %s", settings.targetOs, settings.targetArch);
352+
scope(exit) stderr.writefln("End os: %s arch: %s", settings.targetOs, settings.targetArch);
353+
348354
retry_parse_opts:
349355
try
350356
{
@@ -455,6 +461,7 @@ struct CompileParams {
455461
struct Job {
456462
CompileParams params;
457463
string[] args;
464+
string[string] envVars;
458465
string workDir;
459466
// When executable is produced it will be a first artifact
460467
string[] artifacts;
@@ -467,6 +474,71 @@ struct Job {
467474
bool printOutput;
468475
}
469476

477+
bool isSomeWindowsTarget(in GlobalSettings gs) {
478+
if (gs.targetOs != TargetOs.windows) return false;
479+
if (gs.targetArch == TargetArch.arm64) return true;
480+
if (gs.targetArch == TargetArch.x64) return true;
481+
return false;
482+
}
483+
484+
void addWindowsLibs(in GlobalSettings gs, ref string[string] envVars) {
485+
import std.file;
486+
487+
if (hostOs != TargetOs.windows) return;
488+
if (!isSomeWindowsTarget(gs)) return;
489+
490+
import std.process : execute, Config;
491+
auto result = execute(["vswhere", "-latest", "-property", "resolvedInstallationPath"], null, Config.none, size_t.max);
492+
493+
if (result.status != 0) {
494+
stderr.writeln("vswhere exited with ", result.status);
495+
stderr.writeln("Cannot find Windows SDK and Visual Studio");
496+
return;
497+
}
498+
499+
// LDC will skip environment setup if it detects VSINSTALLDIR and VSCMD_ARG_TGT_ARCH
500+
auto vsPath = result.output.strip;
501+
envVars["VSINSTALLDIR"] = vsPath;
502+
envVars["VSCMD_ARG_TGT_ARCH"] = archName[gs.targetArch];
503+
504+
auto sdkPath = `C:\Program Files (x86)\Windows Kits\10\Lib`;
505+
if (!exists(sdkPath)) {
506+
stderr.writeln("Cannot find Windows SDK at %s", sdkPath);
507+
return;
508+
}
509+
510+
string maxSdkPath;
511+
foreach(DirEntry e; dirEntries(sdkPath, SpanMode.shallow)) {
512+
if (maxSdkPath is null || e.name > maxSdkPath) {
513+
maxSdkPath = e.name;
514+
}
515+
}
516+
517+
auto vsToolsPath = buildPath(vsPath, `VC\Tools\MSVC`);
518+
string maxVSPath;
519+
foreach(DirEntry e; dirEntries(vsToolsPath, SpanMode.shallow)) {
520+
if (maxVSPath is null || e.name > maxVSPath) {
521+
maxVSPath = e.name;
522+
}
523+
}
524+
525+
auto umLibsPath = buildPath(maxSdkPath, "um", archName[gs.targetArch]);
526+
auto ucrtLibsPath = buildPath(maxSdkPath, "ucrt", archName[gs.targetArch]);
527+
auto vsLibsPath = buildPath(maxVSPath, "lib", archName[gs.targetArch]);
528+
529+
auto umTestPath = buildPath(umLibsPath, "kernel32.lib");
530+
auto ucrtTestPath = buildPath(ucrtLibsPath, "libucrt.lib");
531+
auto vsTestPath = buildPath(vsLibsPath, "libcmt.lib");
532+
533+
if (maxSdkPath is null || maxVSPath is null || !exists(umTestPath) || !exists(ucrtTestPath) || !exists(vsTestPath)) {
534+
stderr.writeln("Cannot find Visual Studio at %s", vsPath);
535+
return;
536+
}
537+
538+
import std.array : join;
539+
envVars["LIB"] = join([umLibsPath, ucrtLibsPath, vsLibsPath], ";");
540+
}
541+
470542
Job makeCompileJob(in GlobalSettings gs, in CompileParams params) {
471543
import std.path : buildPath;
472544

@@ -526,12 +598,16 @@ Job makeCompileJob(in GlobalSettings gs, in CompileParams params) {
526598
args ~= buildPath(params.srcDir, "custom_object.d");
527599
}
528600

601+
string[string] envVars;
602+
addWindowsLibs(gs, envVars);
603+
529604
Job job = {
530605
params : params,
531606
args : args,
532607
artifacts : artifacts,
533608
extraArtifacts : extraArtifacts,
534609
printOutput : gs.printCallees,
610+
envVars : envVars,
535611
};
536612
return job;
537613
}
@@ -619,10 +695,16 @@ JobResult runJob(in GlobalSettings gs, in Job job) {
619695
}
620696

621697
void printCommand() {
622-
if (gs.prettyPrint)
698+
if (gs.prettyPrint) {
623699
stderr.writefln("> %-(%s\n| %)", job.args);
624-
else
625-
stderr.writefln("> %-(%s %)", job.args);
700+
foreach(key, val; job.envVars)
701+
stderr.writefln("| $% = %s", key, val);
702+
} else {
703+
stderr.writef("> %-(%s %)", job.args);
704+
foreach(key, val; job.envVars)
705+
stderr.writef(" $%s=%s", key, val);
706+
stderr.writeln;
707+
}
626708
}
627709

628710
if (gs.printCommands) printCommand;
@@ -632,7 +714,7 @@ JobResult runJob(in GlobalSettings gs, in Job job) {
632714
MonoTime startTime = currTime;
633715
import std.process : execute, Config;
634716
try {
635-
auto result = execute(job.args, null, Config.none, size_t.max, job.workDir);
717+
auto result = execute(job.args, job.envVars, Config.none, size_t.max, job.workDir);
636718
MonoTime endTime = currTime;
637719

638720
void printCalleeOutput() {

0 commit comments

Comments
 (0)