Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: fix "warning: "_FORTIFY_SOURCE" redefined" #6283

Merged
merged 1 commit into from
Mar 20, 2024

Conversation

kmk3
Copy link
Collaborator

@kmk3 kmk3 commented Mar 19, 2024

The warning is being produced on Arch since pacman 6.1, which changed
-D_FORTIFY_SOURCE=2 to -D_FORTIFY_SOURCE=3 in CFLAGS in
makepkg.conf:

$ pacman -Q gcc pacman
gcc 13.2.1-5
pacman 6.1.0-3
$ makepkg
[...]
make -C src/lib
gcc [...] -D_FORTIFY_SOURCE=2 [...] -Wp,-D_FORTIFY_SOURCE=3 [...] -c ../../src/lib/common.c -o ../../src/lib/common.o
<command-line>: warning: "_FORTIFY_SOURCE" redefined
<command-line>: note: this is the location of the previous definition

To fix this, only add -D_FORTIFY_SOURCE to EXTRA_CFLAGS if it does not
cause any warnings with CFLAGS and CPPFLAGS during compilation.

The effect remains the same: The build system still defines the macro by
default (if there are no warnings) and the user/distribution can still
override it through CFLAGS/CPPFLAGS.

Fixes #6282.

Reported-by: @glitsj16

The warning is being produced on Arch since pacman 6.1, which changed
`-D_FORTIFY_SOURCE=2` to `-D_FORTIFY_SOURCE=3` in CFLAGS in
makepkg.conf:

    $ pacman -Q gcc pacman
    gcc 13.2.1-5
    pacman 6.1.0-3
    $ makepkg
    [...]
    make -C src/lib
    gcc [...] -D_FORTIFY_SOURCE=2 [...] -Wp,-D_FORTIFY_SOURCE=3 [...] -c ../../src/lib/common.c -o ../../src/lib/common.o
    <command-line>: warning: "_FORTIFY_SOURCE" redefined
    <command-line>: note: this is the location of the previous definition

To fix this, only add `-D_FORTIFY_SOURCE` to EXTRA_CFLAGS if it does not
cause any warnings with CFLAGS and CPPFLAGS during compilation.

The effect remains the same: The build system still defines the macro by
default (if there are no warnings) and the user/distribution can still
override it through CFLAGS/CPPFLAGS.

Fixes netblue30#6282.

Reported-by: @glitsj16
@kmk3 kmk3 force-pushed the build-fix-fortify-warn branch from bd5c8ad to bce208d Compare March 20, 2024 07:22
@kmk3 kmk3 merged commit 0da23da into netblue30:master Mar 20, 2024
13 checks passed
@kmk3 kmk3 deleted the build-fix-fortify-warn branch March 20, 2024 07:28
kmk3 added a commit that referenced this pull request Mar 25, 2024
kmk3 added a commit to kmk3/firejail that referenced this pull request Mar 26, 2024
If not, build with -D_FORTIFY_SOURCE=2 if available (this is what is
currently done).

Note: `-D_FORTIFY_SOURCE=3` is the new default on Arch; see commit
0da23da ("build: fix "warning: "_FORTIFY_SOURCE" redefined" (netblue30#6283)",
2024-03-20).

This is a follow-up to netblue30#6283.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done (on RELNOTES)
Development

Successfully merging this pull request may close these issues.

build: warning: "_FORTIFY_SOURCE" redefined (Arch Linux)
2 participants