diff mbox series

[BlueZ] build: check first before enabling -D_FORTIFY_SOURCE=3

Message ID da7a417d9b27d26393d6c9f52f675e7ae0541e8b.1739007137.git.pav@iki.fi (mailing list archive)
State Accepted
Commit d3e40e82afba8bbc24df8c23272fbf8a68e6ed67
Headers show
Series [BlueZ] build: check first before enabling -D_FORTIFY_SOURCE=3 | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/BuildEll success Build ELL PASS
tedd_an/BluezMake success Bluez Make PASS
tedd_an/MakeCheck success Bluez Make Check PASS
tedd_an/MakeDistcheck success Make Distcheck PASS
tedd_an/CheckValgrind success Check Valgrind PASS
tedd_an/CheckSmatch success CheckSparse PASS
tedd_an/bluezmakeextell success Make External ELL PASS
tedd_an/ScanBuild success Scan Build PASS

Commit Message

Pauli Virtanen Feb. 8, 2025, 9:33 a.m. UTC
With --disable-optimization, _FORTIFY_SOURCE=3 produces compiler
warnings/errors:

/usr/include/features.h:422:4: error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp]
  422 | #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)

Before enabling it for --enable-maintainer-mode, check the compiler
doesn't fail when using the flag.
---
 acinclude.m4 | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

Comments

bluez.test.bot@gmail.com Feb. 8, 2025, 11:06 a.m. UTC | #1
This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=931874

---Test result---

Test Summary:
CheckPatch                    PENDING   0.22 seconds
GitLint                       PENDING   0.32 seconds
BuildEll                      PASS      20.11 seconds
BluezMake                     PASS      1422.15 seconds
MakeCheck                     PASS      13.93 seconds
MakeDistcheck                 PASS      156.59 seconds
CheckValgrind                 PASS      212.61 seconds
CheckSmatch                   PASS      281.65 seconds
bluezmakeextell               PASS      97.47 seconds
IncrementalBuild              PENDING   0.30 seconds
ScanBuild                     PASS      854.25 seconds

Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:

##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:

##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:



---
Regards,
Linux Bluetooth
patchwork-bot+bluetooth@kernel.org Feb. 10, 2025, 10:40 p.m. UTC | #2
Hello:

This patch was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Sat,  8 Feb 2025 11:33:55 +0200 you wrote:
> With --disable-optimization, _FORTIFY_SOURCE=3 produces compiler
> warnings/errors:
> 
> /usr/include/features.h:422:4: error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp]
>   422 | #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
> 
> Before enabling it for --enable-maintainer-mode, check the compiler
> doesn't fail when using the flag.
> 
> [...]

Here is the summary with links:
  - [BlueZ] build: check first before enabling -D_FORTIFY_SOURCE=3
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=d3e40e82afba

You are awesome, thank you!
diff mbox series

Patch

diff --git a/acinclude.m4 b/acinclude.m4
index 9f2dc302e..168117840 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -65,7 +65,6 @@  AC_DEFUN([COMPILER_FLAGS], [
 		with_cflags="$with_cflags -DG_DISABLE_DEPRECATED"
 		with_cflags="$with_cflags -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_28"
 		with_cflags="$with_cflags -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_32"
-		with_cflags="$with_cflags -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3"
 	fi
 	AC_SUBST([WARNING_CFLAGS], $with_cflags)
 ])
@@ -136,6 +135,21 @@  AC_DEFUN([MISC_FLAGS], [
 		misc_cflags="$misc_cflags --coverage"
 		misc_ldflags="$misc_ldflags --coverage"
 	fi
+	if (test "$USE_MAINTAINER_MODE" = "yes"); then
+		AC_CACHE_CHECK([whether ${CC-cc} accepts -D_FORTIFY_SOURCE=3],
+						ac_cv_prog_cc_fortify_source_3, [
+			echo '#include <errno.h>' > fortify.c
+			if test -z "`${CC-cc} ${CFLAGS} ${misc_cflags} -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -c fortify.c  2>&1`"; then
+				ac_cv_prog_cc_fortify_source_3=yes
+			else
+				ac_cv_prog_cc_fortify_source_3=no
+			fi
+			rm -f fortify.c fortify.o
+		])
+		if test "${ac_cv_prog_cc_fortify_source_3}" = "yes"; then
+			misc_cflags="$misc_cflags -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3"
+		fi
+	fi
 	misc_cflags="$misc_cflags -ffunction-sections -fdata-sections"
 	misc_ldflags="$misc_ldflags -Wl,--gc-sections"
 	AC_SUBST([MISC_CFLAGS], $misc_cflags)