Skip to content

Commit 76bb5c2

Browse files
committed
refactor: use uefi-amd64.json instead of modify target.go
1 parent f0311a6 commit 76bb5c2

File tree

2 files changed

+41
-38
lines changed

2 files changed

+41
-38
lines changed

compileopts/target.go

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -375,43 +375,6 @@ func defaultTarget(goos, goarch, triple string) (*TargetSpec, error) {
375375
"--no-insert-timestamp",
376376
"--no-dynamicbase",
377377
)
378-
} else if goos == "uefi" {
379-
spec.Triple = strings.ReplaceAll(triple, "-unknown-uefi", "-unknown-windows-gnu")
380-
spec.GOOS = "linux"
381-
spec.Linker = "ld.lld"
382-
spec.Libc = "picolibc"
383-
spec.BuildTags = append(spec.BuildTags, "baremetal")
384-
spec.CFlags = append(spec.CFlags,
385-
"-ffreestanding",
386-
"-fshort-wchar",
387-
"-fshort-enums",
388-
"-mno-red-zone",
389-
)
390-
switch goarch {
391-
case "amd64", "i386":
392-
spec.LDFlags = append(spec.LDFlags,
393-
"-m", "i386pep",
394-
"--image-base", "0x400000",
395-
)
396-
spec.ExtraFiles = append(spec.ExtraFiles,
397-
"src/device/x86/cpu_"+goarch+".S",
398-
)
399-
case "arm64":
400-
spec.LDFlags = append(spec.LDFlags,
401-
"-m", "arm64pe",
402-
)
403-
}
404-
spec.LDFlags = append(spec.LDFlags,
405-
"--entry", "efi_main",
406-
"--subsystem", "efi_application",
407-
"-Bdynamic",
408-
"--gc-sections",
409-
"--no-insert-timestamp",
410-
"--no-dynamicbase",
411-
)
412-
spec.ExtraFiles = append(spec.ExtraFiles,
413-
"src/machine/uefi/asm_"+goarch+".S",
414-
)
415378
} else if goos == "wasip1" {
416379
spec.GC = "" // use default GC
417380
spec.Scheduler = "asyncify"
@@ -433,7 +396,7 @@ func defaultTarget(goos, goarch, triple string) (*TargetSpec, error) {
433396
}
434397
if goarch != "wasm" {
435398
suffix := ""
436-
if (goos == "windows" || goos == "uefi") && goarch == "amd64" {
399+
if goos == "windows" && goarch == "amd64" {
437400
// Windows uses a different calling convention on amd64 from other
438401
// operating systems so we need separate assembly files.
439402
suffix = "_windows"

targets/uefi-amd64.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"build-tags": ["uefi", "baremetal", "linux", "amd64"],
3+
"llvm-target": "x86_64-unknown-windows-gnu",
4+
"goos": "linux",
5+
"goarch": "amd64",
6+
"gc": "precise",
7+
"linker": "ld.lld",
8+
"libc": "picolibc",
9+
"scheduler": "tasks",
10+
"automatic-stack-size": false,
11+
"default-stack-size": 65536,
12+
"cflags": [
13+
"-Werror",
14+
"-fshort-enums",
15+
"-fomit-frame-pointer",
16+
"-mfloat-abi=soft",
17+
"-fno-exceptions", "-fno-unwind-tables", "-fno-asynchronous-unwind-tables",
18+
"-ffunction-sections", "-fdata-sections",
19+
"-ffreestanding",
20+
"-fshort-wchar",
21+
"-mno-red-zone"
22+
],
23+
"ldflags": [
24+
"-m", "i386pep",
25+
"--image-base", "0x400000",
26+
"--entry", "efi_main",
27+
"--subsystem", "efi_application",
28+
"-Bdynamic",
29+
"--gc-sections",
30+
"--no-insert-timestamp",
31+
"--no-dynamicbase"
32+
],
33+
"extra-files": [
34+
"src/device/x86/cpu_amd64.S",
35+
"src/machine/uefi/asm_amd64.S",
36+
"src/internal/task/task_stack_amd64_windows.S",
37+
"src/runtime/asm_amd64_windows.S"
38+
],
39+
"gdb": ["gdb-multiarch", "gdb"]
40+
}

0 commit comments

Comments
 (0)