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).
This commit is contained in:
Ayke van Laethem
2021-11-01 19:11:04 +01:00
committed by Ron Evans
parent c2165f74d8
commit 29206cf0a4
21 changed files with 174 additions and 28 deletions
-3
View File
@@ -3,9 +3,6 @@
"cpu": "atmega1280",
"build-tags": ["atmega1280", "atmega"],
"serial": "uart",
"cflags": [
"-mmcu=atmega1280"
],
"ldflags": [
"-mmcu=avr51",
"-Wl,--defsym=_stack_size=512"
-3
View File
@@ -3,9 +3,6 @@
"cpu": "atmega1284p",
"build-tags": ["atmega1284p", "atmega"],
"serial": "uart",
"cflags": [
"-mmcu=atmega1284p"
],
"ldflags": [
"-mmcu=avr51",
"-Wl,--defsym=_bootloader_size=0",
-3
View File
@@ -3,9 +3,6 @@
"cpu": "atmega2560",
"build-tags": ["atmega2560", "atmega"],
"serial": "uart",
"cflags": [
"-mmcu=atmega2560"
],
"ldflags": [
"-mmcu=avr6",
"-Wl,--defsym=_stack_size=512"
-3
View File
@@ -3,9 +3,6 @@
"cpu": "atmega328p",
"build-tags": ["atmega328p", "atmega", "avr5"],
"serial": "uart",
"cflags": [
"-mmcu=atmega328p"
],
"ldflags": [
"-mmcu=avr5"
],
-1
View File
@@ -3,7 +3,6 @@
"cpu": "attiny85",
"build-tags": ["attiny85", "attiny", "avr2", "avr25"],
"cflags": [
"-mmcu=attiny85",
"-D__AVR_ARCH__=25"
],
"ldflags": [
+2 -1
View File
@@ -1,4 +1,5 @@
{
"inherits": ["cortex-m"],
"llvm-target": "armv6m-unknown-unknown-eabi"
"llvm-target": "armv6m-unknown-unknown-eabi",
"cpu": "cortex-m0"
}
+2 -1
View File
@@ -1,4 +1,5 @@
{
"inherits": ["cortex-m"],
"llvm-target": "armv6m-unknown-unknown-eabi"
"llvm-target": "armv6m-unknown-unknown-eabi",
"cpu": "cortex-m0plus"
}
+2 -1
View File
@@ -1,4 +1,5 @@
{
"inherits": ["cortex-m"],
"llvm-target": "armv7m-unknown-unknown-eabi"
"llvm-target": "armv7m-unknown-unknown-eabi",
"cpu": "cortex-m3"
}
+1
View File
@@ -1,6 +1,7 @@
{
"inherits": ["cortex-m"],
"llvm-target": "armv7em-unknown-unknown-eabi",
"cpu": "cortex-m4",
"cflags": [
"-mfloat-abi=soft"
]
-1
View File
@@ -3,7 +3,6 @@
"llvm-target": "armv7em-unknown-unknown-eabi",
"cpu": "cortex-m7",
"cflags": [
"-mcpu=cortex-m7",
"-mfloat-abi=soft"
]
}
-3
View File
@@ -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",
-3
View File
@@ -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",
+1
View File
@@ -1,5 +1,6 @@
{
"inherits": ["riscv32"],
"cpu": "sifive-e31",
"features": ["+a", "+c", "+m"],
"build-tags": ["fe310", "sifive"]
}
-1
View File
@@ -8,7 +8,6 @@
"rtlib": "compiler-rt",
"libc": "picolibc",
"cflags": [
"-mcpu=arm7tdmi",
"-Werror",
"-fshort-enums",
"-fomit-frame-pointer",
+1 -2
View File
@@ -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",
+1
View File
@@ -1,5 +1,6 @@
{
"llvm-target": "wasm32-unknown-wasi",
"cpu": "generic",
"build-tags": ["tinygo.wasm", "wasi"],
"goos": "linux",
"goarch": "arm",
+1
View File
@@ -1,5 +1,6 @@
{
"llvm-target": "wasm32-unknown-wasi",
"cpu": "generic",
"build-tags": ["tinygo.wasm"],
"goos": "js",
"goarch": "wasm",