aboutsummaryrefslogtreecommitdiffhomepage
path: root/builder
diff options
context:
space:
mode:
Diffstat (limited to 'builder')
-rw-r--r--builder/build.go2
-rw-r--r--builder/builder_test.go1
-rw-r--r--builder/mingw-w64.go18
-rw-r--r--builder/tools-builtin.go2
4 files changed, 18 insertions, 5 deletions
diff --git a/builder/build.go b/builder/build.go
index 26395d53f..78a9dc662 100644
--- a/builder/build.go
+++ b/builder/build.go
@@ -151,7 +151,7 @@ func Build(pkgName, outpath, tmpdir string, config *compileopts.Config) (BuildRe
return BuildResult{}, err
}
unlock()
- libcDependencies = append(libcDependencies, makeMinGWExtraLibs(tmpdir)...)
+ libcDependencies = append(libcDependencies, makeMinGWExtraLibs(tmpdir, config.GOARCH())...)
case "":
// no library specified, so nothing to do
default:
diff --git a/builder/builder_test.go b/builder/builder_test.go
index 3b0ae8bcf..f8bdd5134 100644
--- a/builder/builder_test.go
+++ b/builder/builder_test.go
@@ -59,6 +59,7 @@ func TestClangAttributes(t *testing.T) {
{GOOS: "darwin", GOARCH: "amd64"},
{GOOS: "darwin", GOARCH: "arm64"},
{GOOS: "windows", GOARCH: "amd64"},
+ {GOOS: "windows", GOARCH: "arm64"},
} {
name := "GOOS=" + options.GOOS + ",GOARCH=" + options.GOARCH
if options.GOARCH == "arm" {
diff --git a/builder/mingw-w64.go b/builder/mingw-w64.go
index 289a85489..1e7701d47 100644
--- a/builder/mingw-w64.go
+++ b/builder/mingw-w64.go
@@ -1,6 +1,7 @@
package builder
import (
+ "fmt"
"io"
"os"
"path/filepath"
@@ -43,7 +44,7 @@ var MinGW = Library{
//
// TODO: cache the result. At the moment, it costs a few hundred milliseconds to
// compile these files.
-func makeMinGWExtraLibs(tmpdir string) []*compileJob {
+func makeMinGWExtraLibs(tmpdir, goarch string) []*compileJob {
var jobs []*compileJob
root := goenv.Get("TINYGOROOT")
// Normally all the api-ms-win-crt-*.def files are all compiled to a single
@@ -74,16 +75,27 @@ func makeMinGWExtraLibs(tmpdir string) []*compileJob {
result: outpath,
run: func(job *compileJob) error {
defpath := inpath
+ var archDef, emulation string
+ switch goarch {
+ case "amd64":
+ archDef = "-DDEF_X64"
+ emulation = "i386pep"
+ case "arm64":
+ archDef = "-DDEF_ARM64"
+ emulation = "arm64pe"
+ default:
+ return fmt.Errorf("unsupported architecture for mingw-w64: %s", goarch)
+ }
if strings.HasSuffix(inpath, ".in") {
// .in files need to be preprocessed by a preprocessor (-E)
// first.
defpath = outpath + ".def"
- err := runCCompiler("-E", "-x", "c", "-Wp,-w", "-P", "-DDEF_X64", "-DDATA", "-o", defpath, inpath, "-I"+goenv.Get("TINYGOROOT")+"/lib/mingw-w64/mingw-w64-crt/def-include/")
+ err := runCCompiler("-E", "-x", "c", "-Wp,-w", "-P", archDef, "-DDATA", "-o", defpath, inpath, "-I"+goenv.Get("TINYGOROOT")+"/lib/mingw-w64/mingw-w64-crt/def-include/")
if err != nil {
return err
}
}
- return link("ld.lld", "-m", "i386pep", "-o", outpath, defpath)
+ return link("ld.lld", "-m", emulation, "-o", outpath, defpath)
},
}
jobs = append(jobs, job)
diff --git a/builder/tools-builtin.go b/builder/tools-builtin.go
index fbe6ef02f..2b3cba618 100644
--- a/builder/tools-builtin.go
+++ b/builder/tools-builtin.go
@@ -28,7 +28,7 @@ const hasBuiltinTools = true
func RunTool(tool string, args ...string) error {
linker := "elf"
if tool == "ld.lld" && len(args) >= 2 {
- if args[0] == "-m" && args[1] == "i386pep" {
+ if args[0] == "-m" && (args[1] == "i386pep" || args[1] == "arm64pe") {
linker = "mingw"
} else if args[0] == "-flavor" {
linker = args[1]