6 export CXXFLAGS = %{CFLAGS}
11 # Enable optimisation and compile in debugging information
14 # Enable all compiler warnings
15 CFLAGS += -Wall -Werror=format-security
18 CFLAGS += -Wp,-U_FORTIFY_SOURCE -Wp,-D_FORTIFY_SOURCE=3
20 # Build Position Independent Code
23 # Enable Stack Smashing Protection
24 CFLAGS += -fstack-protector-strong
26 # Enable unwind tables
27 CFLAGS += -funwind-tables -fasynchronous-unwind-tables
29 # Enable Stack Clash Protection
30 CFLAGS += -fstack-clash-protection
32 # Tell the compiler where the source will be put
33 CFLAGS += -fdebug-prefix-map=%{DIR_SRC}=%{debugsourcedir}
35 # Avoid creating temporary files
39 CFLAGS_x86_64 = -m64 -march=x86-64-v2 -mtune=generic
42 CFLAGS_aarch64 = -mbranch-protection=standard
44 # Append architecture optimisations
45 CFLAGS += %{CFLAGS_%{DISTRO_ARCH}}
48 LTO_CFLAGS = -flto=auto -ffat-lto-objects
49 CFLAGS += %{LTO_CFLAGS}
51 # Optimise linked binaries https://lwn.net/Articles/192624/
54 # Only link what we actually need
55 LDFLAGS += -Wl,--as-needed
57 # Create an ELF "PT_GNU_RELRO" segment header in the object
58 LDFLAGS += -Wl,-z,relro
60 # When generating an executable or shared library, mark it to tell the
61 # dynamic linker to resolve all symbols when the program is started,
62 # or when the shared library is linked to using dlopen, instead of
63 # deferring function call resolution to the point when the function is
67 # Export default compilers
71 # Show libtool where to find any libraries
72 export LT_SYS_LIBRARY_PATH = %{libdir}: