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 fails if -D_FORTIFY_SOURCES is in env CFLAGS #7310

Closed
real-or-random opened this issue Apr 4, 2024 · 6 comments
Closed

Build fails if -D_FORTIFY_SOURCES is in env CFLAGS #7310

real-or-random opened this issue Apr 4, 2024 · 6 comments
Labels

Comments

@real-or-random
Copy link

real-or-random commented Apr 4, 2024

Describe the bug
setup.py prepends the env CFLAGS with -D_FORTIFY_SOURCES=2. This leads to a build failure when the env CFLAGS contain a different definition. For example, Arch Linux recently switched to -D_FORTIFY_SOURCES=3 (see https://rfc.archlinux.page/0017-increase-fortification-level/). When I try to build the Arch AUR package kitty-git, I get this (after modifying setup.py not to suppress stderr):

<command-line>: error: "_FORTIFY_SOURCE" redefined
<command-line>: note: this is the location of the previous definition
Failed to determine target architecture compiling test program failed with exit code: 1  

See https://aur.archlinux.org/packages/kitty-git#comment-961665 for more reports of this.

Analysis/Suggestion
This is a bit unfortunate. Usually, later CFLAGS override earlier CFLAGS (to give the user the last word), but not in the case of -D. (Strictly speaking, -D_FORTIFY_SOURCES=2 belongs to CPPFLAGS, but it probably won't matter, and even Arch Linux's defaults get this wrong... edit: Apparently this is there for good reasons: https://rfc.archlinux.page/0003-buildflags/)

I suggest

  • adding -D_FORTIFY_SOURCES=2 only if CFLAGS and CPPFLAGS don't contain the substring -D_FORTIFY_SOURCES=
  • switching to -D_FORTIFY_SOURCES=3 (this alone would make the problem go away on Arch Linux, but it's not a proper solution...)
@kovidgoyal
Copy link
Owner

I am on Arch too, it doesnt set CFLAGS as an env var. This must be
something specific to the kitty-git aur build script. That said, easy
enough to fix.

@real-or-random
Copy link
Author

I am on Arch too, it doesnt set CFLAGS as an env var. This must be
something specific to the kitty-git aur build script.

Okay, strictly speaking, Arch doesn't set it, but makepkg does: https://gitlab.archlinux.org/archlinux/packaging/packages/pacman/-/blob/main/makepkg.conf?ref_type=heads

@CanadianBaconBoi
Copy link

The kitty-git package builds perfectly when manually running makepkg -si. The yay AUR helper is where the issue seems to lie.

@real-or-random
Copy link
Author

The kitty-git package builds perfectly when manually running makepkg -si. The yay AUR helper is where the issue seems to lie.

Okay, I don't know. I haven't tried this. Anyway, it's fixed now. :)

@HanabishiRecca
Copy link

@kovidgoyal doesn't 20375ee break OVERRIDE_CFLAGS?

@kovidgoyal
Copy link
Owner

It prevents it from overriding fortify source yes, but there are many
other things it doesnt override anyway.

Rhodate pushed a commit to Rhodate/kitty that referenced this issue Apr 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants