From autoconf Mon Dec 11 15:55:55 2023 From: "David A. Wheeler" Date: Mon, 11 Dec 2023 15:55:55 +0000 To: autoconf Subject: Will autoconf work with -Werror=implicit-int and -Werror=implicit-function-declaration ? Message-Id: X-MARC-Message: https://marc.info/?l=autoconf&m=170231022311100 All: Will the latest version of autoconf work by default when the compiler = has these options enabled?: -Werror=3Dimplicit-int -Werror=3Dimplicit-function-declaration If not, can that be fixed at least in the most common cases (e.g., by = declaring exit() so it's no longer an implicit function nor using an = implicit int)? Below are details. Sorry for the late notice/question. I realize an autoconf update is = about to be released. However, I *just* became aware of this issue. This = particularly hints clang, because a late change in Clang appears to = cause implicit function declarations to be errors by default. = Details/context below. --- David A. Wheeler =3D=3D=3D Details =3D=3D=3D The Open Source Security Foundation (OpenSSF) has developed "Compiler Options Hardening Guide for C and C++" = which gives recommended compiler flags to detect/counter bugs = (especially vulnerabilities). The guide is in active development. We want to strongly encourage using = various options to detect bugs as soon as possible (ideally at compile time when that's = practical). A proposed change here: = suggests implementing the Fedora project's "Porting to Modern C" where "modern" is C99 (~24 years old). That Fedora document recommends turning on "-Werror=3Dimplicit-int", = however, it notes that: >... introducing errors for these constructs (as required by C99) alters = the result of autoconf configure checks. Quite a few such checks use an = implicitly declared exit function, for instance. These failures are not = really related to the feature under test. If the build system is well = written, the build still succeeds, the relevant features are = automatically disabled in the test suite and removed from reference ABI = lists, and it's not immediately apparent that feature is gone. = Therefore, some care is needed that no such alterations happen, and = packages need to be ported to C99. Various tools for this porting = activity are being developed to support this proposal. = Cross-distribution collaboration will help as well, sharing patches and = insights. *Another* proposed change to the OpenSSF guide *also* recommends adding "-Werror=3Dimplicit-function-declaration", in = this case because it's listed in "Florian Weimer's 2018 article "Recommended compiler and linker flags = for GCC" = . However, there are discussions that suggest that autoconf struggles when = -Werror=3Dimplicit-function-declaration is enabled (e.g., by clang = default): = https://discourse.llvm.org/t/configure-script-breakage-with-the-new-werror= -implicit-function-declaration/65213/5 > "We=E2=80=99ve noticed some worrying problems resulting from the late = change in Clang that causes implicit function declarations to be errors = by default 105. It seems that many configure (e.g. autoconf) scripts = were silently relying on the old behavior, and the change is causing = them to misfire." It'd be great if autoconf "just worked" when enabling "modern C" = options, especially "-Werror=3Dimplicit-int" and "-Werror=3Dimplicit-function-declaration".=