diff --git a/compileopts/target.go b/compileopts/target.go index 9894ec6e31..f7b8a065f3 100644 --- a/compileopts/target.go +++ b/compileopts/target.go @@ -375,43 +375,6 @@ func defaultTarget(goos, goarch, triple string) (*TargetSpec, error) { "--no-insert-timestamp", "--no-dynamicbase", ) - } else if goos == "uefi" { - spec.Triple = strings.ReplaceAll(triple, "-unknown-uefi", "-unknown-windows-gnu") - spec.GOOS = "linux" - spec.Linker = "ld.lld" - spec.Libc = "picolibc" - spec.BuildTags = append(spec.BuildTags, "baremetal") - spec.CFlags = append(spec.CFlags, - "-ffreestanding", - "-fshort-wchar", - "-fshort-enums", - "-mno-red-zone", - ) - switch goarch { - case "amd64", "i386": - spec.LDFlags = append(spec.LDFlags, - "-m", "i386pep", - "--image-base", "0x400000", - ) - spec.ExtraFiles = append(spec.ExtraFiles, - "src/device/x86/cpu_"+goarch+".S", - ) - case "arm64": - spec.LDFlags = append(spec.LDFlags, - "-m", "arm64pe", - ) - } - spec.LDFlags = append(spec.LDFlags, - "--entry", "efi_main", - "--subsystem", "efi_application", - "-Bdynamic", - "--gc-sections", - "--no-insert-timestamp", - "--no-dynamicbase", - ) - spec.ExtraFiles = append(spec.ExtraFiles, - "src/machine/uefi/asm_"+goarch+".S", - ) } else if goos == "wasip1" { spec.GC = "" // use default GC spec.Scheduler = "asyncify" @@ -433,7 +396,7 @@ func defaultTarget(goos, goarch, triple string) (*TargetSpec, error) { } if goarch != "wasm" { suffix := "" - if (goos == "windows" || goos == "uefi") && goarch == "amd64" { + if goos == "windows" && goarch == "amd64" { // Windows uses a different calling convention on amd64 from other // operating systems so we need separate assembly files. suffix = "_windows" diff --git a/targets/uefi-amd64.json b/targets/uefi-amd64.json new file mode 100644 index 0000000000..b281391cfb --- /dev/null +++ b/targets/uefi-amd64.json @@ -0,0 +1,40 @@ +{ + "build-tags": ["uefi", "baremetal", "linux", "amd64"], + "llvm-target": "x86_64-unknown-windows-gnu", + "goos": "linux", + "goarch": "amd64", + "gc": "precise", + "linker": "ld.lld", + "libc": "picolibc", + "scheduler": "tasks", + "automatic-stack-size": false, + "default-stack-size": 65536, + "cflags": [ + "-Werror", + "-fshort-enums", + "-fomit-frame-pointer", + "-mfloat-abi=soft", + "-fno-exceptions", "-fno-unwind-tables", "-fno-asynchronous-unwind-tables", + "-ffunction-sections", "-fdata-sections", + "-ffreestanding", + "-fshort-wchar", + "-mno-red-zone" + ], + "ldflags": [ + "-m", "i386pep", + "--image-base", "0x400000", + "--entry", "efi_main", + "--subsystem", "efi_application", + "-Bdynamic", + "--gc-sections", + "--no-insert-timestamp", + "--no-dynamicbase" + ], + "extra-files": [ + "src/device/x86/cpu_amd64.S", + "src/machine/uefi/asm_amd64.S", + "src/internal/task/task_stack_amd64_windows.S", + "src/runtime/asm_amd64_windows.S" + ], + "gdb": ["gdb-multiarch", "gdb"] +}