diff options
author | Ayke van Laethem <[email protected]> | 2021-04-14 02:23:01 +0200 |
---|---|---|
committer | Ron Evans <[email protected]> | 2021-04-14 09:17:54 +0200 |
commit | 96b1b76483a99647cc12b1c0f1d15c95f1d54025 (patch) | |
tree | 2ec04409d460e7dc21ca2cfbf3775104a8010035 | |
parent | f234df7a50e6377adc3cf0133e847f48e9f2aaa2 (diff) | |
download | tinygo-96b1b76483a99647cc12b1c0f1d15c95f1d54025.tar.gz tinygo-96b1b76483a99647cc12b1c0f1d15c95f1d54025.zip |
all: use -Qunused-arguments only for assembly files
The -Qunused-arguments flag disables the warning where some flags are
not relevant to a compilation. This commonly happens when compiling
assembly files (.s or .S files) because some flags are specific to C and
not relevant to assembly.
Because practically all baremetal targets need some form of assembly,
this flag is added to most CFlags. This creates a lot of noise. And it
is also added for compiling C code where it might hide bugs (by hiding
the fact a flag is actually unused).
This commit adds the flag to all assembly compilations and removes them
from all target JSON files.
29 files changed, 20 insertions, 53 deletions
diff --git a/builder/cc.go b/builder/cc.go index 0261fdb4c..f9bdbaf19 100644 --- a/builder/cc.go +++ b/builder/cc.go @@ -124,6 +124,13 @@ func compileAndCacheCFile(abspath, tmpdir string, cflags []string, config *compi flags := append([]string{}, cflags...) // copy cflags flags = append(flags, "-MD", "-MV", "-MTdeps", "-MF", depTmpFile.Name()) // autogenerate dependencies flags = append(flags, "-c", "-o", objTmpFile.Name(), abspath) + if strings.ToLower(filepath.Ext(abspath)) == ".s" { + // If this is an assembly file (.s or .S, lowercase or uppercase), then + // we'll need to add -Qunused-arguments because many parameters are + // relevant to C, not assembly. And with -Werror, having meaningless + // flags (for the assembler) is a compiler error. + flags = append(flags, "-Qunused-arguments") + } if config.Options.PrintCommands { fmt.Printf("%s %s\n", config.Target.Compiler, strings.Join(flags, " ")) } diff --git a/targets/atsamd21e18a.json b/targets/atsamd21e18a.json index e185c1d36..3b35a7b7c 100644 --- a/targets/atsamd21e18a.json +++ b/targets/atsamd21e18a.json @@ -3,8 +3,7 @@ "llvm-target": "armv6m-none-eabi", "build-tags": ["atsamd21e18a", "atsamd21e18", "atsamd21", "sam"], "cflags": [ - "--target=armv6m-none-eabi", - "-Qunused-arguments" + "--target=armv6m-none-eabi" ], "linkerscript": "targets/atsamd21.ld", "extra-files": [ diff --git a/targets/atsamd21g18a.json b/targets/atsamd21g18a.json index c04c31883..f9b8a540b 100644 --- a/targets/atsamd21g18a.json +++ b/targets/atsamd21g18a.json @@ -3,8 +3,7 @@ "llvm-target": "armv6m-none-eabi", "build-tags": ["atsamd21g18a", "atsamd21g18", "atsamd21", "sam"], "cflags": [ - "--target=armv6m-none-eabi", - "-Qunused-arguments" + "--target=armv6m-none-eabi" ], "linkerscript": "targets/atsamd21.ld", "extra-files": [ diff --git a/targets/atsamd51g19a.json b/targets/atsamd51g19a.json index a5f50309c..4534d1c1a 100644 --- a/targets/atsamd51g19a.json +++ b/targets/atsamd51g19a.json @@ -1,9 +1,6 @@ { "inherits": ["cortex-m4"], "build-tags": ["atsamd51g19a", "atsamd51g19", "atsamd51", "sam"], - "cflags": [ - "-Qunused-arguments" - ], "linkerscript": "targets/atsamd51.ld", "extra-files": [ "src/device/sam/atsamd51g19a.s" diff --git a/targets/atsamd51j19a.json b/targets/atsamd51j19a.json index 32ae341d0..2493ca4dd 100644 --- a/targets/atsamd51j19a.json +++ b/targets/atsamd51j19a.json @@ -1,9 +1,6 @@ { "inherits": ["cortex-m4"], "build-tags": ["atsamd51j19a", "atsamd51j19", "atsamd51", "sam"], - "cflags": [ - "-Qunused-arguments" - ], "linkerscript": "targets/atsamd51.ld", "extra-files": [ "src/device/sam/atsamd51j19a.s" diff --git a/targets/atsamd51j20a.json b/targets/atsamd51j20a.json index 40893bc96..9f59e32d4 100644 --- a/targets/atsamd51j20a.json +++ b/targets/atsamd51j20a.json @@ -1,9 +1,6 @@ { "inherits": ["cortex-m4"], "build-tags": ["sam", "atsamd51", "atsamd51j20", "atsamd51j20a"], - "cflags": [ - "-Qunused-arguments" - ], "linkerscript": "targets/atsamd51j20a.ld", "extra-files": [ "src/device/sam/atsamd51j20a.s" diff --git a/targets/atsamd51p19a.json b/targets/atsamd51p19a.json index f8d664e33..6b2f6b5b3 100644 --- a/targets/atsamd51p19a.json +++ b/targets/atsamd51p19a.json @@ -1,9 +1,6 @@ { "inherits": ["cortex-m4"], "build-tags": ["atsamd51p19a", "atsamd51p19", "atsamd51", "sam"], - "cflags": [ - "-Qunused-arguments" - ], "linkerscript": "targets/atsamd51.ld", "extra-files": [ "src/device/sam/atsamd51p19a.s" diff --git a/targets/atsamd51p20a.json b/targets/atsamd51p20a.json index bf5aa3ce0..bc66ca032 100644 --- a/targets/atsamd51p20a.json +++ b/targets/atsamd51p20a.json @@ -1,9 +1,6 @@ { "inherits": ["cortex-m4"], "build-tags": ["sam", "atsamd51", "atsamd51p20", "atsamd51p20a"], - "cflags": [ - "-Qunused-arguments" - ], "linkerscript": "targets/atsamd51p20a.ld", "extra-files": [ "src/device/sam/atsamd51p20a.s" diff --git a/targets/attiny85.json b/targets/attiny85.json index 0e0abda5d..8cb4fcc0c 100644 --- a/targets/attiny85.json +++ b/targets/attiny85.json @@ -4,8 +4,7 @@ "build-tags": ["attiny85", "attiny", "avr2", "avr25"], "cflags": [ "-mmcu=attiny85", - "-D__AVR_ARCH__=25", - "-Qunused-arguments" + "-D__AVR_ARCH__=25" ], "ldflags": [ "-mmcu=avr25" diff --git a/targets/avr.json b/targets/avr.json index 10aca60f1..ae1385ce5 100644 --- a/targets/avr.json +++ b/targets/avr.json @@ -9,7 +9,8 @@ "scheduler": "none", "default-stack-size": 256, "cflags": [ - "--target=avr-unknown-unknown" + "--target=avr-unknown-unknown", + "-Werror" ], "ldflags": [ "-T", "targets/avr.ld", diff --git a/targets/bluepill.json b/targets/bluepill.json index bcec1d72e..1bd029a39 100644 --- a/targets/bluepill.json +++ b/targets/bluepill.json @@ -3,8 +3,7 @@ "llvm-target": "armv7m-none-eabi", "build-tags": ["bluepill", "stm32f103", "stm32f1", "stm32"], "cflags": [ - "--target=armv7m-none-eabi", - "-Qunused-arguments" + "--target=armv7m-none-eabi" ], "linkerscript": "targets/stm32.ld", "extra-files": [ diff --git a/targets/cortex-m-qemu.json b/targets/cortex-m-qemu.json index 03d688a36..6d384c743 100644 --- a/targets/cortex-m-qemu.json +++ b/targets/cortex-m-qemu.json @@ -3,8 +3,7 @@ "llvm-target": "armv7m-none-eabi", "build-tags": ["qemu", "lm3s6965"], "cflags": [ - "--target=armv7m-none-eabi", - "-Qunused-arguments" + "--target=armv7m-none-eabi" ], "linkerscript": "targets/lm3s6965.ld", "extra-files": [ diff --git a/targets/cortex-m0.json b/targets/cortex-m0.json index 8cbbe2850..f86945b87 100644 --- a/targets/cortex-m0.json +++ b/targets/cortex-m0.json @@ -2,7 +2,6 @@ "inherits": ["cortex-m"], "llvm-target": "armv6m-none-eabi", "cflags": [ - "--target=armv6m-none-eabi", - "-Qunused-arguments" + "--target=armv6m-none-eabi" ] } diff --git a/targets/cortex-m33.json b/targets/cortex-m33.json index 8e4a893c5..db0f2516d 100644 --- a/targets/cortex-m33.json +++ b/targets/cortex-m33.json @@ -3,7 +3,6 @@ "llvm-target": "armv7m-none-eabi", "cflags": [ "--target=armv7m-none-eabi", - "-mfloat-abi=soft", - "-Qunused-arguments" + "-mfloat-abi=soft" ] } diff --git a/targets/cortex-m4.json b/targets/cortex-m4.json index cd6f9a5e1..1d5ce2b19 100644 --- a/targets/cortex-m4.json +++ b/targets/cortex-m4.json @@ -3,7 +3,6 @@ "llvm-target": "armv7em-none-eabi", "cflags": [ "--target=armv7em-none-eabi", - "-mfloat-abi=soft", - "-Qunused-arguments" + "-mfloat-abi=soft" ] } diff --git a/targets/cortex-m7.json b/targets/cortex-m7.json index 9b0097581..dcaa42577 100644 --- a/targets/cortex-m7.json +++ b/targets/cortex-m7.json @@ -2,7 +2,6 @@ "inherits": ["cortex-m"], "llvm-target": "armv7em-none-eabi", "cflags": [ - "--target=armv7em-none-eabi", - "-Qunused-arguments" + "--target=armv7em-none-eabi" ] } diff --git a/targets/feather-stm32f405.json b/targets/feather-stm32f405.json index 311ba9207..0e86cd4c5 100644 --- a/targets/feather-stm32f405.json +++ b/targets/feather-stm32f405.json @@ -3,9 +3,6 @@ "build-tags": ["feather_stm32f405", "stm32f405", "stm32f4", "stm32"], "automatic-stack-size": false, "default-stack-size": 1024, - "cflags": [ - "-Qunused-arguments" - ], "linkerscript": "targets/stm32f405.ld", "extra-files": [ "src/device/stm32/stm32f405.s" diff --git a/targets/gameboy-advance.json b/targets/gameboy-advance.json index 9fcdb30af..1e1eb1e02 100644 --- a/targets/gameboy-advance.json +++ b/targets/gameboy-advance.json @@ -15,7 +15,6 @@ "-Werror", "-fshort-enums", "-fomit-frame-pointer", - "-Qunused-arguments", "-fno-exceptions", "-fno-unwind-tables", "-ffunction-sections", "-fdata-sections" ], diff --git a/targets/nintendoswitch.json b/targets/nintendoswitch.json index b7bc5bcd4..847859ea7 100644 --- a/targets/nintendoswitch.json +++ b/targets/nintendoswitch.json @@ -15,7 +15,6 @@ "-mcpu=cortex-a57", "-fPIE", "-Werror", - "-Qunused-arguments", "-fshort-enums", "-fomit-frame-pointer", "-fno-exceptions", "-fno-unwind-tables", diff --git a/targets/nrf51.json b/targets/nrf51.json index f8870bc9a..2327d39f7 100644 --- a/targets/nrf51.json +++ b/targets/nrf51.json @@ -4,7 +4,6 @@ "build-tags": ["nrf51822", "nrf51", "nrf"], "cflags": [ "--target=armv6m-none-eabi", - "-Qunused-arguments", "-DNRF51", "-I{root}/lib/CMSIS/CMSIS/Include", "-I{root}/lib/nrfx/mdk" diff --git a/targets/nrf52.json b/targets/nrf52.json index 765fee23f..3248ef731 100644 --- a/targets/nrf52.json +++ b/targets/nrf52.json @@ -2,7 +2,6 @@ "inherits": ["cortex-m4"], "build-tags": ["nrf52", "nrf"], "cflags": [ - "-Qunused-arguments", "-DNRF52832_XXAA", "-I{root}/lib/CMSIS/CMSIS/Include", "-I{root}/lib/nrfx/mdk" diff --git a/targets/nrf52833.json b/targets/nrf52833.json index a1c88a6f2..54304dbc6 100644 --- a/targets/nrf52833.json +++ b/targets/nrf52833.json @@ -2,7 +2,6 @@ "inherits": ["cortex-m4"], "build-tags": ["nrf52833", "nrf"], "cflags": [ - "-Qunused-arguments", "-DNRF52833_XXAA", "-I{root}/lib/CMSIS/CMSIS/Include", "-I{root}/lib/nrfx/mdk" diff --git a/targets/nrf52840.json b/targets/nrf52840.json index c8470c655..9d86a6503 100644 --- a/targets/nrf52840.json +++ b/targets/nrf52840.json @@ -2,7 +2,6 @@ "inherits": ["cortex-m4"], "build-tags": ["nrf52840", "nrf"], "cflags": [ - "-Qunused-arguments", "-DNRF52840_XXAA", "-I{root}/lib/CMSIS/CMSIS/Include", "-I{root}/lib/nrfx/mdk" diff --git a/targets/nucleo-f103rb.json b/targets/nucleo-f103rb.json index 0e7a92245..10c9b2a6f 100644 --- a/targets/nucleo-f103rb.json +++ b/targets/nucleo-f103rb.json @@ -3,8 +3,7 @@ "llvm-target": "armv7m-none-eabi", "build-tags": ["nucleof103rb", "stm32f103", "stm32f1","stm32"], "cflags": [ - "--target=armv7m-none-eabi", - "-Qunused-arguments" + "--target=armv7m-none-eabi" ], "linkerscript": "targets/stm32f103rb.ld", "extra-files": [ diff --git a/targets/stm32f4disco.json b/targets/stm32f4disco.json index 0a1a3c1bb..622c5b0d6 100644 --- a/targets/stm32f4disco.json +++ b/targets/stm32f4disco.json @@ -1,9 +1,6 @@ { "inherits": ["cortex-m4"], "build-tags": ["stm32f4disco", "stm32f407", "stm32f4", "stm32"], - "cflags": [ - "-Qunused-arguments" - ], "linkerscript": "targets/stm32f407.ld", "extra-files": [ "src/device/stm32/stm32f407.s" diff --git a/targets/stm32l0x2.json b/targets/stm32l0x2.json index 666441fb1..78389f379 100644 --- a/targets/stm32l0x2.json +++ b/targets/stm32l0x2.json @@ -9,8 +9,7 @@ "stm32" ], "cflags": [ - "--target=armv6m-none-eabi", - "-Qunused-arguments" + "--target=armv6m-none-eabi" ], "extra-files": [ "src/device/stm32/stm32l0x2.s" diff --git a/targets/teensy36.json b/targets/teensy36.json index 473aec2eb..de9e6dc0f 100644 --- a/targets/teensy36.json +++ b/targets/teensy36.json @@ -5,7 +5,6 @@ "build-tags": ["teensy36", "teensy", "mk66f18", "nxp"], "cflags": [ "--target=armv7em-none-eabi", - "-Qunused-arguments", "-mfloat-abi=hard", "-mfpu=fpv4-sp-d16" ], diff --git a/targets/teensy40.json b/targets/teensy40.json index 575d5d19e..0ecb0353a 100644 --- a/targets/teensy40.json +++ b/targets/teensy40.json @@ -7,7 +7,6 @@ "default-stack-size": 4096, "cflags": [ "--target=armv7em-none-eabi", - "-Qunused-arguments", "-mfloat-abi=soft" ], "linkerscript": "targets/mimxrt1062-teensy40.ld", diff --git a/targets/xtensa.json b/targets/xtensa.json index 276a8131e..f4b57b0eb 100644 --- a/targets/xtensa.json +++ b/targets/xtensa.json @@ -12,7 +12,6 @@ "-Werror", "-fshort-enums", "-Wno-macro-redefined", - "-Qunused-arguments", "-fno-exceptions", "-fno-unwind-tables", "-ffunction-sections", "-fdata-sections" ], |