]> git.ipfire.org Git - people/stevee/pakfire.git/blobdiff - macros/cflags.macro
macros: Update CFLAGS (again)
[people/stevee/pakfire.git] / macros / cflags.macro
index 5dee6f886f7f130da83d2f8ea1d8b6a0c188790d..7ab68f43e618350ceec64b9e2bf99a0034faf0a9 100644 (file)
@@ -1,13 +1,45 @@
+# Export CFLAGS
+export CFLAGS = # empty
 
-# Export CFLAGS + CXXFLAGS
-GLOBAL_CFLAGS   = -O2 -g -pipe -Wall -fexceptions --param=ssp-buffer-size=4
+# Export CXXFLAGS
+export CXXFLAGS = %{CFLAGS}
 
-CFLAGS_i686     = -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables
-CFLAGS_x86_64   = -m64 -mtune=generic
-CFLAGS_armv5tel = -march=armv5te -mfloat-abi=soft
-CFLAGS_armv7hl  = -march=armv7-a -mfpu=vfpv3-d16  -mfloat-abi=hard -mthumb
+# Export LDFLAGS
+export LDFLAGS  = -Wl,-z,relro -Wl,-z,now
 
-export CFLAGS   = %{GLOBAL_CFLAGS} %{CFLAGS_%{DISTRO_ARCH}}
-export CXXFLAGS = %{CFLAGS}
+# Enable optimisation and compile in debugging information
+CFLAGS = -O2 -g
+
+# Enable all compiler warnings
+CFLAGS += -Wall -Werror=format-security
+
+# Fortify Source
+CFLAGS += -Wp,-U_FORTIFY_SOURCE-Wp,-D_FORTIFY_SOURCE=3
+
+# Build Position Independent Code
+CFLAGS += -fPIC
+
+# Enable Stack Smashing Protection
+CFLAGS += -fstack-protector-strong
+
+# Enable unwind tables
+CFLAGS += -funwind-tables -fasynchronous-unwind-tables
+
+# Enable Stack Clash Protection
+CFLAGS += -fstack-clash-protection
+
+# Tell the compiler where the source will be put
+CFLAGS += -fdebug-prefix-map=%{DIR_SRC}=%{debugsourcedir}
+
+# Arch: x86_64
+CFLAGS_x86_64 = -m64 -march=x86-64-v2 -mtune=generic
+
+# Arch: aarch64
+CFLAGS_aarch64 = -mbranch-protection=standard
+
+# Append architecture optimisations
+CFLAGS += %{CFLAGS_%{DISTRO_ARCH}}
 
-export LDFLAGS  =
+# Enable LTO
+LTO_CFLAGS = -flto=auto -ffat-lto-objects
+CFLAGS += %{LTO_CFLAGS}