From c1642e5a43de3affa75d52c3577ee1be4c874a5d Mon Sep 17 00:00:00 2001 From: jvoisin Date: Fri, 13 Mar 2026 01:07:17 +0100 Subject: Fixes compilation with clang and -D_FORTIFY_SOURCE=2 This commit fixes the typo pass_object_size__ for pass_object_size. It also adds tests in the CI to prevent this from happening again. Ref https://clang.llvm.org/docs/AttributeReference.html#pass-object-size-pass-dynamic-object-size Co-Authored-By: Sertonix --- .github/workflows/testsuite.yaml | 27 +++++++++++++++++++++++++++ include/fortify-headers.h | 2 +- tests/Makefile | 4 +++- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/.github/workflows/testsuite.yaml b/.github/workflows/testsuite.yaml index 8de273c..3185f0c 100644 --- a/.github/workflows/testsuite.yaml +++ b/.github/workflows/testsuite.yaml @@ -104,3 +104,30 @@ jobs: - name: Building with gcc shell: bash run: CFLAGS=-std=${{ matrix.version }} make -C tests clean gcc run + + fortify_level: + runs-on: ubuntu-latest + strategy: + matrix: + level: [2, 3] + steps: + - name: Checking out the code + uses: actions/checkout@v3 + - name: Cache musl toolchain + uses: actions/cache@v3 + id: cache-musl + with: + path: x86_64-linux-musl-native + key: musl + - name: Downloading musl-based toolchain + if: steps.cache-musl.outputs.cache-hit != 'true' + run: wget --quiet https://dustri.org/x86_64-linux-musl-native.tgz + - name: Extracting musl-based toolchain + if: steps.cache-musl.outputs.cache-hit != 'true' + run: tar xzf ./x86_64-linux-musl-native.tgz + - name: Building with clang + shell: bash + run: _FORTIFY_SOURCE=${{ matrix.level }} make -C tests clean clang + - name: Building with gcc + shell: bash + run: _FORTIFY_SOURCE=${{ matrix.level }} make -C tests clean gcc diff --git a/include/fortify-headers.h b/include/fortify-headers.h index c32d5fb..3dc33b7 100644 --- a/include/fortify-headers.h +++ b/include/fortify-headers.h @@ -23,7 +23,7 @@ #define _FORTIFY_POSN(n) const __attribute__((pass_dynamic_object_size(n))) #else /* clang uses overloads; see https://github.com/llvm/llvm-project/issues/53516 */ -#define _FORTIFY_POSN(n) const __attribute__((pass_object_size__(n))) +#define _FORTIFY_POSN(n) const __attribute__((pass_object_size(n))) #endif /* we can't use extern inline with overloads without making them external */ diff --git a/tests/Makefile b/tests/Makefile index b71c004..f2428f8 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,7 +1,9 @@ MACHINE := $(shell uname -m) +_FORTIFY_SOURCE ?= 3 CFLAGS ?= -std=gnu99 -CFLAGS += -I../include/ -D_FORTIFY_SOURCE=3 -static -O2 -Wall -Wextra -Werror -Werror=pointer-arith +CFLAGS += -I../include/ -D_FORTIFY_SOURCE=$(_FORTIFY_SOURCE) -static -O2 -Wall -Wextra -Werror -Werror=pointer-arith CFLAGS += -Wno-format -Wno-array-bounds -Wno-shift-count-negative -Wno-unused-variable -Wno-unused-parameter +CXXFLAGS += -D_FORTIFY_SOURCE=$(_FORTIFY_SOURCE) RUNTIME_TARGETS= \ test_FD_CLR_SETSIZE \ -- cgit v1.3