6 export CXXFLAGS = %{CFLAGS}
11 # Enable optimisation and compile in debugging information
14 # Enable all compiler warnings
17 # Fail on any string format security issues
18 STRING_FORMAT_SECURITY_CFLAGS = -Werror=format-security
19 CFLAGS += %{STRING_FORMAT_SECURITY_CFLAGS}
22 CFLAGS += -Wp,-U_FORTIFY_SOURCE -Wp,-D_FORTIFY_SOURCE=3
25 CFLAGS += -D_GLIBCXX_ASSERTIONS
27 # Build Position Independent Code
30 # Enable Stack Smashing Protection
31 CFLAGS += -fstack-protector-all
33 # Enable unwind tables
34 CFLAGS += -funwind-tables -fasynchronous-unwind-tables
36 # Enable Stack Clash Protection
37 CFLAGS += -fstack-clash-protection
39 # Tell the compiler where the source will be put
40 CFLAGS += -fdebug-prefix-map=%{DIR_SRC}=%{debugsourcedir}
42 # Avoid creating temporary files
46 CFLAGS_x86_64 = -m64 -march=x86-64-v2 -mtune=generic
48 # Enable Control Flow Technology (CET)
49 CFLAGS_x86_64 += -fcf-protection=full
52 CFLAGS_aarch64 = -mbranch-protection=standard
54 # Append architecture optimisations
55 CFLAGS += %{CFLAGS_%{DISTRO_ARCH}}
58 LTO_CFLAGS = -flto=auto -ffat-lto-objects
59 CFLAGS += %{LTO_CFLAGS}
61 # Optimise linked binaries https://lwn.net/Articles/192624/
64 # Only link what we actually need
65 LDFLAGS += -Wl,--as-needed
67 # Create an ELF "PT_GNU_RELRO" segment header in the object
68 LDFLAGS += -Wl,-z,relro
70 # When generating an executable or shared library, mark it to tell the
71 # dynamic linker to resolve all symbols when the program is started,
72 # or when the shared library is linked to using dlopen, instead of
73 # deferring function call resolution to the point when the function is
77 # Export default compilers
81 # Show libtool where to find any libraries
82 export LT_SYS_LIBRARY_PATH = %{libdir}: