]> git.ipfire.org Git - pakfire.git/blame - macros/cflags.macro
FHS: Drop /usr/bin/su from list of allowed SUID binaries
[pakfire.git] / macros / cflags.macro
CommitLineData
36bd8319
MT
1build
2 # Export CFLAGS
4026d3a0 3 export CFLAGS =
fa913867 4
36bd8319
MT
5 # Export CXXFLAGS
6 export CXXFLAGS = %{CFLAGS}
f1db4356 7
36bd8319 8 # Export LDFLAGS
4026d3a0 9 export LDFLAGS =
f1db4356 10
36bd8319
MT
11 # Enable optimisation and compile in debugging information
12 CFLAGS = -O2 -g
77539420 13
36bd8319 14 # Enable all compiler warnings
b1964236
MT
15 CFLAGS += -Wall
16
17 # Fail on any string format security issues
18 STRING_FORMAT_SECURITY_CFLAGS = -Werror=format-security
19 CFLAGS += %{STRING_FORMAT_SECURITY_CFLAGS}
77539420 20
36bd8319
MT
21 # Fortify Source
22 CFLAGS += -Wp,-U_FORTIFY_SOURCE -Wp,-D_FORTIFY_SOURCE=3
77539420 23
32636d17
MT
24 # libstc++ Assertions
25 CFLAGS += -D_GLIBCXX_ASSERTIONS
26
36bd8319
MT
27 # Build Position Independent Code
28 CFLAGS += -fPIC
77539420 29
36bd8319 30 # Enable Stack Smashing Protection
f1153a85 31 CFLAGS += -fstack-protector-all
77539420 32
36bd8319
MT
33 # Enable unwind tables
34 CFLAGS += -funwind-tables -fasynchronous-unwind-tables
77539420 35
36bd8319
MT
36 # Enable Stack Clash Protection
37 CFLAGS += -fstack-clash-protection
77539420 38
36bd8319
MT
39 # Tell the compiler where the source will be put
40 CFLAGS += -fdebug-prefix-map=%{DIR_SRC}=%{debugsourcedir}
77539420 41
d4cf91a8
MT
42 # Avoid creating temporary files
43 CFLAGS += -pipe
44
36bd8319
MT
45 # Arch: x86_64
46 CFLAGS_x86_64 = -m64 -march=x86-64-v2 -mtune=generic
77539420 47
60853ed1
MT
48 # Enable Control Flow Technology (CET)
49 CFLAGS_x86_64 += -fcf-protection=full
50
36bd8319
MT
51 # Arch: aarch64
52 CFLAGS_aarch64 = -mbranch-protection=standard
fa913867 53
36bd8319
MT
54 # Append architecture optimisations
55 CFLAGS += %{CFLAGS_%{DISTRO_ARCH}}
90d30d4e 56
36bd8319
MT
57 # Enable LTO
58 LTO_CFLAGS = -flto=auto -ffat-lto-objects
59 CFLAGS += %{LTO_CFLAGS}
89b8cbc7 60
4026d3a0
MT
61 # Optimise linked binaries https://lwn.net/Articles/192624/
62 LDFLAGS += -Wl,-O1
63
64 # Only link what we actually need
65 LDFLAGS += -Wl,--as-needed
66
67 # Create an ELF "PT_GNU_RELRO" segment header in the object
68 LDFLAGS += -Wl,-z,relro
69
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
74 # first called.
75 LDFLAGS += -Wl,-z,now
76
89b8cbc7
MT
77 # Export default compilers
78 export CC = gcc
79 export CXX = g++
9c275524
MT
80
81 # Show libtool where to find any libraries
82 export LT_SYS_LIBRARY_PATH = %{libdir}:
36bd8319 83end