From f02766265ced8b90444ce0382a6d1cc5196d7c30 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Mon, 19 Nov 2018 20:17:42 +0100 Subject: [PATCH] targets: make compiler runtime selection more configurable --- main.go | 4 ++-- target.go | 2 +- targets/bluepill.json | 2 +- targets/microbit.json | 2 +- targets/pca10040.json | 2 +- targets/qemu.json | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index 91e4e965..e87636d6 100644 --- a/main.go +++ b/main.go @@ -153,7 +153,7 @@ func Compile(pkgName, outpath string, spec *TargetSpec, config *BuildConfig, act // Load builtins library from the cache, possibly compiling it on the // fly. var cachePath string - if spec.CompilerRT { + if spec.RTLib == "compiler-rt" { librt, err := loadBuiltins(spec.Triple) if err != nil { return err @@ -165,7 +165,7 @@ func Compile(pkgName, outpath string, spec *TargetSpec, config *BuildConfig, act executable := filepath.Join(dir, "main") tmppath := executable // final file args := append(spec.PreLinkArgs, "-o", executable, objfile) - if spec.CompilerRT { + if spec.RTLib == "compiler-rt" { args = append(args, "-L", cachePath, "-lrt-"+spec.Triple) } cmd := exec.Command(spec.Linker, args...) diff --git a/target.go b/target.go index 96845759..b67eddff 100644 --- a/target.go +++ b/target.go @@ -20,7 +20,7 @@ type TargetSpec struct { Triple string `json:"llvm-target"` BuildTags []string `json:"build-tags"` Linker string `json:"linker"` - CompilerRT bool `json:"compiler-rt"` + RTLib string `json:"rtlib"` // compiler runtime library (libgcc, compiler-rt) PreLinkArgs []string `json:"pre-link-args"` Objcopy string `json:"objcopy"` Emulator []string `json:"emulator"` diff --git a/targets/bluepill.json b/targets/bluepill.json index 65b74b47..cded74db 100644 --- a/targets/bluepill.json +++ b/targets/bluepill.json @@ -2,7 +2,7 @@ "llvm-target": "armv7m-none-eabi", "build-tags": ["bluepill", "stm32f103xx", "stm32", "tinygo.arm", "js", "wasm"], "linker": "arm-none-eabi-gcc", - "compiler-rt": true, + "rtlib": "compiler-rt", "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"], "objcopy": "arm-none-eabi-objcopy", "flash": "openocd -f interface/stlink-v2.cfg -f target/stm32f1x.cfg -c 'program {hex} reset exit'" diff --git a/targets/microbit.json b/targets/microbit.json index 810b2dc0..e9e5ec9b 100644 --- a/targets/microbit.json +++ b/targets/microbit.json @@ -2,7 +2,7 @@ "llvm-target": "armv6m-none-eabi", "build-tags": ["microbit", "nrf51822", "nrf51", "nrf", "tinygo.arm", "js", "wasm"], "linker": "arm-none-eabi-gcc", - "compiler-rt": true, + "rtlib": "compiler-rt", "pre-link-args": [ "-nostdlib", "-nostartfiles", diff --git a/targets/pca10040.json b/targets/pca10040.json index b003c2e0..0a3cbb4e 100644 --- a/targets/pca10040.json +++ b/targets/pca10040.json @@ -2,7 +2,7 @@ "llvm-target": "armv7em-none-eabi", "build-tags": ["pca10040", "nrf52832", "nrf52", "nrf", "tinygo.arm", "js", "wasm"], "linker": "arm-none-eabi-gcc", - "compiler-rt": true, + "rtlib": "compiler-rt", "pre-link-args": [ "-nostdlib", "-nostartfiles", diff --git a/targets/qemu.json b/targets/qemu.json index 7ed4a34a..cd0ecaf5 100644 --- a/targets/qemu.json +++ b/targets/qemu.json @@ -2,7 +2,7 @@ "llvm-target": "armv7m-none-eabi", "build-tags": ["qemu", "lm3s6965", "tinygo.arm", "js", "wasm"], "linker": "arm-none-eabi-gcc", - "compiler-rt": true, + "rtlib": "compiler-rt", "pre-link-args": [ "-nostdlib", "-nostartfiles",