* [stalld v2 0/6] Improve Makefile portability and debugging
@ 2025-11-10 13:22 Wander Lairson Costa
2025-11-10 13:22 ` [stalld v2 1/6] Makefile: Conditionally add -mno-omit-leaf-frame-pointer Wander Lairson Costa
` (6 more replies)
0 siblings, 7 replies; 15+ messages in thread
From: Wander Lairson Costa @ 2025-11-10 13:22 UTC (permalink / raw)
To: williams
Cc: linux-rt-users, Wander Lairson Costa, Derek Barbosa, John Kacur,
Juri Lelli, Chunsheng Luo
This patch series improves the stalld build system to be more portable
across different architectures and compiler toolchains while adding
better debugging capabilities. The main motivation is to eliminate
hard-coded compiler version checks that were brittle and could fail on
non-standard toolchains or different architectures.
The changes replace minimum version checks with direct compiler feature
detection tests, ensuring that compiler flags are only used when
actually supported. This approach tests each flag by attempting to
compile a minimal test program, making the build system resilient to
variations in compiler implementations across architectures like x86_64,
aarch64, s390x, i686, and powerpc. Additionally, the series adds build
environment information output and cleans up redundant checks to improve
maintainability.
The series also includes minor improvements to explicitly specify the
test target invocation and exclude development environment metadata from
version control.
Wander Lairson Costa (6):
Makefile: Conditionally add -mno-omit-leaf-frame-pointer
Makefile: Improve compiler flag detection for -fcf-protection
Makefile: Explicitly run the 'test' target in the tests directory
Makefile: Remove redundant GCC version check
Makefile: Print BPF tool versions for debugging
gitignore: Exclude Serena and Claude Code metadata
.gitignore | 2 ++
Makefile | 42 ++++++++++++++++++++++++------------------
2 files changed, 26 insertions(+), 18 deletions(-)
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>
---
--
2.51.1
^ permalink raw reply [flat|nested] 15+ messages in thread
* [stalld v2 1/6] Makefile: Conditionally add -mno-omit-leaf-frame-pointer
2025-11-10 13:22 [stalld v2 0/6] Improve Makefile portability and debugging Wander Lairson Costa
@ 2025-11-10 13:22 ` Wander Lairson Costa
2025-11-10 17:51 ` Clark Williams
2025-11-10 13:22 ` [stalld v2 2/6] Makefile: Improve compiler flag detection for -fcf-protection Wander Lairson Costa
` (5 subsequent siblings)
6 siblings, 1 reply; 15+ messages in thread
From: Wander Lairson Costa @ 2025-11-10 13:22 UTC (permalink / raw)
To: williams
Cc: linux-rt-users, Wander Lairson Costa, Derek Barbosa, John Kacur,
Juri Lelli, Chunsheng Luo
The -mno-omit-leaf-frame-pointer option is not available on all
architectures (e.g., s390x) or with older compiler versions. To avoid
compilation errors on such systems, this change adds a check to ensure
the option is only used when the compiler supports it.
This approach is similar to the existing check for -fcf-protection.
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 | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index c19e0bd..d605e60 100644
--- a/Makefile
+++ b/Makefile
@@ -60,7 +60,13 @@ FOPTS := -flto=auto -ffat-lto-objects -fexceptions -fstack-protector-strong \
-fasynchronous-unwind-tables -fstack-clash-protection -fno-omit-frame-pointer \
$(strip $(FCF_PROTECTION)) -fpie
-MOPTS := $(strip $(MTUNE)) $(strip $(M64)) -mno-omit-leaf-frame-pointer
+# Test if compiler supports -mno-omit-leaf-frame-pointer
+OMIT_LEAF_FP := $(shell echo 'int main(void){return 0;}' | \
+ $(CC) -x c -mno-omit-leaf-frame-pointer - \
+ -o /dev/null 2>/dev/null && \
+ echo '-mno-omit-leaf-frame-pointer')
+
+MOPTS := $(strip $(MTUNE)) $(strip $(M64)) $(strip $(OMIT_LEAF_FP))
WOPTS := -Wall -Werror=format-security
--
2.51.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [stalld v2 2/6] Makefile: Improve compiler flag detection for -fcf-protection
2025-11-10 13:22 [stalld v2 0/6] Improve Makefile portability and debugging Wander Lairson Costa
2025-11-10 13:22 ` [stalld v2 1/6] Makefile: Conditionally add -mno-omit-leaf-frame-pointer Wander Lairson Costa
@ 2025-11-10 13:22 ` Wander Lairson Costa
2025-11-10 17:51 ` Clark Williams
2025-11-10 13:22 ` [stalld v2 3/6] Makefile: Explicitly run the 'test' target in the tests directory Wander Lairson Costa
` (4 subsequent siblings)
6 siblings, 1 reply; 15+ messages in thread
From: Wander Lairson Costa @ 2025-11-10 13:22 UTC (permalink / raw)
To: williams
Cc: linux-rt-users, Wander Lairson Costa, Derek Barbosa, John Kacur,
Juri Lelli, Chunsheng Luo
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 | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/Makefile b/Makefile
index d605e60..23e786d 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,23 +40,23 @@ ifeq ($(ARCH),powerpc)
USE_BPF := 0
MTUNE := -mtune=powerpc
endif
-ifeq ($(strip $(IS_MINVER)), false)
-FCF_PROTECTION :=
-endif
-
-
-$(info USE_BPF=$(USE_BPF))
-$(info FCF_PROTECTION=$(FCF_PROTECTION))
-$(info MTUNE=$(MTUNE))
DEBUG ?= 0
INSTALL = install
CC := gcc
+
+# 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')
+
FOPTS := -flto=auto -ffat-lto-objects -fexceptions -fstack-protector-strong \
-fasynchronous-unwind-tables -fstack-clash-protection -fno-omit-frame-pointer \
$(strip $(FCF_PROTECTION)) -fpie
+
# Test if compiler supports -mno-omit-leaf-frame-pointer
OMIT_LEAF_FP := $(shell echo 'int main(void){return 0;}' | \
$(CC) -x c -mno-omit-leaf-frame-pointer - \
@@ -74,6 +71,10 @@ DEFS := -DUSE_BPF=$(USE_BPF) -D_FORTIFY_SOURCE=3 -D_GLIBCXX_ASSERTIONS -DDEBUG_S
CFLAGS := -DVERSION=\"$(VERSION)\" $(FOPTS) $(MOPTS) $(WOPTS) $(DEFS)
+$(info USE_BPF=$(USE_BPF))
+$(info FCF_PROTECTION=$(FCF_PROTECTION))
+$(info MTUNE=$(MTUNE))
+
ifeq ($(DEBUG),0)
CFLAGS += -g -O2
else
--
2.51.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [stalld v2 3/6] Makefile: Explicitly run the 'test' target in the tests directory
2025-11-10 13:22 [stalld v2 0/6] Improve Makefile portability and debugging Wander Lairson Costa
2025-11-10 13:22 ` [stalld v2 1/6] Makefile: Conditionally add -mno-omit-leaf-frame-pointer Wander Lairson Costa
2025-11-10 13:22 ` [stalld v2 2/6] Makefile: Improve compiler flag detection for -fcf-protection Wander Lairson Costa
@ 2025-11-10 13:22 ` Wander Lairson Costa
2025-11-10 17:48 ` Clark Williams
2025-11-10 13:22 ` [stalld v2 4/6] Makefile: Remove redundant GCC version check Wander Lairson Costa
` (3 subsequent siblings)
6 siblings, 1 reply; 15+ messages in thread
From: Wander Lairson Costa @ 2025-11-10 13:22 UTC (permalink / raw)
To: williams
Cc: linux-rt-users, Wander Lairson Costa, Derek Barbosa, John Kacur,
Juri Lelli, Chunsheng Luo
The 'tests' target in the main Makefile was invoking 'make' in the
'tests' subdirectory without specifying a target. This relied on the
default target in the tests/Makefile, which is not explicit.
This commit adds the 'test' target to the make command, making the
build process clearer and more robust.
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 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 23e786d..619413f 100644
--- a/Makefile
+++ b/Makefile
@@ -183,7 +183,7 @@ static: $(OBJ)
$(CC) -o stalld-static $(LDFLAGS) --static $(OBJ) $(LIBS)
tests:
- make -C tests VERSION=$(VERSION) CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)"
+ make -C tests VERSION=$(VERSION) CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" test
.PHONY: install
install: stalld
--
2.51.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [stalld v2 4/6] Makefile: Remove redundant GCC version check
2025-11-10 13:22 [stalld v2 0/6] Improve Makefile portability and debugging Wander Lairson Costa
` (2 preceding siblings ...)
2025-11-10 13:22 ` [stalld v2 3/6] Makefile: Explicitly run the 'test' target in the tests directory Wander Lairson Costa
@ 2025-11-10 13:22 ` Wander Lairson Costa
2025-11-10 17:52 ` Clark Williams
2025-11-11 0:30 ` Derek Barbosa
2025-11-10 13:22 ` [stalld v2 5/6] Makefile: Print BPF tool versions for debugging Wander Lairson Costa
` (2 subsequent siblings)
6 siblings, 2 replies; 15+ messages in thread
From: Wander Lairson Costa @ 2025-11-10 13:22 UTC (permalink / raw)
To: williams
Cc: linux-rt-users, Wander Lairson Costa, Derek Barbosa, John Kacur,
Juri Lelli, Chunsheng Luo
The minimum GCC version check was introduced to handle the `-fcf-protection`
flag, which was not available in older compiler versions. However, a more
robust method that directly tests for compiler support for this flag has
been implemented.
This commit removes the now-redundant GCC version check, simplifying the
Makefile and relying on the more accurate feature detection.
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 | 5 -----
1 file changed, 5 deletions(-)
diff --git a/Makefile b/Makefile
index 619413f..ba67698 100644
--- a/Makefile
+++ b/Makefile
@@ -14,11 +14,6 @@ GCC_VER=$(shell gcc --version | grep ^gcc | cut -f 3 -d ' ' | cut -f 1 -d '.')
endif
$(info GCC_VER=$(GCC_VER))
-# Does the current GCC compiler have fcf-protection and c99+ as default?
-MIN_GCC_VER := 8
-IS_MINVER := $(intcmp $(GCC_VER), $(MIN_GCC_VER), false, true, true)
-$(info IS_MINVER=$(IS_MINVER))
-
USE_BPF := 1
MTUNE := -mtune=generic
M64 := -m64
--
2.51.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [stalld v2 5/6] Makefile: Print BPF tool versions for debugging
2025-11-10 13:22 [stalld v2 0/6] Improve Makefile portability and debugging Wander Lairson Costa
` (3 preceding siblings ...)
2025-11-10 13:22 ` [stalld v2 4/6] Makefile: Remove redundant GCC version check Wander Lairson Costa
@ 2025-11-10 13:22 ` Wander Lairson Costa
2025-11-10 17:50 ` Clark Williams
2025-11-10 13:22 ` [stalld v2 6/6] gitignore: Exclude Serena and Claude Code metadata Wander Lairson Costa
2025-11-25 19:58 ` [stalld v2 0/6] Improve Makefile portability and debugging Clark Williams
6 siblings, 1 reply; 15+ messages in thread
From: Wander Lairson Costa @ 2025-11-10 13:22 UTC (permalink / raw)
To: williams
Cc: linux-rt-users, Wander Lairson Costa, Derek Barbosa, John Kacur,
Juri Lelli, Chunsheng Luo
This commit adds informational messages to the Makefile to print the
kernel version, clang version, and bpftool version. This will help in
debugging BPF-related compilation issues by providing clear information
about the build environment.
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 | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Makefile b/Makefile
index ba67698..43eb9b8 100644
--- a/Makefile
+++ b/Makefile
@@ -121,6 +121,10 @@ VMLINUX_BTF_PATHS := /sys/kernel/btf/vmlinux /boot/vmlinux-$(KERNEL_REL)
VMLINUX_BTF_PATH := $(or $(VMLINUX_BTF),$(firstword \
$(wildcard $(VMLINUX_BTF_PATHS))))
+$(info KERNEL=$(KERNEL_REL))
+$(info $(shell $(CLANG) --version | head -1))
+$(info $(shell $(BPFTOOL) --version))
+
ifeq ($(ARCH),x86_64)
CLANGARCH="-D__x86_64__"
endif
--
2.51.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [stalld v2 6/6] gitignore: Exclude Serena and Claude Code metadata
2025-11-10 13:22 [stalld v2 0/6] Improve Makefile portability and debugging Wander Lairson Costa
` (4 preceding siblings ...)
2025-11-10 13:22 ` [stalld v2 5/6] Makefile: Print BPF tool versions for debugging Wander Lairson Costa
@ 2025-11-10 13:22 ` Wander Lairson Costa
2025-11-10 17:50 ` Clark Williams
2025-11-25 19:58 ` [stalld v2 0/6] Improve Makefile portability and debugging Clark Williams
6 siblings, 1 reply; 15+ messages in thread
From: Wander Lairson Costa @ 2025-11-10 13:22 UTC (permalink / raw)
To: williams; +Cc: linux-rt-users, Wander Lairson Costa
This commit adds .serena and CLAUDE.md to the .gitignore file to
prevent Serena IDE metadata and Claude Code documentation from being
tracked in version control. These files are development environment
specific and should not be part of the repository.
The .serena directory contains IDE-specific configuration and cache
files, while CLAUDE.md is used for AI-assisted development guidance.
Both are local-only files that vary between development environments
and should remain untracked.
Signed-off-by: Wander Lairson Costa <wander@redhat.com>
---
.gitignore | 2 ++
1 file changed, 2 insertions(+)
diff --git a/.gitignore b/.gitignore
index dc802f6..62fddc0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,3 +18,5 @@ node_modules/
patches/
tests/legacy/test01
*.patch
+.serena
+CLAUDE.md
--
2.51.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [stalld v2 3/6] Makefile: Explicitly run the 'test' target in the tests directory
2025-11-10 13:22 ` [stalld v2 3/6] Makefile: Explicitly run the 'test' target in the tests directory Wander Lairson Costa
@ 2025-11-10 17:48 ` Clark Williams
0 siblings, 0 replies; 15+ messages in thread
From: Clark Williams @ 2025-11-10 17:48 UTC (permalink / raw)
To: Wander Lairson Costa
Cc: linux-rt-users, Derek Barbosa, John Kacur, Juri Lelli,
Chunsheng Luo
On Mon, Nov 10, 2025 at 10:22:38AM -0300, Wander Lairson Costa wrote:
> The 'tests' target in the main Makefile was invoking 'make' in the
> 'tests' subdirectory without specifying a target. This relied on the
> default target in the tests/Makefile, which is not explicit.
>
> This commit adds the 'test' target to the make command, making the
> build process clearer and more robust.
>
> 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 | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/Makefile b/Makefile
> index 23e786d..619413f 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -183,7 +183,7 @@ static: $(OBJ)
> $(CC) -o stalld-static $(LDFLAGS) --static $(OBJ) $(LIBS)
>
> tests:
> - make -C tests VERSION=$(VERSION) CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)"
> + make -C tests VERSION=$(VERSION) CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" test
>
How do you feel about adding a 'sudo' to the make invocation, either
here or in the tests/Makefile?
If you don't then the tests run and all pass. If you run it as sudo you
find that there are still a couple of failures.
Clark
--
The United States Coast Guard
Ruining Natural Selection since 1790
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [stalld v2 5/6] Makefile: Print BPF tool versions for debugging
2025-11-10 13:22 ` [stalld v2 5/6] Makefile: Print BPF tool versions for debugging Wander Lairson Costa
@ 2025-11-10 17:50 ` Clark Williams
0 siblings, 0 replies; 15+ messages in thread
From: Clark Williams @ 2025-11-10 17:50 UTC (permalink / raw)
To: Wander Lairson Costa
Cc: linux-rt-users, Derek Barbosa, John Kacur, Juri Lelli,
Chunsheng Luo
On Mon, Nov 10, 2025 at 10:22:40AM -0300, Wander Lairson Costa wrote:
> This commit adds informational messages to the Makefile to print the
> kernel version, clang version, and bpftool version. This will help in
> debugging BPF-related compilation issues by providing clear information
> about the build environment.
>
> 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 | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/Makefile b/Makefile
> index ba67698..43eb9b8 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -121,6 +121,10 @@ VMLINUX_BTF_PATHS := /sys/kernel/btf/vmlinux /boot/vmlinux-$(KERNEL_REL)
> VMLINUX_BTF_PATH := $(or $(VMLINUX_BTF),$(firstword \
> $(wildcard $(VMLINUX_BTF_PATHS))))
>
> +$(info KERNEL=$(KERNEL_REL))
> +$(info $(shell $(CLANG) --version | head -1))
> +$(info $(shell $(BPFTOOL) --version))
> +
> ifeq ($(ARCH),x86_64)
> CLANGARCH="-D__x86_64__"
> endif
> --
> 2.51.1
>
Looks good to me
Signed-off-by: Clark Williams <williams@redhat.com>
--
The United States Coast Guard
Ruining Natural Selection since 1790
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [stalld v2 6/6] gitignore: Exclude Serena and Claude Code metadata
2025-11-10 13:22 ` [stalld v2 6/6] gitignore: Exclude Serena and Claude Code metadata Wander Lairson Costa
@ 2025-11-10 17:50 ` Clark Williams
0 siblings, 0 replies; 15+ messages in thread
From: Clark Williams @ 2025-11-10 17:50 UTC (permalink / raw)
To: Wander Lairson Costa; +Cc: linux-rt-users
On Mon, Nov 10, 2025 at 10:22:41AM -0300, Wander Lairson Costa wrote:
> This commit adds .serena and CLAUDE.md to the .gitignore file to
> prevent Serena IDE metadata and Claude Code documentation from being
> tracked in version control. These files are development environment
> specific and should not be part of the repository.
>
> The .serena directory contains IDE-specific configuration and cache
> files, while CLAUDE.md is used for AI-assisted development guidance.
> Both are local-only files that vary between development environments
> and should remain untracked.
>
> Signed-off-by: Wander Lairson Costa <wander@redhat.com>
> ---
> .gitignore | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/.gitignore b/.gitignore
> index dc802f6..62fddc0 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -18,3 +18,5 @@ node_modules/
> patches/
> tests/legacy/test01
> *.patch
> +.serena
> +CLAUDE.md
> --
> 2.51.1
>
Signed-off-by: Clark Williams <williams@redhat.com>
--
The United States Coast Guard
Ruining Natural Selection since 1790
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [stalld v2 1/6] Makefile: Conditionally add -mno-omit-leaf-frame-pointer
2025-11-10 13:22 ` [stalld v2 1/6] Makefile: Conditionally add -mno-omit-leaf-frame-pointer Wander Lairson Costa
@ 2025-11-10 17:51 ` Clark Williams
0 siblings, 0 replies; 15+ messages in thread
From: Clark Williams @ 2025-11-10 17:51 UTC (permalink / raw)
To: Wander Lairson Costa
Cc: linux-rt-users, Derek Barbosa, John Kacur, Juri Lelli,
Chunsheng Luo
On Mon, Nov 10, 2025 at 10:22:36AM -0300, Wander Lairson Costa wrote:
> The -mno-omit-leaf-frame-pointer option is not available on all
> architectures (e.g., s390x) or with older compiler versions. To avoid
> compilation errors on such systems, this change adds a check to ensure
> the option is only used when the compiler supports it.
>
> This approach is similar to the existing check for -fcf-protection.
>
> 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 | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/Makefile b/Makefile
> index c19e0bd..d605e60 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -60,7 +60,13 @@ FOPTS := -flto=auto -ffat-lto-objects -fexceptions -fstack-protector-strong \
> -fasynchronous-unwind-tables -fstack-clash-protection -fno-omit-frame-pointer \
> $(strip $(FCF_PROTECTION)) -fpie
>
> -MOPTS := $(strip $(MTUNE)) $(strip $(M64)) -mno-omit-leaf-frame-pointer
> +# Test if compiler supports -mno-omit-leaf-frame-pointer
> +OMIT_LEAF_FP := $(shell echo 'int main(void){return 0;}' | \
> + $(CC) -x c -mno-omit-leaf-frame-pointer - \
> + -o /dev/null 2>/dev/null && \
> + echo '-mno-omit-leaf-frame-pointer')
> +
> +MOPTS := $(strip $(MTUNE)) $(strip $(M64)) $(strip $(OMIT_LEAF_FP))
>
> WOPTS := -Wall -Werror=format-security
>
> --
> 2.51.1
>
Signed-off-by: Clark Williams <williams@redhat.com>
--
The United States Coast Guard
Ruining Natural Selection since 1790
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [stalld v2 2/6] Makefile: Improve compiler flag detection for -fcf-protection
2025-11-10 13:22 ` [stalld v2 2/6] Makefile: Improve compiler flag detection for -fcf-protection Wander Lairson Costa
@ 2025-11-10 17:51 ` Clark Williams
0 siblings, 0 replies; 15+ messages in thread
From: Clark Williams @ 2025-11-10 17:51 UTC (permalink / raw)
To: Wander Lairson Costa
Cc: linux-rt-users, Derek Barbosa, John Kacur, Juri Lelli,
Chunsheng Luo
On Mon, Nov 10, 2025 at 10:22:37AM -0300, Wander Lairson Costa wrote:
> 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 | 23 ++++++++++++-----------
> 1 file changed, 12 insertions(+), 11 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index d605e60..23e786d 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,23 +40,23 @@ ifeq ($(ARCH),powerpc)
> USE_BPF := 0
> MTUNE := -mtune=powerpc
> endif
> -ifeq ($(strip $(IS_MINVER)), false)
> -FCF_PROTECTION :=
> -endif
> -
> -
> -$(info USE_BPF=$(USE_BPF))
> -$(info FCF_PROTECTION=$(FCF_PROTECTION))
> -$(info MTUNE=$(MTUNE))
>
> DEBUG ?= 0
>
> INSTALL = install
> CC := gcc
> +
> +# 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')
> +
> FOPTS := -flto=auto -ffat-lto-objects -fexceptions -fstack-protector-strong \
> -fasynchronous-unwind-tables -fstack-clash-protection -fno-omit-frame-pointer \
> $(strip $(FCF_PROTECTION)) -fpie
>
> +
> # Test if compiler supports -mno-omit-leaf-frame-pointer
> OMIT_LEAF_FP := $(shell echo 'int main(void){return 0;}' | \
> $(CC) -x c -mno-omit-leaf-frame-pointer - \
> @@ -74,6 +71,10 @@ DEFS := -DUSE_BPF=$(USE_BPF) -D_FORTIFY_SOURCE=3 -D_GLIBCXX_ASSERTIONS -DDEBUG_S
>
> CFLAGS := -DVERSION=\"$(VERSION)\" $(FOPTS) $(MOPTS) $(WOPTS) $(DEFS)
>
> +$(info USE_BPF=$(USE_BPF))
> +$(info FCF_PROTECTION=$(FCF_PROTECTION))
> +$(info MTUNE=$(MTUNE))
> +
> ifeq ($(DEBUG),0)
> CFLAGS += -g -O2
> else
> --
> 2.51.1
>
Signed-off-by: Clark Williams <williams@redhat.com>
--
The United States Coast Guard
Ruining Natural Selection since 1790
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [stalld v2 4/6] Makefile: Remove redundant GCC version check
2025-11-10 13:22 ` [stalld v2 4/6] Makefile: Remove redundant GCC version check Wander Lairson Costa
@ 2025-11-10 17:52 ` Clark Williams
2025-11-11 0:30 ` Derek Barbosa
1 sibling, 0 replies; 15+ messages in thread
From: Clark Williams @ 2025-11-10 17:52 UTC (permalink / raw)
To: Wander Lairson Costa
Cc: linux-rt-users, Derek Barbosa, John Kacur, Juri Lelli,
Chunsheng Luo
On Mon, Nov 10, 2025 at 10:22:39AM -0300, Wander Lairson Costa wrote:
> The minimum GCC version check was introduced to handle the `-fcf-protection`
> flag, which was not available in older compiler versions. However, a more
> robust method that directly tests for compiler support for this flag has
> been implemented.
>
> This commit removes the now-redundant GCC version check, simplifying the
> Makefile and relying on the more accurate feature detection.
>
> 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 | 5 -----
> 1 file changed, 5 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 619413f..ba67698 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -14,11 +14,6 @@ GCC_VER=$(shell gcc --version | grep ^gcc | cut -f 3 -d ' ' | cut -f 1 -d '.')
> endif
> $(info GCC_VER=$(GCC_VER))
>
> -# Does the current GCC compiler have fcf-protection and c99+ as default?
> -MIN_GCC_VER := 8
> -IS_MINVER := $(intcmp $(GCC_VER), $(MIN_GCC_VER), false, true, true)
> -$(info IS_MINVER=$(IS_MINVER))
> -
> USE_BPF := 1
> MTUNE := -mtune=generic
> M64 := -m64
> --
> 2.51.1
>
Signed-off-by: Clark Williams <williams@redhat.com>
--
The United States Coast Guard
Ruining Natural Selection since 1790
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [stalld v2 4/6] Makefile: Remove redundant GCC version check
2025-11-10 13:22 ` [stalld v2 4/6] Makefile: Remove redundant GCC version check Wander Lairson Costa
2025-11-10 17:52 ` Clark Williams
@ 2025-11-11 0:30 ` Derek Barbosa
1 sibling, 0 replies; 15+ messages in thread
From: Derek Barbosa @ 2025-11-11 0:30 UTC (permalink / raw)
To: Wander Lairson Costa
Cc: williams, linux-rt-users, John Kacur, Juri Lelli, Chunsheng Luo
On Mon, Nov 10, 2025 at 10:22:39AM -0300, Wander Lairson Costa wrote:
> The minimum GCC version check was introduced to handle the `-fcf-protection`
> flag, which was not available in older compiler versions. However, a more
> robust method that directly tests for compiler support for this flag has
> been implemented.
>
> This commit removes the now-redundant GCC version check, simplifying the
> Makefile and relying on the more accurate feature detection.
>
> 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 | 5 -----
> 1 file changed, 5 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 619413f..ba67698 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -14,11 +14,6 @@ GCC_VER=$(shell gcc --version | grep ^gcc | cut -f 3 -d ' ' | cut -f 1 -d '.')
> endif
> $(info GCC_VER=$(GCC_VER))
>
> -# Does the current GCC compiler have fcf-protection and c99+ as default?
> -MIN_GCC_VER := 8
> -IS_MINVER := $(intcmp $(GCC_VER), $(MIN_GCC_VER), false, true, true)
> -$(info IS_MINVER=$(IS_MINVER))
> -
> USE_BPF := 1
> MTUNE := -mtune=generic
> M64 := -m64
> --
> 2.51.1
>
Acked-by: Derek Barbosa <debarbos@redhat.com>
--
Derek <debarbos@redhat.com>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [stalld v2 0/6] Improve Makefile portability and debugging
2025-11-10 13:22 [stalld v2 0/6] Improve Makefile portability and debugging Wander Lairson Costa
` (5 preceding siblings ...)
2025-11-10 13:22 ` [stalld v2 6/6] gitignore: Exclude Serena and Claude Code metadata Wander Lairson Costa
@ 2025-11-25 19:58 ` Clark Williams
6 siblings, 0 replies; 15+ messages in thread
From: Clark Williams @ 2025-11-25 19:58 UTC (permalink / raw)
To: Wander Lairson Costa
Cc: linux-rt-users, Derek Barbosa, John Kacur, Juri Lelli,
Chunsheng Luo
On Mon, Nov 10, 2025 at 10:22:35AM -0300, Wander Lairson Costa wrote:
> This patch series improves the stalld build system to be more portable
> across different architectures and compiler toolchains while adding
> better debugging capabilities. The main motivation is to eliminate
> hard-coded compiler version checks that were brittle and could fail on
> non-standard toolchains or different architectures.
>
> The changes replace minimum version checks with direct compiler feature
> detection tests, ensuring that compiler flags are only used when
> actually supported. This approach tests each flag by attempting to
> compile a minimal test program, making the build system resilient to
> variations in compiler implementations across architectures like x86_64,
> aarch64, s390x, i686, and powerpc. Additionally, the series adds build
> environment information output and cleans up redundant checks to improve
> maintainability.
>
> The series also includes minor improvements to explicitly specify the
> test target invocation and exclude development environment metadata from
> version control.
>
> Wander Lairson Costa (6):
> Makefile: Conditionally add -mno-omit-leaf-frame-pointer
> Makefile: Improve compiler flag detection for -fcf-protection
> Makefile: Explicitly run the 'test' target in the tests directory
> Makefile: Remove redundant GCC version check
> Makefile: Print BPF tool versions for debugging
> gitignore: Exclude Serena and Claude Code metadata
>
> .gitignore | 2 ++
> Makefile | 42 ++++++++++++++++++++++++------------------
> 2 files changed, 26 insertions(+), 18 deletions(-)
>
> 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>
Ack for the series (note that I have this now in my devel branch, which
is based on v1.25.1)
Signed-off-by: Clark Williams <williams@redhat.com>
--
The United States Coast Guard
Ruining Natural Selection since 1790
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2025-11-25 19:58 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-10 13:22 [stalld v2 0/6] Improve Makefile portability and debugging Wander Lairson Costa
2025-11-10 13:22 ` [stalld v2 1/6] Makefile: Conditionally add -mno-omit-leaf-frame-pointer Wander Lairson Costa
2025-11-10 17:51 ` Clark Williams
2025-11-10 13:22 ` [stalld v2 2/6] Makefile: Improve compiler flag detection for -fcf-protection Wander Lairson Costa
2025-11-10 17:51 ` Clark Williams
2025-11-10 13:22 ` [stalld v2 3/6] Makefile: Explicitly run the 'test' target in the tests directory Wander Lairson Costa
2025-11-10 17:48 ` Clark Williams
2025-11-10 13:22 ` [stalld v2 4/6] Makefile: Remove redundant GCC version check Wander Lairson Costa
2025-11-10 17:52 ` Clark Williams
2025-11-11 0:30 ` Derek Barbosa
2025-11-10 13:22 ` [stalld v2 5/6] Makefile: Print BPF tool versions for debugging Wander Lairson Costa
2025-11-10 17:50 ` Clark Williams
2025-11-10 13:22 ` [stalld v2 6/6] gitignore: Exclude Serena and Claude Code metadata Wander Lairson Costa
2025-11-10 17:50 ` Clark Williams
2025-11-25 19:58 ` [stalld v2 0/6] Improve Makefile portability and debugging Clark Williams
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox