From 6234bf9a88e26636f8867ff71ca986be952ea780 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Fri, 17 Sep 2021 01:43:14 +0200 Subject: [PATCH] all: use -opt flag for optimization level in CFlags (-Os, etc) This brings some consistency to the CFlags and fixes the issue that on some platforms (Linux, MacOS), no optimization level was set and therefore C files in packages were not optimized at all. --- compileopts/config.go | 2 ++ targets/cortex-m.json | 1 - targets/gameboy-advance.json | 1 - targets/riscv.json | 1 - targets/wasi.json | 3 +-- targets/wasm.json | 3 +-- targets/xtensa.json | 1 - 7 files changed, 4 insertions(+), 8 deletions(-) diff --git a/compileopts/config.go b/compileopts/config.go index 8f815ffb..4aa8ed5e 100644 --- a/compileopts/config.go +++ b/compileopts/config.go @@ -211,6 +211,8 @@ func (c *Config) CFlags() []string { } // Always emit debug information. It is optionally stripped at link time. cflags = append(cflags, "-g") + // Use the same optimization level as TinyGo. + cflags = append(cflags, "-O"+c.Options.Opt) return cflags } diff --git a/targets/cortex-m.json b/targets/cortex-m.json index 0021d03c..dacf2181 100644 --- a/targets/cortex-m.json +++ b/targets/cortex-m.json @@ -10,7 +10,6 @@ "automatic-stack-size": true, "default-stack-size": 2048, "cflags": [ - "-Oz", "-mthumb", "-Werror", "-fshort-enums", diff --git a/targets/gameboy-advance.json b/targets/gameboy-advance.json index 2eb8aaa8..e2d58159 100644 --- a/targets/gameboy-advance.json +++ b/targets/gameboy-advance.json @@ -10,7 +10,6 @@ "cflags": [ "--target=arm4-none-eabi", "-mcpu=arm7tdmi", - "-Oz", "-Werror", "-fshort-enums", "-fomit-frame-pointer", diff --git a/targets/riscv.json b/targets/riscv.json index 1ccf123a..4b78db60 100644 --- a/targets/riscv.json +++ b/targets/riscv.json @@ -7,7 +7,6 @@ "rtlib": "compiler-rt", "libc": "picolibc", "cflags": [ - "-Os", "-Werror", "-fno-exceptions", "-fno-unwind-tables", "-ffunction-sections", "-fdata-sections" diff --git a/targets/wasi.json b/targets/wasi.json index b80b77d1..fd481b65 100644 --- a/targets/wasi.json +++ b/targets/wasi.json @@ -7,8 +7,7 @@ "libc": "wasi-libc", "cflags": [ "--target=wasm32--wasi", - "--sysroot={root}/lib/wasi-libc/sysroot", - "-Oz" + "--sysroot={root}/lib/wasi-libc/sysroot" ], "ldflags": [ "--allow-undefined", diff --git a/targets/wasm.json b/targets/wasm.json index eb03eb8c..083b6230 100644 --- a/targets/wasm.json +++ b/targets/wasm.json @@ -7,8 +7,7 @@ "libc": "wasi-libc", "cflags": [ "--target=wasm32--wasi", - "--sysroot={root}/lib/wasi-libc/sysroot", - "-Oz" + "--sysroot={root}/lib/wasi-libc/sysroot" ], "ldflags": [ "--allow-undefined", diff --git a/targets/xtensa.json b/targets/xtensa.json index 6ebfc4e9..7fa24f5b 100644 --- a/targets/xtensa.json +++ b/targets/xtensa.json @@ -7,7 +7,6 @@ "scheduler": "none", "cflags": [ "--target=xtensa", - "-Oz", "-Werror", "-fshort-enums", "-Wno-macro-redefined",