]> git.ipfire.org Git - people/ms/pakfire.git/commitdiff
macros: Update CFLAGS (again)
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 27 Nov 2022 11:52:14 +0000 (11:52 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 27 Nov 2022 11:52:14 +0000 (11:52 +0000)
This commit tidies up how we build the CFLAGS variable (as there is no
point in putting together an auxiliary variable first).

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
macros/cflags.macro

index b9405cb00b8a1673eb2e78a61ebb681078ccbf7a..7ab68f43e618350ceec64b9e2bf99a0034faf0a9 100644 (file)
@@ -1,27 +1,35 @@
+# Export CFLAGS
+export CFLAGS = # empty
 
-# Export CFLAGS + CXXFLAGS
-GLOBAL_CFLAGS = -O2 -g
+# Export CXXFLAGS
+export CXXFLAGS = %{CFLAGS}
+
+# Export LDFLAGS
+export LDFLAGS  = -Wl,-z,relro -Wl,-z,now
+
+# Enable optimisation and compile in debugging information
+CFLAGS = -O2 -g
 
 # Enable all compiler warnings
-GLOBAL_CFLAGS += -Wall
+CFLAGS += -Wall -Werror=format-security
 
 # Fortify Source
-GLOBAL_CFLAGS += -Wp,-U_FORTIFY_SOURCE-Wp,-D_FORTIFY_SOURCE=3
+CFLAGS += -Wp,-U_FORTIFY_SOURCE-Wp,-D_FORTIFY_SOURCE=3
 
 # Build Position Independent Code
-GLOBAL_CFLAGS += -fPIC
+CFLAGS += -fPIC
 
 # Enable Stack Smashing Protection
-GLOBAL_CFLAGS += -fstack-protector-strong
+CFLAGS += -fstack-protector-strong
 
 # Enable unwind tables
-GLOBAL_CFLAGS += -funwind-tables -fasynchronous-unwind-tables
+CFLAGS += -funwind-tables -fasynchronous-unwind-tables
 
 # Enable Stack Clash Protection
-GLOBAL_CFLAGS += -fstack-clash-protection
+CFLAGS += -fstack-clash-protection
 
 # Tell the compiler where the source will be put
-GLOBAL_CFLAGS += -fdebug-prefix-map=%{DIR_SRC}=%{debugsourcedir}
+CFLAGS += -fdebug-prefix-map=%{DIR_SRC}=%{debugsourcedir}
 
 # Arch: x86_64
 CFLAGS_x86_64 = -m64 -march=x86-64-v2 -mtune=generic
@@ -29,7 +37,9 @@ CFLAGS_x86_64 = -m64 -march=x86-64-v2 -mtune=generic
 # Arch: aarch64
 CFLAGS_aarch64 = -mbranch-protection=standard
 
-export CFLAGS   = %{GLOBAL_CFLAGS} %{CFLAGS_%{DISTRO_ARCH}}
-export CXXFLAGS = %{CFLAGS}
+# Append architecture optimisations
+CFLAGS += %{CFLAGS_%{DISTRO_ARCH}}
 
-export LDFLAGS  = -Wl,-z,relro -Wl,-z,now
+# Enable LTO
+LTO_CFLAGS = -flto=auto -ffat-lto-objects
+CFLAGS += %{LTO_CFLAGS}