Skip to content

Commit ade3cc9

Browse files
committed
build: use distro CFLAGS
Instead of using the default settings, use the ones used to build the distros. This should also catch more bugs due to FORTIFY and friends being enabled. Signed-off-by: Daniel Wagner <[email protected]>
1 parent e09fce3 commit ade3cc9

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,40 @@ jobs:
2525
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
2626
- name: build
2727
run: |
28+
if [ "${{ matrix.compiler }}" = "gcc" ]; then
29+
if [ "${{ matrix.distro }}" = "tumbleweed" ]; then
30+
BASE_FLAGS="-Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 \
31+
-fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables \
32+
-fstack-clash-protection -Werror -g"
33+
34+
if [ "${{ matrix.buildtype }}" = "release" ]; then
35+
export CFLAGS="-O2 ${BASE_FLAGS} -flto=auto"
36+
export LDFLAGS="-flto=auto"
37+
else
38+
export CFLAGS="-O0 ${BASE_FLAGS}"
39+
export LDFLAGS=""
40+
fi
41+
fi
42+
export CXXFLAGS="$CFLAGS"
43+
elif [ "${{ matrix.distro }}" = "fedora" ] && \
44+
[ "${{ matrix.buildtype }}" = "release" ]; then
45+
BASE_FLAGS="-O2 -flto=auto -ffat-lto-objects -fexceptions -g \
46+
-grecord-gcc-switches -pipe -Wall -Werror=format-security \
47+
-Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS \
48+
-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong \
49+
-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m32 -march=i686 -mtune=generic \
50+
-msse2 -mfpmath=sse -mstackrealign -fasynchronous-unwind-tables \
51+
-fstack-clash-protection"
52+
53+
export CFLAGS="$BASE_FLAGS"
54+
export CXXFLAGS="$BASE_FLAGS"
55+
export LDFLAGS='-Wl,-z,relro -Wl,--as-needed -Wl,-z,pack-relative-relocs \
56+
-Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld \
57+
-specs=/usr/lib/rpm/redhat/redhat-hardened-ld-errors \
58+
-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 \
59+
-Wl,--build-id=sha1 -specs=/usr/lib/rpm/redhat/redhat-package-notes'
60+
fi
61+
2862
scripts/build.sh -b ${{ matrix.buildtype }} -c ${{ matrix.compiler }} -x
2963
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
3064
name: upload logs

0 commit comments

Comments
 (0)