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: do not modify user-provided CFLAGS variable #240

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jengelh
Copy link

@jengelh jengelh commented Mar 31, 2025

$ ./configure CFLAGS="-U_FORTIFY_SOURCE -g3" && grep ^CFLAGS Makefile && make
...
CFLAGS = -std=gnu11 -U_FORTIFY_SOURCE -g3 -U_FORTIFY_SOURCE -fstack-protector-strong -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -mfunction-return=keep -mindirect-branch=keep -Wall -W -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wchar-subscripts -Wformat=2 -Wbad-function-cast -fno-builtin-strftime -Wstrict-aliasing=2
...
/usr/include/features.h:435:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Wcpp]
  435 | #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)

This is not how ./configure CFLAGS=... should work. As per https://www.gnu.org/software/automake/manual/html_node/User-Variables.html CFLAGS is reserved for the user, should not be changed (and also should enjoy highest precedence).

AM_CFLAGS is the right variable to use here.

```
$ ./configure CFLAGS="-U_FORTIFY_SOURCE -g3" && grep ^CFLAGS Makefile && make
...
CFLAGS = -std=gnu11 -U_FORTIFY_SOURCE -g3 -U_FORTIFY_SOURCE -fstack-protector-strong -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -mfunction-return=keep -mindirect-branch=keep -Wall -W -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wchar-subscripts -Wformat=2 -Wbad-function-cast -fno-builtin-strftime -Wstrict-aliasing=2
...
/usr/include/features.h:435:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Wcpp]
  435 | #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
```

This is not how `./configure CFLAGS=...` should work. As per
https://www.gnu.org/software/automake/manual/html_node/User-Variables.html
CFLAGS is reserved for the user and should not be changed.

AM_CFLAGS is the right variable to use here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant