From: Wander Lairson Costa <wander@redhat.com>
To: williams@redhat.com
Cc: linux-rt-users@vger.kernel.org,
Wander Lairson Costa <wander@redhat.com>,
Derek Barbosa <debarbos@redhat.com>,
John Kacur <jkacur@redhat.com>,
Juri Lelli <juri.lelli@redhat.com>,
Chunsheng Luo <luochunsheng@ustc.edu>
Subject: [PATCH 2/3] Makefile: Improve compiler flag detection for -fcf-protection
Date: Fri, 7 Nov 2025 13:17:27 -0300 [thread overview]
Message-ID: <20251107161729.320087-3-wander@redhat.com> (raw)
In-Reply-To: <20251107161729.320087-1-wander@redhat.com>
The previous method of detecting support for -fcf-protection relied on
a minimum GCC version check, which was not always accurate and could
fail on different architectures or compiler toolchains.
This commit replaces the version check with a more robust method that
directly tests if the compiler supports the -fcf-protection flag. This
ensures better portability and avoids compilation errors on systems
where the flag is not available.
This change mirrors the recently added detection logic for the
-mno-omit-leaf-frame-pointer flag.
Signed-off-by: Wander Lairson Costa <wander@redhat.com>
Cc: Derek Barbosa <debarbos@redhat.com>
Cc: John Kacur <jkacur@redhat.com>
Cc: Juri Lelli <juri.lelli@redhat.com>
Cc: Chunsheng Luo <luochunsheng@ustc.edu>
---
Makefile | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/Makefile b/Makefile
index d605e60..bc82858 100644
--- a/Makefile
+++ b/Makefile
@@ -20,17 +20,14 @@ IS_MINVER := $(intcmp $(GCC_VER), $(MIN_GCC_VER), false, true, true)
$(info IS_MINVER=$(IS_MINVER))
USE_BPF := 1
-FCF_PROTECTION := -fcf-protection
MTUNE := -mtune=generic
M64 := -m64
ifeq ($(ARCH),aarch64)
-FCF_PROTECTION := "-fcf-protection=none"
M64 :=
endif
ifeq ($(ARCH),i686)
USE_BPF := 0
-FCF_PROTECTION := "-fcf-protection=branch"
endif
ifeq ($(ARCH),s390x)
MTUNE := -mtune=z13
@@ -43,9 +40,12 @@ ifeq ($(ARCH),powerpc)
USE_BPF := 0
MTUNE := -mtune=powerpc
endif
-ifeq ($(strip $(IS_MINVER)), false)
-FCF_PROTECTION :=
-endif
+
+# Test if compiler supports -fcf-protection
+FCF_PROTECTION := $(shell echo 'int main(void){return 0;}' | \
+ $(CC) -x c -fcf-protection - \
+ -o /dev/null 2>/dev/null && \
+ echo '-fcf-protection')
$(info USE_BPF=$(USE_BPF))
--
2.51.1
next prev parent reply other threads:[~2025-11-07 16:17 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-07 16:17 [PATCH 0/3] Improve Makefile robustness and explicitness Wander Lairson Costa
2025-11-07 16:17 ` [PATCH 1/3] Makefile: Conditionally add -mno-omit-leaf-frame-pointer Wander Lairson Costa
2025-11-07 16:17 ` Wander Lairson Costa [this message]
2025-11-07 16:41 ` [PATCH 2/3] Makefile: Improve compiler flag detection for -fcf-protection Derek Barbosa
2025-11-07 16:17 ` [PATCH 3/3] Makefile: Explicitly run the 'test' target in the tests directory Wander Lairson Costa
2025-11-11 14:50 ` [PATCH 0/3] Improve Makefile robustness and explicitness Sebastian Andrzej Siewior
2025-11-11 15:35 ` Derek Barbosa
2025-11-11 15:50 ` Sebastian Andrzej Siewior
2025-11-11 16:29 ` Derek Barbosa
2025-11-12 7:41 ` Sebastian Andrzej Siewior
2025-11-12 12:12 ` Wander Lairson Costa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251107161729.320087-3-wander@redhat.com \
--to=wander@redhat.com \
--cc=debarbos@redhat.com \
--cc=jkacur@redhat.com \
--cc=juri.lelli@redhat.com \
--cc=linux-rt-users@vger.kernel.org \
--cc=luochunsheng@ustc.edu \
--cc=williams@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox