LWN: Comments on "Modernizing Fedora's C code" https://lwn.net/Articles/913505/ This is a special feed containing comments posted to the individual LWN article titled "Modernizing Fedora's C code". en-us Mon, 27 Oct 2025 23:35:31 +0000 Mon, 27 Oct 2025 23:35:31 +0000 https://www.rssboard.org/rss-specification lwn@lwn.net Modernizing Fedora's C code https://lwn.net/Articles/914051/ https://lwn.net/Articles/914051/ eru Maybe we could standardise something like the tripled defining the environment in GCC, but only with compiler and libc: <i>compiler-vers-libc-vers.</i> "uname" will provide the architecture and OS on POSIX-compatible hosts. <p> Existence of external dependencies could be pre-checked with pkg-config and/or the host's package manager. If the package is not found, warn, but barge on regardless, in case it was installed without such metadata. (The build would then fail if it does not exist). Tue, 08 Nov 2022 13:45:28 +0000 Modernizing Fedora's C code https://lwn.net/Articles/914034/ https://lwn.net/Articles/914034/ fw It's not just autoconf. For example, <a href="https://github.com/pypa/setuptools/issues/3648">has_function in Python's setuptools</a> appears to be quite broken even for C89 compilers, and it gets worse with the removal of implicit function declarations. <p>A side effective of this endeavor is that we look at parts of the build process that are usually ignored and taken for granted. For example, I also found a garbled line in <code>configure.ac</code> of <a href="https://www.liblognorm.com/">liblognorm</a>, causing the <code>clock_gettime</code> check to always fail (even on glibc 2.17), resulting in unnecessary linking with <code>-lrt</code>. The tricky part will be not get sucked in to side projects to address such issues. Mon, 07 Nov 2022 19:38:55 +0000 Modernizing Fedora's C code https://lwn.net/Articles/914032/ https://lwn.net/Articles/914032/ fw The wrapper approach still over-reports issues somewhat because <code>-Werror=implicit-function-declaration</code> moves errors from link time to compile time. Many configure-like checks perform just a single <code>gcc</code> invocation even for link checks. But separate invocations will still result in false reports (because the compile stage used to pass). <p>In practice, there is not that much of a difference to a single-pass approach, logging the errors. A lot of the errors are caused by a missing <code>#include &lt;stdio.h&gt;</code> for <code>exit</code>, and require manual intervention anyway. There are many <a href="https://src.fedoraproject.org/fork/fweimer/rpms/redhat-rpm-config/blob/c99-port/f/report-gcc-errors.lua">functions which are expected to be implemented</a>, but we can maintain a list of those. Mon, 07 Nov 2022 19:32:23 +0000 Modernizing Fedora's C code https://lwn.net/Articles/914018/ https://lwn.net/Articles/914018/ farnz <p>A big part of it is that nobody uses <a href="https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.71/html_node/Site-Defaults.html">site defaults</a> to set up a site-wide <a href="https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.71/html_node/Cache-Files.html">cache file</a> for configure to use, so nobody's configure scripts are set up to cope with a site-wide cache, and it all thus falls apart. <p>In theory, a Linux distribution could take responsibility for this, but the mess that results from autoconf allowing you to override linkers, compilers etc via environment variables makes it problematic. Mon, 07 Nov 2022 14:11:04 +0000 Modernizing Fedora's C code https://lwn.net/Articles/914013/ https://lwn.net/Articles/914013/ mathstuf <div class="FormattedComment"> Checking for functions and their signatures doesn't make a lot of sense anymore, but there are still open questions:<br> <p> - musl or glibc?<br> - is dep X available? is it a sufficient version?<br> - is libdl a separate library?<br> <p> My pet peeve is when I see checks being performed that get put into `config.h` and then…never used. Those patches at least tend to get some traction even if removing unnecessary-but-used checks is not as well-received.<br> <p> And, not that it's relevant for autoconf, but Windows support does tend to require probing (or embedding tables for things like "the XYZ toolchain finally supports snprintf"). These checks can be dropped as older toolchain support is dropped.<br> </div> Mon, 07 Nov 2022 14:02:36 +0000 Modernizing Fedora's C code https://lwn.net/Articles/913988/ https://lwn.net/Articles/913988/ eru <blockquote><i>... is complicated by the use of Autoconf in many of the packages ...</i></blockquote> <p> I have long wondered what is the point of Autoconf (and other build tools that do similar autoprobing) these days. The environments and compilers are much more standard now than when Autoconf was born and had to deal with a zoo of twisty unix variants, all different. Now the configure step sometimes takes as much time than the actual compilation while it checks for the presence of features every realistic environment has had for the past 30 years. I would like to just say "I have Linux and GCC, build it". Mon, 07 Nov 2022 12:59:08 +0000 Modernizing Fedora's C code https://lwn.net/Articles/913900/ https://lwn.net/Articles/913900/ floppus <div class="FormattedComment"> For static functions, the function definition can tell you the parameter types. It's not uncommon in older codebases for static functions to always be defined before they're used, and not to have prototypes (I think K&amp;R C doesn't allow forward declarations of static functions at all.) External functions, of course, usually have prototypes in a header file, guarded by #ifdef __STDC__ or something.<br> <p> GCC doesn't check argument types against an earlier old-style definition (though it does check old-style parameters against an earlier prototype), and -Wmissing-prototypes doesn't complain about missing prototypes for static functions, either.<br> </div> Fri, 04 Nov 2022 22:34:44 +0000 Modernizing Fedora's C code https://lwn.net/Articles/913894/ https://lwn.net/Articles/913894/ zaitseff <p>Thanks for your comments. I guess I won't be the only package maintainer in this situation!</p> <blockquote> <p>I think you might have generated <tt>configure</tt> using an older <tt>autoconf</tt>.</p> </blockquote> <p>I used the latest versions of <tt>autoconf</tt> (2.71) and <tt>automake</tt> (1.16.5) that were in Debian Sid at the time (August 2022). These versions are still the latest as released upstream. So I guess I might have to wait for new versions to be released. I'll also check whether Fedora includes/will include additional patches that Debian does not.</p> <blockquote> <p>Something which makes all of this harder to test for is that you can't use <tt>-Werror=strict-prototypes</tt> for <tt>configure</tt> because some tests rely on it failing/succeeding.</p> </blockquote> <p>In actual fact, not only can I not use <tt>-Werror=strict-prototypes</tt>, I also must drop <tt>-Werror=old-style-definition</tt>. But then my package compiles, installs and actually works! <tt>:-)</tt></p> Fri, 04 Nov 2022 20:40:27 +0000 Modernizing Fedora's C code https://lwn.net/Articles/913874/ https://lwn.net/Articles/913874/ mbunkus <div class="FormattedComment"> What's even worse is that autoconf versions aren't always compatible. You cannot simply take a years-old autoconf.ac source file &amp; process it with a the newest, bug-fixed autoconf release. There are several breaking changes.<br> </div> Fri, 04 Nov 2022 15:52:17 +0000 Modernizing Fedora's C code https://lwn.net/Articles/913856/ https://lwn.net/Articles/913856/ madscientist <div class="FormattedComment"> Clearly, I meant that once the basic issues were worked out; this may well require a new release of autoconf.<br> <p> If things outright fail, that's straightforward enough to resolve (obviously assuming sufficient manpower). My understanding is that this wasn't the concerning part. My understanding is that the concern was when a test for some feature fails not because that feature is not available but because the test doesn't compile properly.<br> <p> This is a kind of "silent error" where the build succeeds but the resulting package is neutered and important functionality is missing, because configure incorrectly thought the feature was not available.<br> <p> For this it seems like running the configure both ways and comparing the config.h / config.status would let you know if there was such a "silent error".<br> </div> Fri, 04 Nov 2022 14:25:55 +0000 Modernizing Fedora's C code https://lwn.net/Articles/913811/ https://lwn.net/Articles/913811/ wezm <div class="FormattedComment"> <span class="QuotedText">&gt; which is currently slated for the northern-hemisphere Spring of 2024</span><br> <p> Thank you for explicitly naming the hemisphere instead of just assuming northern like so many season based calendar references I see.<br> </div> Fri, 04 Nov 2022 04:02:56 +0000 Modernizing Fedora's C code https://lwn.net/Articles/913791/ https://lwn.net/Articles/913791/ sam_c <div class="FormattedComment"> 1. I said "wrap for". The point being, if you want to just find 'configure' or configure-ish failures, and avoid this affecting package builds (which makes things awkward because you then can build things which depend on it), it can be a problem. We do sandbox builds including network but yes, it'll be doable to store in a file somewhere.<br> <p> 2/3. Right, it's a good idea. You indeed don't have to worry about diffing later, you can import if something simply doesn't compile with the second compiler. I'll go play with it.<br> <p> 4. It's really just the nature of the large amount of software out there. Some of these bugs will end up hitting other distros anyway.<br> <p> 5. Yes, it is, because you have to go around running autoreconf in tonnes of packages when the configure scripts in the release tarball are stale (and it's not fixed in an autoconf release, so new releases of software will continue to be broken).<br> <p> Would it perhaps have been more acceptable to you if I'd said "complex" rather than "hard", as there's many factors? :)<br> </div> Thu, 03 Nov 2022 22:36:05 +0000 Modernizing Fedora's C code https://lwn.net/Articles/913788/ https://lwn.net/Articles/913788/ khim <font class="QuotedText">&gt; I'm not claiming this is all intractable, but it's also not easy, and it's also not quick.</font> <p>It definitely wouldn't be quick and that's why I think it's good idea to do a bit more infrastructure work before starting looking on logs.</p> <p>#1: I'm <b>not</b> proposing to wrap configure. Not even close. I propose to make wrapper for <b>gcc</b> (and <b>clang</b> if it's used). You either specify it as compiler or, if even that's hard, rename old gcc to something like <code>gcc.real</code> and put wrapper in that place instead.</p> <p>The only trouble would be the fact that Gentoo wouldn't allow wrapper to just store logs in some random file, but that's not a big deal: you can send them by connecting to 127.0.0.1 and talking to some server, e.g.</p> <p>#2 and #3 become irrelevant, because you are not even comparing logs. You are just comparing behavior of two <code>gcc</code> calls. And if they lead to the same result (both attempts compiled <code>conftest</code> succefully or both failed) then you don't even need to do anything about that case. But if one succeeded and one failed then you need to look and see what happens there.</p> <p>#4 is indeed a big problem, but that's Gentoo-specific issue, that I have no idea how to fix. I only needed to ensure that after switch from glibc to musl in some pretty convoluted embedded image builder there would be no changes in behavior (or at least we would know what have changed). It's a bit easier than what you attempted, because there are no 82 use flags.</p> <p>#5 you would, probably, require some changes in autotools, but is it really that problematic? I guess that's something I haven't actually needed, but without working fix it's hard to even start.</p> <p>#6 is, again, same problem as #4. You can not ensure there would be not changes in all possible combinations of use flags, but at least you can ensure that tested combinations work fine.</p> Thu, 03 Nov 2022 22:28:18 +0000 Modernizing Fedora's C code https://lwn.net/Articles/913787/ https://lwn.net/Articles/913787/ sam_c <div class="FormattedComment"> <span class="QuotedText">&gt; Why is it hard? I have done such things before. They are tedious, sure, but “hard”? How? Why?</span><br> <p> "Hard" in that there's a lot of work, not a lot of people helping with it right now, and not all packages follow a standard pattern. I'm glad you've done it before and I welcome your help in our efforts! Also, there's a lot of packages in the world, and therefore a lot of logs to sift through and actually fix the problems in.<br> <p> 1. Not everything uses `autotools` so you can't just wrap for e.g. configure. Of course, in Gentoo, it's easy enough for us to wrap anything called in our `src_configure` phase. An example of this is the bug in the article: distutils (<a href="https://github.com/pypa/setuptools/issues/3648">https://github.com/pypa/setuptools/issues/3648</a>).<br> <p> 2. Older `autotools` doesn't create a config.log. Related to #1, as different build systems behave differently. They may store their results in a different place.<br> <p> 3. autotools and other build systems may generate implicit function declaration errors intentionally when testing for e.g. BSD-only functions. This is noise and makes it harder to identify "real" breakage.<br> <p> 4. Testing every build combination of every package is impossible. In Gentoo, for example, PHP has 82 or so USE flags (different build options). We therefore can't test all combinations ourselves. Making a test for these issues programmatically so that users are warned if their configuration might be broken is possible (and will likely be done), but reducing false positives is important to avoid user confusion.<br> <p> 5. As noted in another comment, the shipped versions of autoconf (including the latest version 2.71) emits declarations which are broken with `-Werror=strict-prototypes`.<br> <p> 6. Related to #4: suppose we missed a problem in a build of a library. A user then reports a problem in a consumer of that library. It's not always going to be obvious that the library was miscompiled, especially if this is several years down the line.<br> <p> I'm not claiming this is all intractable, but it's also not easy, and it's also not quick.<br> <p> </div> Thu, 03 Nov 2022 22:00:08 +0000 Modernizing Fedora's C code https://lwn.net/Articles/913785/ https://lwn.net/Articles/913785/ sam_c <div class="FormattedComment"> Thank you for your interest!<br> <p> There's two problems here:<br> 1. I think you might have generated `configure` using an older `autoconf`. But even newer `autoconf` will generate code which isn't strict-prototypes compliant (see below). Try `autoreconf -fi` and see if it's any better. Consider publishing a new release if it is.<br> <p> 2. Something which makes all of this harder to test for is that you can't use `-Werror=strict-prototypes` for `configure` because some tests rely on it failing/succeeding.<br> <p> <a href="https://git.savannah.gnu.org/cgit/autoconf.git/commit/?id=8b5e2016c7ed2d67f31b03a3d2e361858ff5299b">https://git.savannah.gnu.org/cgit/autoconf.git/commit/?id...</a> could be applied to your distribution's `autoconf` to make sure it generates decent code.<br> <p> As a workaround: omit -Werror=strict-prototypes when passing CFLAGS to `configure`. You can try then passing them with make/in the environment after `configure` and hope it gets picked up.<br> </div> Thu, 03 Nov 2022 21:50:30 +0000 Modernizing Fedora's C code https://lwn.net/Articles/913777/ https://lwn.net/Articles/913777/ zaitseff <p>I use Autoconf and Automake in my small <a href="https://www.zap.org.au/projects/trader/">Star Traders</a> game. My code is written in C99, but when I tried running <tt>./configure</tt> with the flags recommended in the article, <tt>configure</tt> didn't get very far at all:</p> <pre> $ <b>wget -N https://ftp.zap.org.au/pub/trader/unix/trader-7.18.tar.xz</b> $ <b>tar xvf trader-7.18.tar.xz</b> $ <b>cd trader-7.18</b> $ <b>./configure CFLAGS="-Werror=implicit-int -Werror=implicit-function-declaration -Werror=int-conversion -Werror=strict-prototypes -Werror=old-style-definition"</b> checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a race-free mkdir -p... /usr/bin/mkdir -p checking for gawk... gawk checking whether make sets $(MAKE)... yes checking whether make supports nested variables... yes checking whether to enable maintainer-specific portions of Makefiles... yes checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether the compiler supports GNU C... yes checking whether gcc accepts -g... yes checking for gcc option to enable C11 features... unsupported checking for gcc option to enable C99 features... unsupported checking for gcc option to enable C89 features... unsupported checking whether gcc understands -c and -o together... yes checking whether the compiler is clang... no checking for compiler option needed when checking for declarations... none checking whether make supports the include directive... yes (GNU style) checking dependency style of gcc... gcc3 configure: error: requires an ISO/IEC 9899:1999 (C99) compiler </pre> <p>The problem is that even when <tt>configure</tt> tries the <tt>-std=gnu11</tt> flag for GCC, it still has K&amp;R-style function declarations in conftest.c:</p> <pre> configure:5405: gcc -std=gnu11 -c -Werror=implicit-int -Werror=implicit-function-declaration -Werror=int-conversion -Werror=strict-prototypes -Werror=old-style-definition conftest.c &gt;&amp;5 conftest.c:26:14: error: function declaration isn't a prototype [-Werror=strict-prototypes] 26 | static char *e (p, i) | ^ conftest.c: In function 'e': conftest.c:26:14: error: old-style function definition [-Werror=old-style-definition] cc1: some warnings being treated as errors </pre> <p>Given that this package is in Fedora (and many other distros), happy to help solve the problem! And yes, I recognise I might be doing something wrong...</p> Thu, 03 Nov 2022 20:20:26 +0000 Modernizing Fedora's C code https://lwn.net/Articles/913716/ https://lwn.net/Articles/913716/ madscientist <div class="FormattedComment"> It seems like it should be feasible to run configure with the original flags, then re-run it with the strict flags, and simply compare the resulting config.h (or possibly config.status, with some fuzzing) to see that features are not being incorrectly lost.<br> </div> Thu, 03 Nov 2022 19:49:34 +0000 Modernizing Fedora's C code https://lwn.net/Articles/913694/ https://lwn.net/Articles/913694/ NYKevin <div class="FormattedComment"> They still have <a href="https://github.com/NetHack/NetHack/blob/NetHack-3.7/include/tradstdc.h">https://github.com/NetHack/NetHack/blob/NetHack-3.7/inclu...</a> though.<br> </div> Thu, 03 Nov 2022 17:35:55 +0000 Modernizing Fedora's C code https://lwn.net/Articles/913674/ https://lwn.net/Articles/913674/ willy <div class="FormattedComment"> Over twenty years ago, I went through much the same exercise for much the same reason with Itanium &amp; PA-RISC. It was more C++ than C, but not being able to use gcc-2.95 forced us to fix a lot of crusty old code. It was a slog, but I'm glad you find this kind of exercise rewarding!<br> </div> Thu, 03 Nov 2022 15:46:12 +0000 Modernizing Fedora's C code https://lwn.net/Articles/913672/ https://lwn.net/Articles/913672/ dskoll <p>How could it do type-checking with the old syntax? You need a function prototype to do type-checking, and that can't be written with the old syntax (and making it possible would be a nightmare for the parser.) Thu, 03 Nov 2022 15:42:02 +0000 Modernizing Fedora's C code https://lwn.net/Articles/913633/ https://lwn.net/Articles/913633/ khim <font class="QuotedText">&gt; The super hard part is configure tests silently failing and changing behaviour.</font> <p>Why is it hard? I have done such things before. They are tedious, sure, but “hard”? How? Why?</p> <p>Just create a wrapper which would call <code>gcc</code> twice (first with added <code>Werror=implicit-int -Werror=implicit-function-declaration</code> and then normally) and log commands somewhere if one call succeeds, other call fails.</p> <p>Maybe would be a good idea to also collect error messages and ensure they match, too.</p> <p>Then look on these logs and tweak source till they are empty.</p> <font class="QuotedText">&gt; The build failures in a particular package are easy if they're within its source code, they're not so easy if it's because of failed feature detection in either its configure script, or worse, another package's.</font> <p>That's why you use result of second call, the one without <code>-Werror</code> options. Only when you are sure there are no difference in options detection and you are sure there are no problems you turn these options <code>on</code> for real.</p> Thu, 03 Nov 2022 14:03:38 +0000 Modernizing Fedora's C code https://lwn.net/Articles/913632/ https://lwn.net/Articles/913632/ epa <div class="FormattedComment"> It's a shame, because I find the old style a bit more readable. It would have been better for ANSI C to start doing the type checking even when the old style was used, rather than forcing a switch to a different syntax to get checking of function arguments. Much too late now of course.<br> </div> Thu, 03 Nov 2022 13:30:04 +0000 Modernizing Fedora's C code https://lwn.net/Articles/913622/ https://lwn.net/Articles/913622/ mpr22 <div class="FormattedComment"> <span class="QuotedText">&gt; Old-style function definitions</span><br> <p> Dear God. I think even Nethack, once the great swamp of compatibility cruft for antediluvian K&amp;R 1st edition compilers and steam-driven Unices, has got rid of those now!<br> </div> Thu, 03 Nov 2022 11:05:18 +0000 Modernizing Fedora's C code https://lwn.net/Articles/913600/ https://lwn.net/Articles/913600/ xen0n <div class="FormattedComment"> As an interesting side note, the ongoing effort of porting various Linux distros (including Gentoo of course) to the emerging LoongArch architecture would actually help here. Because the *first* LLVM/Clang to work on the architecture would be version 16. We already have caught many gcc-13-related changes in the wild, for that matter, and will surely continue to do so with clang-16.<br> <p> And I find it so much more rewarding that work on such a niche architecture could benefit the Linux ecosystem as a whole. Keep on compiling!<br> </div> Thu, 03 Nov 2022 06:04:17 +0000 Modernizing Fedora's C code https://lwn.net/Articles/913594/ https://lwn.net/Articles/913594/ sam_c <div class="FormattedComment"> Sorry, it ate the mailing list post: <a href="https://archives.gentoo.org/gentoo-dev/message/dd9f2d3082b8b6f8dfbccb0639e6e240">https://archives.gentoo.org/gentoo-dev/message/dd9f2d3082...</a><br> </div> Thu, 03 Nov 2022 00:59:10 +0000 Modernizing Fedora's C code https://lwn.net/Articles/913592/ https://lwn.net/Articles/913592/ sam_c <div class="FormattedComment"> Thanks for shining a light on the ongoing hassle we're facing. I'm working on the effort for Gentoo and have spoken with Florian about his side over in Fedora land. I wrote a bit about the situation for Gentoo at <a href="https://archives.gentoo.org/gentoo-dev/message/dd9f2d3082b8b6f8dfbccb0639e6e240.">https://archives.gentoo.org/gentoo-dev/message/dd9f2d3082...</a><br> <p> So far, in Gentoo, we've come across across several interesting bugs:<br> - SDL thought no joystick support existed (<a href="https://github.com/libsdl-org/SDL/pull/6217">https://github.com/libsdl-org/SDL/pull/6217</a>)<br> - zsh stopped installing any extensions and would hang at runtime (<a href="https://bugs.gentoo.org/869539">https://bugs.gentoo.org/869539</a>)<br> - apr would install but cause apr-util build to loop forever (<a href="https://bugs.gentoo.org/870004">https://bugs.gentoo.org/870004</a>)<br> <p> Ultimately, as noted in the article (and in various talks of late, like Florian's talk at Plumbers in 2021: <a href="https://youtu.be/q5itHU2T5xU?t=2579">https://youtu.be/q5itHU2T5xU?t=2579</a>), these issues often caused runtime problems before they became fatal in Clang 16 &amp; possibly the future GCC 14 release. They need to be fixed, but they're still not easy to find.<br> <p> The super hard part is configure tests silently failing and changing behaviour. I'm playing with diffing `configure` output before/after, while Florian is looking to specifically log errors from the compiler (by patching it) for missing prototypes where we *know* on a given system they're present (and hence a missing include or whatever, not just a deliberately missing function that's BSD-only).<br> <p> The build failures in a particular package are easy if they're within its source code, they're not so easy if it's because of failed feature detection in either its configure script, or worse, another package's.<br> <p> Florian and I have started a mailing list (which we haven't posted to yet, but I'd rather plug it now because we really need the help on this) at lists.linux.dev: <a href="https://lore.kernel.org/c-std-porting/">https://lore.kernel.org/c-std-porting/</a>. Please consider subscribing and helping out if you're comfortable with C.<br> </div> Thu, 03 Nov 2022 00:58:37 +0000