Skip to content

Conversation

@BalkanMadman
Copy link

The build system should not unconditionally set compilation flag that vary a lot between each user and, as a result, are meant to be toggled individually by distribution/developer/end user.

Among these flags are the options that control program optimisation, debug symbols, the -pipe options and -Werror. -Werror might be harmful since compilers continuously add warnings so the users of new compilers may unexpectedly fail to compile njs since -Werror is set.

The compilation flags should be supplied in the standard CFLAGS environment variable.

Proposed changes

We hit this problem while packaging njs. The build system appends two -O, a -pipe and a -g to CFLAGS even if the user doesn't have these flags in their CFLAGS. I believe, the correct solution is to not unconditionally add any non-warning CFLAGS.

Checklist

Before creating a PR, run through this checklist and mark each as complete:

  • I have read the CONTRIBUTING document
  • If applicable, I have added tests that prove my fix is effective or that my feature works
  • If applicable, I have checked that any relevant tests pass after adding my changes

The build system should not unconditionally set compilation flag that
vary a lot between each user and, as a result, are meant to be toggled
individually by distribution/developer/end user.

Among these flags are the options that control program optimisation,
debug symbols, the `-pipe` options and `-Werror`. `-Werror` might be
harmful since compilers continuously add warnings so the users of new
compilers may unexpectedly fail to compile njs since `-Werror` is set.

The compilation flags should be supplied in the standard CFLAGS
environment variable.

Signed-off-by: Zurab Kvachadze <[email protected]>
@xeioex
Copy link
Contributor

xeioex commented Nov 19, 2025

@BalkanMadman

NJS follows nginx here. It serves us well. I see no reason to change it without strong arguments.

We hit this problem while packaging njs. The build system appends two -O, a -pipe and a -g to CFLAGS even if the user doesn't have these flags in their CFLAGS.

Normally the last options trump the first ones if they conflict. Does it break anything for you. And if yes, could you, please, share any details? (compilers, OS, CFLAGS)

With CFLAGS, you can still overrule compiler options. See here.
Also, see in our CI pipeline here how options are passed.

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.

2 participants