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: warning: "_FORTIFY_SOURCE" redefined (Arch Linux) #6282

Closed
glitsj16 opened this issue Mar 18, 2024 · 1 comment · Fixed by #6283
Closed

build: warning: "_FORTIFY_SOURCE" redefined (Arch Linux) #6282

glitsj16 opened this issue Mar 18, 2024 · 1 comment · Fixed by #6283

Comments

@glitsj16
Copy link
Collaborator

The arrival of pacman 6.1 and related changes show some impact on Firejails build output when using --enable-analyzer. I'm seeing a large number of repeated output like the below:

[...]
<command-line>: warning: "_FORTIFY_SOURCE" redefined
<command-line>: note: this is the location of the previous definition
[...]

Nothing breaks, so this isn't urgent IMO, more of a FYI.

Details that might help grokking this:

$ pacman -Q gcc pacman
gcc 13.2.1-5
pacman 6.1.0-3

[pacman 6.0] [Core]
https://archlinux.org/packages/core/x86_64/pacman/
https://gitlab.archlinux.org/archlinux/packaging/packages/pacman/-/blob/0486fd84165488f10bb3602b103692c70f8a2fb8/makepkg.conf
CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions
-Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security
-fstack-clash-protection -fcf-protection"
LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now"

[pacman 6.1] [Core]
https://gitlab.archlinux.org/archlinux/packaging/packages/pacman/-/blob/main/makepkg.conf?ref_type=heads
CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions
-Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security
-fstack-clash-protection -fcf-protection
-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer"
LDFLAGS="-Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now
-Wl,-z,pack-relative-relocs"

@kmk3 kmk3 changed the title Arch Linux (compiler and linker flags) changes impacting build output build: warning: "_FORTIFY_SOURCE" redefined (Arch Linux) Mar 19, 2024
kmk3 added a commit to kmk3/firejail that referenced this issue Mar 19, 2024
The warning is being produced on Arch (and potentially on other
distributions) since pacman 6.1, which changes `-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 user/distribution can still override
the current value through CFLAGS/CPPFLAGS and the build system still
defines the flag for older distributions/compilers which may not enable
it by default.

Fixes netblue30#6282.

Reported-by: @glitsj16
@kmk3
Copy link
Collaborator

kmk3 commented Mar 19, 2024

Thanks for the the debugging!

Fixed in:

kmk3 added a commit to kmk3/firejail that referenced this issue Mar 20, 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 netblue30#6282.

Reported-by: @glitsj16
kmk3 added a commit that referenced this issue Mar 20, 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
kmk3 added a commit that referenced this issue Mar 25, 2024
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 a pull request may close this issue.

2 participants