4 ms·
The dependency on the toolchain should be made explicit and this issue goes away. When updating the toolchain you can set default flags to disable the new warn
by charcircuit 3y ago
The dependency on the toolchain should be made explicit and this issue goes away.
When updating the toolchain you can set default flags to disable the new warnings if you wish to fix each warning one a time.
- mort96 3y agoThat's fine if you're not writing open source code and don't plan on updating your toolchain frequently. For the rest of us? -Werror is not our friend.
- deleted 3y ago[deleted]
- charcircuit 3y agoIt works the same with open source. If your open source library is always built with clang 16 then it will never fail to compile. If people want to use an unsupported toolchain they can figure out how to get it working themselves.
- mort96 3y agoAs an author of open source software, you must expect people to use their system's toolchain. You can define minimum versions sure, but if you use Clang 16, you really ought to not break when a user tries to compile with Clang 17, unless your build system actually automatically downloads and uses the right clang version automatically. Most of us aren't using such a build system.
- charcircuit 3y ago>you must expect people to use their system's toolchain Why? I don't expect people to build against their system libraries. >unless your build system actually automatically downloads and uses the right clang version automatically Nix, bazel, buck, etc all support defining the toolchain for your build. Reproducable builds are useful. You are supporting a known configuration. Crashes can all be collected an easily analyzed. You can be sure you have a properly compiled version by verifying the hash. >Most of us aren't using such a build system. That's okay. You can just ingest a prebuilt artifact if you aren't capable of tying it into your build system.
- aflag 3y ago> Why? Because that's what people do. One of the big reasons that build open source software is to have fun and work together with other hobbyists, some of each don't even write software professionally at all. If you want to have fun with open source you really want to keep things simple and keep the entry barrier low. Otherwise, it'll just feel like an unpaid job.
- charcircuit 3y agoSome people want to develop open source software in a professional manner. Having to support the output of a single toolchain is the definition of keeping things simple.
- mort96 3y agoTo be honest I don't understand what your goal is. Use one toolchain to produce the binaries you distribute, sure. Only provide support for those official binaries or binaries compiled with the officially supported toolchain, why not. And use -Werror with that standardized toolchain in CI to ensure builds with warnings don't get committed, I think that's great. But why are you hell bent on making it harder for your users to build from source?
- charcircuit 3y ago>But why are you hell bent on making it harder for your users to build from source? Building from source would use the toolchain you designed the source code for meaning that it will always succeed. If someone wants to fork the project and add support for a different toolchain they are free to do so. If they want to get rid of the requirement to have no compiler errors they are free to remove -Werror or disable the new warnings.
- mort96 3y agoHonestly the only code base I've seen which does this is Google's Chromium stuff; by default, it will download a pre-built Clang as well as a Debian sysroot. IMO, it's completely insane and has always been a giant pain in the ass. Maybe it's warranted for something as complex as Chromium but I really don't think it's the right choice for some 10kLOC FOSS project.
- viraptor 3y agoOnly in your controlled environment. When you publish something and it gets picked up by a distribution, it will fail. Sometimes even on a bug in a specific compiler version - Ubuntu had a GCC which sometimes picked up a `write()` result as unused and you couldn't ignore/dismiss in any way, so I had to carry patches for some project.
- forrestthewoods 3y agoIf the project is an “executable” then the toolchain dependency should be explicit. If it’s a “library” then it should be implicit. But it’s really not hard to support Clang + GCC + MSVC. And if new toolchains introduce new warnings they should be fixed. That said, my preference is for “dev” builds to not have warnings as errors, only “retail” which gets built by CI. Third party libraries almost always have to be compiled without warnings as errors because almost all open source code is rife with warnings.
- tonyarkles 3y ago> If the project is an “executable” then the toolchain dependency should be explicit. Cross-platform makes this fun. I work on a project that, in production, runs on an embedded Linux box. With a couple of features disabled, I can do development work just fine on my Macbook. Unfortunately, the embedded target uses a relatively old and crusty version of GCC and OS X has a newer version of Clang. We generally shoot for "zero warnings on production builds" but warnings in development on OS X are... okay. We pay attention to them and have occasionally benefitted from warnings that Clang provides that the older GCC does not, but some of the warnings come from some (admittedly questionable but work correctly) casts that a 3rd party library's header makes. Definitely not worth the effort to try to get upstream to fix the code gen that makes these headers to make OS X Clang happy.
- forrestthewoods 3y agoI do a lot of Linux + macOS + Windows support. Yeah third-party libraries are effectively a lost cause. It's ok if it's limited to cpp files. If it's in headers it's annoying. We vendor all third-party dependencies but would probably bias towards fixing the warning. It just spirals out of control too fast if you don't. Ancient toolchains for embedded or similar is definitely tough. If you can use modern toolchains then the combination of warnings across GCC + Clang + MSVC is probably a win.