From 611bca39ab6c083c6671af5b06f9b5742c829b69 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Fri, 9 Nov 2018 11:19:54 +0100 Subject: [PATCH] all: rename 'arm' to 'tinygo.arm' for Cortex-M Let the standard library think that it is compiling for js/wasm. The most correct way of supporting bare metal Cortex-M targets would be using the 'arm' build tag and specifying no OS or an 'undefined' OS (perhaps GOOS=noos?). However, there is no build tag for specifying no OS at all, the closest possible is GOOS=js which makes very few assumptions. Sadly GOOS=js also makes some assumptions: it assumes to be running with GOARCH=wasm. This would not be such a problem, just add js, wasm and arm as build tags. However, having two GOARCH build tags leads to an error in internal/cpu: it defines variables for both architectures which then conflict. To work around these problems, the 'arm' target has been renamed to 'tinygo.arm', which should work around these problems. In the future, a GOOS=noos (or similar) should be added which can work with any architecture and doesn't implement OS-specific stuff. --- src/runtime/{arch_arm.go => arch_tinygoarm.go} | 2 +- src/runtime/arch_wasm.go | 2 +- src/runtime/override_js.go | 2 +- src/runtime/{runtime_arm.go => runtime_tinygoarm.go} | 2 +- src/runtime/runtime_wasm.go | 2 +- targets/bluepill.json | 2 +- targets/microbit.json | 2 +- targets/nrf52840-mdk.json | 2 +- targets/pca10040.json | 2 +- targets/qemu.json | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) rename src/runtime/{arch_arm.go => arch_tinygoarm.go} (92%) rename src/runtime/{runtime_arm.go => runtime_tinygoarm.go} (98%) diff --git a/src/runtime/arch_arm.go b/src/runtime/arch_tinygoarm.go similarity index 92% rename from src/runtime/arch_arm.go rename to src/runtime/arch_tinygoarm.go index 46c2a09e..f3a8e6f3 100644 --- a/src/runtime/arch_arm.go +++ b/src/runtime/arch_tinygoarm.go @@ -1,4 +1,4 @@ -// +build arm +// +build tinygo.arm package runtime diff --git a/src/runtime/arch_wasm.go b/src/runtime/arch_wasm.go index bc48ce0b..38a12ed1 100644 --- a/src/runtime/arch_wasm.go +++ b/src/runtime/arch_wasm.go @@ -1,4 +1,4 @@ -// +build wasm,!arm,!avr +// +build wasm,!tinygo.arm,!avr package runtime diff --git a/src/runtime/override_js.go b/src/runtime/override_js.go index 47ca4da1..c21e7040 100644 --- a/src/runtime/override_js.go +++ b/src/runtime/override_js.go @@ -1,4 +1,4 @@ -// +build js,arm avr +// +build js,tinygo.arm avr package runtime diff --git a/src/runtime/runtime_arm.go b/src/runtime/runtime_tinygoarm.go similarity index 98% rename from src/runtime/runtime_arm.go rename to src/runtime/runtime_tinygoarm.go index 3debdd67..9003c893 100644 --- a/src/runtime/runtime_arm.go +++ b/src/runtime/runtime_tinygoarm.go @@ -1,4 +1,4 @@ -/// +build arm +// +build tinygo.arm package runtime diff --git a/src/runtime/runtime_wasm.go b/src/runtime/runtime_wasm.go index 8e58eec5..514ab8c8 100644 --- a/src/runtime/runtime_wasm.go +++ b/src/runtime/runtime_wasm.go @@ -1,4 +1,4 @@ -// +build wasm,!arm,!avr +// +build wasm,!tinygo.arm,!avr package runtime diff --git a/targets/bluepill.json b/targets/bluepill.json index ed3079b5..65b74b47 100644 --- a/targets/bluepill.json +++ b/targets/bluepill.json @@ -1,6 +1,6 @@ { "llvm-target": "armv7m-none-eabi", - "build-tags": ["bluepill", "stm32f103xx", "stm32", "arm", "js", "wasm"], + "build-tags": ["bluepill", "stm32f103xx", "stm32", "tinygo.arm", "js", "wasm"], "linker": "arm-none-eabi-gcc", "compiler-rt": true, "pre-link-args": ["-nostdlib", "-nostartfiles", "-mcpu=cortex-m3", "-mthumb", "-T", "targets/stm32.ld", "-Wl,--gc-sections", "-fno-exceptions", "-fno-unwind-tables", "-ffunction-sections", "-fdata-sections", "-Os", "src/device/stm32/stm32f103xx.s"], diff --git a/targets/microbit.json b/targets/microbit.json index de932934..810b2dc0 100644 --- a/targets/microbit.json +++ b/targets/microbit.json @@ -1,6 +1,6 @@ { "llvm-target": "armv6m-none-eabi", - "build-tags": ["microbit", "nrf51822", "nrf51", "nrf", "arm", "js", "wasm"], + "build-tags": ["microbit", "nrf51822", "nrf51", "nrf", "tinygo.arm", "js", "wasm"], "linker": "arm-none-eabi-gcc", "compiler-rt": true, "pre-link-args": [ diff --git a/targets/nrf52840-mdk.json b/targets/nrf52840-mdk.json index 15424c51..7be43642 100644 --- a/targets/nrf52840-mdk.json +++ b/targets/nrf52840-mdk.json @@ -1,6 +1,6 @@ { "llvm-target": "armv7em-none-eabi", - "build-tags": ["nrf52840_mdk", "nrf52840", "nrf", "arm", "js", "wasm"], + "build-tags": ["nrf52840_mdk", "nrf52840", "nrf", "tinygo.arm", "js", "wasm"], "linker": "arm-none-eabi-gcc", "pre-link-args": [ "-nostdlib", diff --git a/targets/pca10040.json b/targets/pca10040.json index dd9ba375..b003c2e0 100644 --- a/targets/pca10040.json +++ b/targets/pca10040.json @@ -1,6 +1,6 @@ { "llvm-target": "armv7em-none-eabi", - "build-tags": ["pca10040", "nrf52832", "nrf52", "nrf", "arm", "js", "wasm"], + "build-tags": ["pca10040", "nrf52832", "nrf52", "nrf", "tinygo.arm", "js", "wasm"], "linker": "arm-none-eabi-gcc", "compiler-rt": true, "pre-link-args": [ diff --git a/targets/qemu.json b/targets/qemu.json index 1fc2369c..7ed4a34a 100644 --- a/targets/qemu.json +++ b/targets/qemu.json @@ -1,6 +1,6 @@ { "llvm-target": "armv7m-none-eabi", - "build-tags": ["qemu", "lm3s6965", "arm", "js", "wasm"], + "build-tags": ["qemu", "lm3s6965", "tinygo.arm", "js", "wasm"], "linker": "arm-none-eabi-gcc", "compiler-rt": true, "pre-link-args": [