diff options
32 files changed, 44 insertions, 67 deletions
@@ -470,9 +470,9 @@ build/release: tinygo gen-device wasi-libc @mkdir -p build/release/tinygo/lib/nrfx @mkdir -p build/release/tinygo/lib/picolibc/newlib/libc @mkdir -p build/release/tinygo/lib/wasi-libc - @mkdir -p build/release/tinygo/pkg/armv6m-none-eabi - @mkdir -p build/release/tinygo/pkg/armv7m-none-eabi - @mkdir -p build/release/tinygo/pkg/armv7em-none-eabi + @mkdir -p build/release/tinygo/pkg/armv6m-unknown-unknown-eabi + @mkdir -p build/release/tinygo/pkg/armv7m-unknown-unknown-eabi + @mkdir -p build/release/tinygo/pkg/armv7em-unknown-unknown-eabi @echo copying source files @cp -p build/tinygo$(EXE) build/release/tinygo/bin @cp -p $(abspath $(CLANG_SRC))/lib/Headers/*.h build/release/tinygo/lib/clang/include @@ -491,12 +491,12 @@ build/release: tinygo gen-device wasi-libc @cp -rp lib/wasi-libc/sysroot build/release/tinygo/lib/wasi-libc/sysroot @cp -rp src build/release/tinygo/src @cp -rp targets build/release/tinygo/targets - ./build/tinygo build-library -target=armv6m-none-eabi -o build/release/tinygo/pkg/armv6m-none-eabi/compiler-rt.a compiler-rt - ./build/tinygo build-library -target=armv7m-none-eabi -o build/release/tinygo/pkg/armv7m-none-eabi/compiler-rt.a compiler-rt - ./build/tinygo build-library -target=armv7em-none-eabi -o build/release/tinygo/pkg/armv7em-none-eabi/compiler-rt.a compiler-rt - ./build/tinygo build-library -target=armv6m-none-eabi -o build/release/tinygo/pkg/armv6m-none-eabi/picolibc.a picolibc - ./build/tinygo build-library -target=armv7m-none-eabi -o build/release/tinygo/pkg/armv7m-none-eabi/picolibc.a picolibc - ./build/tinygo build-library -target=armv7em-none-eabi -o build/release/tinygo/pkg/armv7em-none-eabi/picolibc.a picolibc + ./build/tinygo build-library -target=armv6m-unknown-unknown-eabi -o build/release/tinygo/pkg/armv6m-unknown-unknown-eabi/compiler-rt.a compiler-rt + ./build/tinygo build-library -target=armv7m-unknown-unknown-eabi -o build/release/tinygo/pkg/armv7m-unknown-unknown-eabi/compiler-rt.a compiler-rt + ./build/tinygo build-library -target=armv7em-unknown-unknown-eabi -o build/release/tinygo/pkg/armv7em-unknown-unknown-eabi/compiler-rt.a compiler-rt + ./build/tinygo build-library -target=armv6m-unknown-unknown-eabi -o build/release/tinygo/pkg/armv6m-unknown-unknown-eabi/picolibc.a picolibc + ./build/tinygo build-library -target=armv7m-unknown-unknown-eabi -o build/release/tinygo/pkg/armv7m-unknown-unknown-eabi/picolibc.a picolibc + ./build/tinygo build-library -target=armv7em-unknown-unknown-eabi -o build/release/tinygo/pkg/armv7em-unknown-unknown-eabi/picolibc.a picolibc release: build/release tar -czf build/release.tar.gz -C build/release tinygo diff --git a/cgo/cgo_test.go b/cgo/cgo_test.go index 6d5d55045..88c506d46 100644 --- a/cgo/cgo_test.go +++ b/cgo/cgo_test.go @@ -28,7 +28,7 @@ func normalizeResult(result string) string { } func TestCGo(t *testing.T) { - var cflags = []string{"--target=armv6m-none-eabi"} + var cflags = []string{"--target=armv6m-unknown-unknown-eabi"} for _, name := range []string{"basic", "errors", "types", "flags", "const"} { name := name // avoid a race condition diff --git a/compileopts/config.go b/compileopts/config.go index 4aa8ed5ee..52f1a0494 100644 --- a/compileopts/config.go +++ b/compileopts/config.go @@ -21,7 +21,7 @@ type Config struct { TestConfig TestConfig } -// Triple returns the LLVM target triple, like armv6m-none-eabi. +// Triple returns the LLVM target triple, like armv6m-unknown-unknown-eabi. func (c *Config) Triple() string { return c.Target.Triple } @@ -213,6 +213,8 @@ func (c *Config) CFlags() []string { cflags = append(cflags, "-g") // Use the same optimization level as TinyGo. cflags = append(cflags, "-O"+c.Options.Opt) + // Set the LLVM target triple. + cflags = append(cflags, "--target="+c.Triple()) return cflags } diff --git a/compileopts/target.go b/compileopts/target.go index a84896c9b..df3b5d3ff 100644 --- a/compileopts/target.go +++ b/compileopts/target.go @@ -177,7 +177,10 @@ func LoadTarget(target string) (*TargetSpec, error) { if llvmarch == "" { llvmarch = goarch } - target = llvmarch + "--" + llvmos + // Target triples (which actually have four components, but are called + // triples for historical reasons) have the form: + // arch-vendor-os-environment + target = llvmarch + "-unknown-" + llvmos if goarch == "arm" { target += "-gnueabihf" } @@ -207,14 +210,6 @@ func LoadTarget(target string) (*TargetSpec, error) { if len(tripleSplit) < 3 { return nil, errors.New("expected a full LLVM target or a custom target in -target flag") } - if tripleSplit[0] == "arm" { - // LLVM and Clang have a different idea of what "arm" means, so - // upgrade to a slightly more modern ARM. In fact, when you pass - // --target=arm--linux-gnueabihf to Clang, it will convert that - // internally to armv7-unknown-linux-gnueabihf. Changing the - // architecture to armv7 will keep things consistent. - tripleSplit[0] = "armv7" - } goos := tripleSplit[2] if strings.HasPrefix(goos, "darwin") { goos = "darwin" @@ -250,7 +245,6 @@ func defaultTarget(goos, goarch, triple string) (*TargetSpec, error) { Scheduler: "tasks", Linker: "cc", DefaultStackSize: 1024 * 64, // 64kB - CFlags: []string{"--target=" + triple}, GDB: []string{"gdb"}, PortReset: "false", } diff --git a/compiler/testdata/basic.ll b/compiler/testdata/basic.ll index aca2ece0a..56c1fa4c9 100644 --- a/compiler/testdata/basic.ll +++ b/compiler/testdata/basic.ll @@ -1,7 +1,7 @@ ; ModuleID = 'basic.go' source_filename = "basic.go" target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" -target triple = "wasm32--wasi" +target triple = "wasm32-unknown-wasi" %main.kv = type { float } %main.kv.0 = type { i8 } diff --git a/compiler/testdata/channel.ll b/compiler/testdata/channel.ll index 0d33d330b..9f49142d0 100644 --- a/compiler/testdata/channel.ll +++ b/compiler/testdata/channel.ll @@ -1,7 +1,7 @@ ; ModuleID = 'channel.go' source_filename = "channel.go" target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" -target triple = "wasm32--wasi" +target triple = "wasm32-unknown-wasi" %runtime.channel = type { i32, i32, i8, %runtime.channelBlockedList*, i32, i32, i32, i8* } %runtime.channelBlockedList = type { %runtime.channelBlockedList*, %"internal/task.Task"*, %runtime.chanSelectState*, { %runtime.channelBlockedList*, i32, i32 } } diff --git a/compiler/testdata/float.ll b/compiler/testdata/float.ll index 6d35d33e3..e71e3ad41 100644 --- a/compiler/testdata/float.ll +++ b/compiler/testdata/float.ll @@ -1,7 +1,7 @@ ; ModuleID = 'float.go' source_filename = "float.go" target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" -target triple = "wasm32--wasi" +target triple = "wasm32-unknown-wasi" declare noalias nonnull i8* @runtime.alloc(i32, i8*, i8*) diff --git a/compiler/testdata/func.ll b/compiler/testdata/func.ll index 4ccea0aaf..6ed2a5a56 100644 --- a/compiler/testdata/func.ll +++ b/compiler/testdata/func.ll @@ -1,7 +1,7 @@ ; ModuleID = 'func.go' source_filename = "func.go" target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" -target triple = "wasm32--wasi" +target triple = "wasm32-unknown-wasi" %runtime.funcValueWithSignature = type { i32, i8* } diff --git a/compiler/testdata/go1.17.ll b/compiler/testdata/go1.17.ll index 6fa47c8b1..e2c99cc13 100644 --- a/compiler/testdata/go1.17.ll +++ b/compiler/testdata/go1.17.ll @@ -1,7 +1,7 @@ ; ModuleID = 'go1.17.go' source_filename = "go1.17.go" target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" -target triple = "wasm32--wasi" +target triple = "wasm32-unknown-wasi" declare noalias nonnull i8* @runtime.alloc(i32, i8*, i8*) diff --git a/compiler/testdata/goroutine-cortex-m-qemu.ll b/compiler/testdata/goroutine-cortex-m-qemu.ll index a98592c15..63f9cc9af 100644 --- a/compiler/testdata/goroutine-cortex-m-qemu.ll +++ b/compiler/testdata/goroutine-cortex-m-qemu.ll @@ -1,7 +1,7 @@ ; ModuleID = 'goroutine.go' source_filename = "goroutine.go" target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64" -target triple = "armv7m-none-eabi" +target triple = "armv7m-unknown-unknown-eabi" %runtime.channel = type { i32, i32, i8, %runtime.channelBlockedList*, i32, i32, i32, i8* } %runtime.channelBlockedList = type { %runtime.channelBlockedList*, %"internal/task.Task"*, %runtime.chanSelectState*, { %runtime.channelBlockedList*, i32, i32 } } diff --git a/compiler/testdata/goroutine-wasm.ll b/compiler/testdata/goroutine-wasm.ll index 1d840e6da..1acbc50b0 100644 --- a/compiler/testdata/goroutine-wasm.ll +++ b/compiler/testdata/goroutine-wasm.ll @@ -1,7 +1,7 @@ ; ModuleID = 'goroutine.go' source_filename = "goroutine.go" target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" -target triple = "wasm32--wasi" +target triple = "wasm32-unknown-wasi" %runtime.funcValueWithSignature = type { i32, i8* } %runtime.channel = type { i32, i32, i8, %runtime.channelBlockedList*, i32, i32, i32, i8* } diff --git a/compiler/testdata/interface.ll b/compiler/testdata/interface.ll index be9e229a1..8fef79e0e 100644 --- a/compiler/testdata/interface.ll +++ b/compiler/testdata/interface.ll @@ -1,7 +1,7 @@ ; ModuleID = 'interface.go' source_filename = "interface.go" target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" -target triple = "wasm32--wasi" +target triple = "wasm32-unknown-wasi" %runtime.typecodeID = type { %runtime.typecodeID*, i32, %runtime.interfaceMethodInfo*, %runtime.typecodeID* } %runtime.interfaceMethodInfo = type { i8*, i32 } diff --git a/compiler/testdata/intrinsics-cortex-m-qemu.ll b/compiler/testdata/intrinsics-cortex-m-qemu.ll index e3e7580c7..52af02cf1 100644 --- a/compiler/testdata/intrinsics-cortex-m-qemu.ll +++ b/compiler/testdata/intrinsics-cortex-m-qemu.ll @@ -1,7 +1,7 @@ ; ModuleID = 'intrinsics.go' source_filename = "intrinsics.go" target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64" -target triple = "armv7m-none-eabi" +target triple = "armv7m-unknown-unknown-eabi" declare noalias nonnull i8* @runtime.alloc(i32, i8*, i8*) diff --git a/compiler/testdata/intrinsics-wasm.ll b/compiler/testdata/intrinsics-wasm.ll index 433b0a7e9..ebf5799c2 100644 --- a/compiler/testdata/intrinsics-wasm.ll +++ b/compiler/testdata/intrinsics-wasm.ll @@ -1,7 +1,7 @@ ; ModuleID = 'intrinsics.go' source_filename = "intrinsics.go" target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" -target triple = "wasm32--wasi" +target triple = "wasm32-unknown-wasi" declare noalias nonnull i8* @runtime.alloc(i32, i8*, i8*) diff --git a/compiler/testdata/pointer.ll b/compiler/testdata/pointer.ll index 94896ab8c..0561dddbe 100644 --- a/compiler/testdata/pointer.ll +++ b/compiler/testdata/pointer.ll @@ -1,7 +1,7 @@ ; ModuleID = 'pointer.go' source_filename = "pointer.go" target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" -target triple = "wasm32--wasi" +target triple = "wasm32-unknown-wasi" declare noalias nonnull i8* @runtime.alloc(i32, i8*, i8*) diff --git a/compiler/testdata/pragma.ll b/compiler/testdata/pragma.ll index 0515098c5..022626845 100644 --- a/compiler/testdata/pragma.ll +++ b/compiler/testdata/pragma.ll @@ -1,7 +1,7 @@ ; ModuleID = 'pragma.go' source_filename = "pragma.go" target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" -target triple = "wasm32--wasi" +target triple = "wasm32-unknown-wasi" @extern_global = external global [0 x i8], align 1 @main.alignedGlobal = hidden global [4 x i32] zeroinitializer, align 32 diff --git a/compiler/testdata/slice.ll b/compiler/testdata/slice.ll index 7d027fb8b..26701fe25 100644 --- a/compiler/testdata/slice.ll +++ b/compiler/testdata/slice.ll @@ -1,7 +1,7 @@ ; ModuleID = 'slice.go' source_filename = "slice.go" target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" -target triple = "wasm32--wasi" +target triple = "wasm32-unknown-wasi" declare noalias nonnull i8* @runtime.alloc(i32, i8*, i8*) diff --git a/compiler/testdata/string.ll b/compiler/testdata/string.ll index 66cf47818..06ae0ef1c 100644 --- a/compiler/testdata/string.ll +++ b/compiler/testdata/string.ll @@ -1,7 +1,7 @@ ; ModuleID = 'string.go' source_filename = "string.go" target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" -target triple = "wasm32--wasi" +target triple = "wasm32-unknown-wasi" %runtime._string = type { i8*, i32 } diff --git a/main_test.go b/main_test.go index 7ebf8eb03..d27bb7456 100644 --- a/main_test.go +++ b/main_test.go @@ -95,13 +95,13 @@ func TestCompiler(t *testing.T) { if runtime.GOOS == "linux" { t.Run("X86Linux", func(t *testing.T) { - runPlatTests("i386--linux-gnu", tests, t) + runPlatTests("i386-unknown-linux", tests, t) }) t.Run("ARMLinux", func(t *testing.T) { - runPlatTests("arm--linux-gnueabihf", tests, t) + runPlatTests("armv7-unknown-linux-gnueabihf", tests, t) }) t.Run("ARM64Linux", func(t *testing.T) { - runPlatTests("aarch64--linux-gnu", tests, t) + runPlatTests("aarch64-unknown-linux", tests, t) }) t.Run("WebAssembly", func(t *testing.T) { runPlatTests("wasm", tests, t) diff --git a/targets/avr.json b/targets/avr.json index 2ec83a7aa..fbf430645 100644 --- a/targets/avr.json +++ b/targets/avr.json @@ -1,5 +1,5 @@ { - "llvm-target": "avr-unknown-unknown", + "llvm-target": "avr", "build-tags": ["avr", "baremetal", "linux", "arm"], "goos": "linux", "goarch": "arm", @@ -8,7 +8,6 @@ "scheduler": "none", "default-stack-size": 256, "cflags": [ - "--target=avr-unknown-unknown", "-Werror" ], "ldflags": [ diff --git a/targets/cortex-m0.json b/targets/cortex-m0.json index f86945b87..221d1a44e 100644 --- a/targets/cortex-m0.json +++ b/targets/cortex-m0.json @@ -1,7 +1,4 @@ { "inherits": ["cortex-m"], - "llvm-target": "armv6m-none-eabi", - "cflags": [ - "--target=armv6m-none-eabi" - ] + "llvm-target": "armv6m-unknown-unknown-eabi" } diff --git a/targets/cortex-m0plus.json b/targets/cortex-m0plus.json index f86945b87..221d1a44e 100644 --- a/targets/cortex-m0plus.json +++ b/targets/cortex-m0plus.json @@ -1,7 +1,4 @@ { "inherits": ["cortex-m"], - "llvm-target": "armv6m-none-eabi", - "cflags": [ - "--target=armv6m-none-eabi" - ] + "llvm-target": "armv6m-unknown-unknown-eabi" } diff --git a/targets/cortex-m3.json b/targets/cortex-m3.json index 68ecb7fc8..b77a7f97a 100644 --- a/targets/cortex-m3.json +++ b/targets/cortex-m3.json @@ -1,7 +1,4 @@ { "inherits": ["cortex-m"], - "llvm-target": "armv7m-none-eabi", - "cflags": [ - "--target=armv7m-none-eabi" - ] + "llvm-target": "armv7m-unknown-unknown-eabi" } diff --git a/targets/cortex-m33.json b/targets/cortex-m33.json index db0f2516d..0dc79a5fc 100644 --- a/targets/cortex-m33.json +++ b/targets/cortex-m33.json @@ -1,8 +1,7 @@ { "inherits": ["cortex-m"], - "llvm-target": "armv7m-none-eabi", + "llvm-target": "armv7m-unknown-unknown-eabi", "cflags": [ - "--target=armv7m-none-eabi", "-mfloat-abi=soft" ] } diff --git a/targets/cortex-m4.json b/targets/cortex-m4.json index 1d5ce2b19..409a97d2d 100644 --- a/targets/cortex-m4.json +++ b/targets/cortex-m4.json @@ -1,8 +1,7 @@ { "inherits": ["cortex-m"], - "llvm-target": "armv7em-none-eabi", + "llvm-target": "armv7em-unknown-unknown-eabi", "cflags": [ - "--target=armv7em-none-eabi", "-mfloat-abi=soft" ] } diff --git a/targets/cortex-m7.json b/targets/cortex-m7.json index f63490eb2..efd1f302e 100644 --- a/targets/cortex-m7.json +++ b/targets/cortex-m7.json @@ -1,9 +1,8 @@ { "inherits": ["cortex-m"], - "llvm-target": "armv7em-none-eabi", + "llvm-target": "armv7em-unknown-unknown-eabi", "cpu": "cortex-m7", "cflags": [ - "--target=armv7em-none-eabi", "-mcpu=cortex-m7", "-mfloat-abi=soft" ] diff --git a/targets/gameboy-advance.json b/targets/gameboy-advance.json index e2d581594..77046954a 100644 --- a/targets/gameboy-advance.json +++ b/targets/gameboy-advance.json @@ -1,5 +1,5 @@ { - "llvm-target": "arm4-none-eabi", + "llvm-target": "arm4-unknown-unknown-eabi", "cpu": "arm7tdmi", "build-tags": ["gameboyadvance", "arm7tdmi", "baremetal", "linux", "arm"], "goos": "linux", @@ -8,7 +8,6 @@ "rtlib": "compiler-rt", "libc": "picolibc", "cflags": [ - "--target=arm4-none-eabi", "-mcpu=arm7tdmi", "-Werror", "-fshort-enums", diff --git a/targets/riscv32.json b/targets/riscv32.json index 24f5cee90..728fc3cc0 100644 --- a/targets/riscv32.json +++ b/targets/riscv32.json @@ -3,7 +3,6 @@ "llvm-target": "riscv32--none", "build-tags": ["tinygo.riscv32"], "cflags": [ - "--target=riscv32--none", "-march=rv32imac", "-mabi=ilp32" ], diff --git a/targets/riscv64.json b/targets/riscv64.json index a2a0641f9..58510f678 100644 --- a/targets/riscv64.json +++ b/targets/riscv64.json @@ -3,7 +3,6 @@ "llvm-target": "riscv64--none", "build-tags": ["tinygo.riscv64"], "cflags": [ - "--target=riscv64--none", "-march=rv64gc", "-mabi=lp64" ], diff --git a/targets/wasi.json b/targets/wasi.json index fd481b650..ab10cbda0 100644 --- a/targets/wasi.json +++ b/targets/wasi.json @@ -1,12 +1,11 @@ { - "llvm-target": "wasm32--wasi", + "llvm-target": "wasm32-unknown-wasi", "build-tags": ["tinygo.wasm", "wasi"], "goos": "linux", "goarch": "arm", "linker": "wasm-ld", "libc": "wasi-libc", "cflags": [ - "--target=wasm32--wasi", "--sysroot={root}/lib/wasi-libc/sysroot" ], "ldflags": [ diff --git a/targets/wasm.json b/targets/wasm.json index 083b62303..f7606c695 100644 --- a/targets/wasm.json +++ b/targets/wasm.json @@ -1,12 +1,11 @@ { - "llvm-target": "wasm32--wasi", + "llvm-target": "wasm32-unknown-wasi", "build-tags": ["tinygo.wasm"], "goos": "js", "goarch": "wasm", "linker": "wasm-ld", "libc": "wasi-libc", "cflags": [ - "--target=wasm32--wasi", "--sysroot={root}/lib/wasi-libc/sysroot" ], "ldflags": [ diff --git a/targets/xtensa.json b/targets/xtensa.json index 7fa24f5bd..32ac133f5 100644 --- a/targets/xtensa.json +++ b/targets/xtensa.json @@ -6,7 +6,6 @@ "gc": "conservative", "scheduler": "none", "cflags": [ - "--target=xtensa", "-Werror", "-fshort-enums", "-Wno-macro-redefined", |