aboutsummaryrefslogtreecommitdiffhomepage
path: root/targets
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2021-11-01 19:11:04 +0100
committerRon Evans <[email protected]>2021-11-03 23:03:44 +0100
commit29206cf0a4a8efcdabe50306090fe6125f6b2d0c (patch)
tree2df5e3376a0a8b026d6f819f35e2a80880c7b039 /targets
parentc2165f74d81a2ed1b1649e710b73f1c613a54185 (diff)
downloadtinygo-29206cf0a4a8efcdabe50306090fe6125f6b2d0c.tar.gz
tinygo-29206cf0a4a8efcdabe50306090fe6125f6b2d0c.zip
targets: add CPU property everywhere
This is for consistency with Clang, which always adds a CPU flag even if it's not specified in CFLAGS. This commit also adds some tests to make sure the Clang target-cpu matches the CPU property in the JSON files. This does have an effect on the generated binaries. The effect is very small though: on average just 0.2% increase in binary size, apparently because Cortex-M3 and Cortex-M4 are compiled a bit differently. However, when rebased on top of https://github.com/tinygo-org/tinygo/pull/2218 (minsize), the difference drops to -0.1% (a slight decrease on average).
Diffstat (limited to 'targets')
-rw-r--r--targets/atmega1280.json3
-rw-r--r--targets/atmega1284p.json3
-rw-r--r--targets/atmega2560.json3
-rw-r--r--targets/atmega328p.json3
-rw-r--r--targets/attiny85.json1
-rw-r--r--targets/cortex-m0.json3
-rw-r--r--targets/cortex-m0plus.json3
-rw-r--r--targets/cortex-m3.json3
-rw-r--r--targets/cortex-m4.json1
-rw-r--r--targets/cortex-m7.json1
-rw-r--r--targets/esp32.json3
-rw-r--r--targets/esp8266.json3
-rw-r--r--targets/fe310.json1
-rw-r--r--targets/gameboy-advance.json1
-rw-r--r--targets/nintendoswitch.json3
-rw-r--r--targets/wasi.json1
-rw-r--r--targets/wasm.json1
17 files changed, 11 insertions, 26 deletions
diff --git a/targets/atmega1280.json b/targets/atmega1280.json
index 2b0bfde7b..bf2e8c8bc 100644
--- a/targets/atmega1280.json
+++ b/targets/atmega1280.json
@@ -3,9 +3,6 @@
"cpu": "atmega1280",
"build-tags": ["atmega1280", "atmega"],
"serial": "uart",
- "cflags": [
- "-mmcu=atmega1280"
- ],
"ldflags": [
"-mmcu=avr51",
"-Wl,--defsym=_stack_size=512"
diff --git a/targets/atmega1284p.json b/targets/atmega1284p.json
index 3fbecd4b7..7740ccf1c 100644
--- a/targets/atmega1284p.json
+++ b/targets/atmega1284p.json
@@ -3,9 +3,6 @@
"cpu": "atmega1284p",
"build-tags": ["atmega1284p", "atmega"],
"serial": "uart",
- "cflags": [
- "-mmcu=atmega1284p"
- ],
"ldflags": [
"-mmcu=avr51",
"-Wl,--defsym=_bootloader_size=0",
diff --git a/targets/atmega2560.json b/targets/atmega2560.json
index 9caa088cf..d3b37418e 100644
--- a/targets/atmega2560.json
+++ b/targets/atmega2560.json
@@ -3,9 +3,6 @@
"cpu": "atmega2560",
"build-tags": ["atmega2560", "atmega"],
"serial": "uart",
- "cflags": [
- "-mmcu=atmega2560"
- ],
"ldflags": [
"-mmcu=avr6",
"-Wl,--defsym=_stack_size=512"
diff --git a/targets/atmega328p.json b/targets/atmega328p.json
index 24a272147..6a763b727 100644
--- a/targets/atmega328p.json
+++ b/targets/atmega328p.json
@@ -3,9 +3,6 @@
"cpu": "atmega328p",
"build-tags": ["atmega328p", "atmega", "avr5"],
"serial": "uart",
- "cflags": [
- "-mmcu=atmega328p"
- ],
"ldflags": [
"-mmcu=avr5"
],
diff --git a/targets/attiny85.json b/targets/attiny85.json
index 8cb4fcc0c..f28f4f84d 100644
--- a/targets/attiny85.json
+++ b/targets/attiny85.json
@@ -3,7 +3,6 @@
"cpu": "attiny85",
"build-tags": ["attiny85", "attiny", "avr2", "avr25"],
"cflags": [
- "-mmcu=attiny85",
"-D__AVR_ARCH__=25"
],
"ldflags": [
diff --git a/targets/cortex-m0.json b/targets/cortex-m0.json
index 221d1a44e..b1e943f05 100644
--- a/targets/cortex-m0.json
+++ b/targets/cortex-m0.json
@@ -1,4 +1,5 @@
{
"inherits": ["cortex-m"],
- "llvm-target": "armv6m-unknown-unknown-eabi"
+ "llvm-target": "armv6m-unknown-unknown-eabi",
+ "cpu": "cortex-m0"
}
diff --git a/targets/cortex-m0plus.json b/targets/cortex-m0plus.json
index 221d1a44e..7fef099b6 100644
--- a/targets/cortex-m0plus.json
+++ b/targets/cortex-m0plus.json
@@ -1,4 +1,5 @@
{
"inherits": ["cortex-m"],
- "llvm-target": "armv6m-unknown-unknown-eabi"
+ "llvm-target": "armv6m-unknown-unknown-eabi",
+ "cpu": "cortex-m0plus"
}
diff --git a/targets/cortex-m3.json b/targets/cortex-m3.json
index b77a7f97a..a2dc974ad 100644
--- a/targets/cortex-m3.json
+++ b/targets/cortex-m3.json
@@ -1,4 +1,5 @@
{
"inherits": ["cortex-m"],
- "llvm-target": "armv7m-unknown-unknown-eabi"
+ "llvm-target": "armv7m-unknown-unknown-eabi",
+ "cpu": "cortex-m3"
}
diff --git a/targets/cortex-m4.json b/targets/cortex-m4.json
index 409a97d2d..dd966d71a 100644
--- a/targets/cortex-m4.json
+++ b/targets/cortex-m4.json
@@ -1,6 +1,7 @@
{
"inherits": ["cortex-m"],
"llvm-target": "armv7em-unknown-unknown-eabi",
+ "cpu": "cortex-m4",
"cflags": [
"-mfloat-abi=soft"
]
diff --git a/targets/cortex-m7.json b/targets/cortex-m7.json
index efd1f302e..dbe11dfd9 100644
--- a/targets/cortex-m7.json
+++ b/targets/cortex-m7.json
@@ -3,7 +3,6 @@
"llvm-target": "armv7em-unknown-unknown-eabi",
"cpu": "cortex-m7",
"cflags": [
- "-mcpu=cortex-m7",
"-mfloat-abi=soft"
]
}
diff --git a/targets/esp32.json b/targets/esp32.json
index ded861624..9fc32b305 100644
--- a/targets/esp32.json
+++ b/targets/esp32.json
@@ -6,9 +6,6 @@
"serial": "uart",
"linker": "xtensa-esp32-elf-ld",
"default-stack-size": 2048,
- "cflags": [
- "-mcpu=esp32"
- ],
"rtlib": "compiler-rt",
"libc": "picolibc",
"linkerscript": "targets/esp32.ld",
diff --git a/targets/esp8266.json b/targets/esp8266.json
index e1304d245..cec09fdeb 100644
--- a/targets/esp8266.json
+++ b/targets/esp8266.json
@@ -5,9 +5,6 @@
"scheduler": "tasks",
"linker": "xtensa-esp32-elf-ld",
"default-stack-size": 2048,
- "cflags": [
- "-mcpu=esp8266"
- ],
"rtlib": "compiler-rt",
"libc": "picolibc",
"linkerscript": "targets/esp8266.ld",
diff --git a/targets/fe310.json b/targets/fe310.json
index 76f749705..c513a39f1 100644
--- a/targets/fe310.json
+++ b/targets/fe310.json
@@ -1,5 +1,6 @@
{
"inherits": ["riscv32"],
+ "cpu": "sifive-e31",
"features": ["+a", "+c", "+m"],
"build-tags": ["fe310", "sifive"]
}
diff --git a/targets/gameboy-advance.json b/targets/gameboy-advance.json
index 77046954a..c929ab764 100644
--- a/targets/gameboy-advance.json
+++ b/targets/gameboy-advance.json
@@ -8,7 +8,6 @@
"rtlib": "compiler-rt",
"libc": "picolibc",
"cflags": [
- "-mcpu=arm7tdmi",
"-Werror",
"-fshort-enums",
"-fomit-frame-pointer",
diff --git a/targets/nintendoswitch.json b/targets/nintendoswitch.json
index 6e3c44c7f..211b2b299 100644
--- a/targets/nintendoswitch.json
+++ b/targets/nintendoswitch.json
@@ -1,5 +1,6 @@
{
"llvm-target": "aarch64",
+ "cpu": "cortex-a57",
"build-tags": ["nintendoswitch", "arm64"],
"scheduler": "tasks",
"goos": "linux",
@@ -9,11 +10,9 @@
"libc": "picolibc",
"gc": "conservative",
"relocation-model": "pic",
- "cpu": "cortex-a57",
"default-stack-size": 2048,
"cflags": [
"-target", "aarch64-unknown-none",
- "-mcpu=cortex-a57",
"-fPIE",
"-Werror",
"-fshort-enums",
diff --git a/targets/wasi.json b/targets/wasi.json
index ab10cbda0..7826c48d1 100644
--- a/targets/wasi.json
+++ b/targets/wasi.json
@@ -1,5 +1,6 @@
{
"llvm-target": "wasm32-unknown-wasi",
+ "cpu": "generic",
"build-tags": ["tinygo.wasm", "wasi"],
"goos": "linux",
"goarch": "arm",
diff --git a/targets/wasm.json b/targets/wasm.json
index f7606c695..bfffc0058 100644
--- a/targets/wasm.json
+++ b/targets/wasm.json
@@ -1,5 +1,6 @@
{
"llvm-target": "wasm32-unknown-wasi",
+ "cpu": "generic",
"build-tags": ["tinygo.wasm"],
"goos": "js",
"goarch": "wasm",