-
Notifications
You must be signed in to change notification settings - Fork 203
auto/{cc,options}: Removed unnecessary compiler flags #990
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
base: master
Are you sure you want to change the base?
Conversation
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]>
|
NJS follows nginx here. It serves us well. I see no reason to change it without strong arguments.
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. |
What doesn't make sense is... all other build systems typically handle Werror is a far worse, highly fatal problem. The only solution is not to do it. Only use targeted |
|
I think As for |
|
Would you accept a patch that sets the aforementioned flags only if CFLAGS are unset? |
I am not sure it is a good idea to do this now. njs is already in many distros, and we may break their builds. If they, for some reasons, rely on the default flags. |
It's not exactly very "spirit of open source" for software to intentionally not build until you politely ask the upstream maintainers for permission and then wait for a new upstream release. You seem to believe that people who encounter issues due to use of -Werror will "bug the maintainers to fix the underlying issue" but in reality when downstreams encounter scenarios like this, it simply results in increased burnout, and then the software doesn't work for a while until someone provides an appropriate patch file for the software to delete Keep in mind as well that many people who build software don't know much about C/C++, because they are users rather than developers. All they know is that the software doesn't compile on the latest version of Ubuntu even when following the copy-pasted directions for building. And for distros such as Gentoo, where typically all or most software is compiled locally with diverse options and on diverse hardware, even being packaged by the distro doesn't suffice to have prebuilt binaries -- produced by older compiler versions -- and the people who are trying and failing to build the software (and seeing the errors) are a very long distance indeed, away from being experienced distribution package maintainers who know all the tricks about wrangling troublesome software into building. If you are unlucky, such people give up entirely and simply choose not to use "broken software". If you are lucky, such people submit bug reports but not even to you -- to the distro instead -- without details other than "it failed, I don't know why but here's a gigantic logfile of the failure" and then wait days or weeks for the distribution maintainer to have time in between the needs of IRL to investigate the issue, then eventually forward the bug report to you, then wait unknown periods of time for you to release a new tagged version (possibly a couple of months!) before they can even try again! Or: the distribution package maintainer will (eventually, after users have already been broken once) fix it locally by removing the -Werror, and at that point there is "nothing" to report upstream since "it works now". (And because distribution package maintainers don't like getting into painful and frustrating arguments with upstreams that have made it clear they don't really think much about downstream users.) When you say "No amount of CI is able to catch all the possible scenarios." -- you are really saying "we understand that -Werror is bad for our users, but we want our users to involuntarily participate in our CI". Otherwise why are you making the build fail for users over lint-style -Werrors that don't even indicate a coding defect or runtime bug, but simply indicate that GCC started suggesting some coding style isn't recommended anymore?
Absolutely not -- distro build systems have global toggles for whether debug info should be generated, which is very different from "assume or force it" because toggles have an off state. Unfortunately, when software chooses to ignore the toggle, that means the compiler has to do a lot more work and in extreme scenarios you will run out of disk space long before the package manager can call strip(1) -- try building Qt Webengine sometime, with debug info. ;) Now granted that particular problem isn't a problem for njs, fair enough. But the general policy exists for good reason, and njs is breaking the policy and raises packaging warnings. Even if the package manager then forces -g itself, it will warn you if the software sets -g on its own precisely because "only the package manager itself is allowed to do that". What are you gonna do. 🤷 As for users building from scratch being "savvy enough", you're assuming they realize they need to! :) How should they notice that the binary has significantly large debug info that isn't just on account of the software itself being large? And... the readme of this project specifically says when installing from specific distro repositories, that there is an alternate package "with debug info", then warns you that "you should not use this for production environments, but it may be useful when developing". If I read a warning like this I would ABSOLUTELY not assume that |
I'm not aware of a single distro that can even conceptually have their builds broken by changing this. If they need optimizations or debug, they will set those manually. If they don't want either one, then changing this will fix the distro, not break it. The presence or lack of -pipe is uninteresting to me (I personally think you shouldn't be assuming the GNU assembler, but setting it only if you know the GNU assembler is active). The worst thing that can possibly happen from removing it is... Nothing. It makes no difference whatsoever, it doesn't change the generated code in the slightest, all it can do is slightly speed up the compiler. Removing it could make some builds slower if it isn't otherwise set, but that isn't a breakage, that is a slowage. Removing -Werror cannot break any distro builds because Werror by definition can only cause otherwise successful builds to fail, so removing it can only ever result in more builds succeeding. |
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
-pipeoptions and-Werror.-Werrormight be harmful since compilers continuously add warnings so the users of new compilers may unexpectedly fail to compile njs since-Werroris 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-pipeand a-gto 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:
CONTRIBUTINGdocument