Skip to content
Draft
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
55 changes: 54 additions & 1 deletion .github/workflows/ci-win.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Windows Arm64/x86_64 Nightly

on:
# pull_request: {} # Uncomment only to test this WF file update.
pull_request: {} # Uncomment only to test this WF file update.
schedule:
# 9:00 PM Central
- cron: '0 2 * * *'
Expand Down Expand Up @@ -33,6 +33,59 @@ jobs:
name: Windows-Arm64

steps:
- name: Install QEMU with winget
shell: pwsh
run: |
$qemuInstallDirs = @(
'C:\Program Files\qemu',
'C:\Program Files\QEMU',
'C:\Program Files (x86)\qemu'
)

foreach ($qemuDir in $qemuInstallDirs) {
if ((Test-Path $qemuDir) -and -not (($env:Path -split ';') -contains $qemuDir)) {
$env:Path = "$qemuDir;$env:Path"
}
}

if (-not (Get-Command qemu-system-x86_64 -ErrorAction SilentlyContinue)) {
winget install -e --id SoftwareFreedomConservancy.QEMU --silent --accept-package-agreements --accept-source-agreements
$machinePath = [System.Environment]::GetEnvironmentVariable("Path", "Machine")
$userPath = [System.Environment]::GetEnvironmentVariable("Path", "User")
$env:Path = "$machinePath;$userPath"

foreach ($qemuDir in $qemuInstallDirs) {
if ((Test-Path $qemuDir) -and -not (($env:Path -split ';') -contains $qemuDir)) {
$env:Path = "$qemuDir;$env:Path"
}
}
}

$qemu = Get-Command qemu-system-x86_64 -ErrorAction SilentlyContinue
if (-not $qemu) {
$qemu = Get-Command qemu-system-x86_64.exe -ErrorAction SilentlyContinue
}

if (-not $qemu) {
foreach ($qemuDir in $qemuInstallDirs) {
$qemuExePath = Join-Path $qemuDir 'qemu-system-x86_64.exe'
if (Test-Path $qemuExePath) {
$qemu = Get-Item $qemuExePath
break
}
}
}

if (-not $qemu) {
throw 'qemu-system-x86_64.exe not found. Ensure one of these is on PATH: C:\Program Files\qemu, C:\Program Files\QEMU, or C:\Program Files (x86)\qemu.'
}

Split-Path $qemu.Path | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append

- name: Verify QEMU installation
shell: pwsh
run: qemu-system-x86_64 --help

- name: Map Git usr/bin to a space-free drive and prepend to PATH
shell: pwsh
run: |
Expand Down
6 changes: 6 additions & 0 deletions test/lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,13 @@ run=""
clangnorvcopts = ''
filecheck = 'FileCheck'
python = 'python'
qemu_x86_64 = None

if platform.system() == 'Windows':
rm = which("rm") + " -rf"
mkdir = which("mkdir") + " -p"
grep = 'findstr'
qemu_x86_64 = which('qemu-system-x86_64')
config.available_features.add('windows')
elif platform.system() == 'Linux':
rm = 'rm -rf'
Expand Down Expand Up @@ -555,6 +557,8 @@ lit_config.note('using cmake: {}'.format(cmake))
lit_config.note('using git: {}'.format(git))
lit_config.note('using dirname: {}'.format(dirname))
lit_config.note('using test templates directory: {}'.format(test_templates_dir))
if platform.system() == 'Windows':
lit_config.note('using qemu_x86_64: {}'.format(qemu_x86_64))
if muslclang is not None:
lit_config.note('using musl-clang: {}'.format(muslclang))
else:
Expand Down Expand Up @@ -655,5 +659,7 @@ config.substitutions.append( ("%mcpu","".join(mcpu)) )
config.substitutions.append( ("%dirname","".join(dirname)) )
config.substitutions.append( ("%emulation","".join(config.emulation)) )
config.substitutions.append( ("%run","".join(run)) )
if platform.system() == 'Windows':
config.substitutions.append( ("%qemu_x86_64", "".join(qemu_x86_64)) )
if muslclang is not None:
config.substitutions.append( ("%musl-clang","".join(muslclang)) )
20 changes: 12 additions & 8 deletions test/x86_64/linux/DefaultImageBase/DefaultImageBase.test
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
#UNSUPPORTED: windows
#---DefaultImageBase.test-----Executable--------#
BEGIN_COMMENT
# Test x86_64 default image address
# This test verifies that eld uses the correct default image base (0x400000)
# without requiring manual --image-base=0x400000 flag.
# without requiring manual --image-base=0x400000 flag and allows overriding it.
#END_COMMENT
#START_TEST
RUN: %clang %clangopts -c %p/Inputs/1.c -o %t.1.o
RUN: %link %linkopts -o %t.1.out %t.1.o
RUN: %t.1.out; echo $? > %t.code
RUN: %filecheck --input-file=%t.code %s --check-prefix=EXITCODE
RUN: %readelf -l %t.1.out | %grep LOAD | %filecheck %s --check-prefix=IMAGEBASE
RUN: %link %linkopts -o %t.default.out %t.1.o
RUN: %if windows %{ %qemu_x86_64 %t.default.out %} %else %{ %t.default.out %}; echo $? > %t.default.code
RUN: %filecheck --input-file=%t.default.code %s --check-prefix=EXITCODE
RUN: %readelf -l %t.default.out | %grep LOAD | %filecheck %s --check-prefix=IMAGEBASE-DEFAULT
RUN: %link %linkopts --image-base=0x500000 -o %t.custom.out %t.1.o
RUN: %if windows %{ %qemu_x86_64 %t.custom.out %} %else %{ %t.custom.out %}; echo $? > %t.custom.code
RUN: %filecheck --input-file=%t.custom.code %s --check-prefix=EXITCODE
RUN: %readelf -l %t.custom.out | %grep LOAD | %filecheck %s --check-prefix=IMAGEBASE-CUSTOM
EXITCODE: 7
IMAGEBASE: {{.*}}400000{{.*}}
#END_TEST
IMAGEBASE-DEFAULT: {{.*}}400000{{.*}}
IMAGEBASE-CUSTOM: {{.*}}500000{{.*}}
#END_TEST
Loading