farsightsec / wdns

low-level DNS library
Apache License 2.0
18 stars 5 forks source link

Try using C99 #66

Closed mcrawforddt closed 9 months ago

mcrawforddt commented 9 months ago

Use C99 when compiling.

reedjc commented 9 months ago

We need to support clang and other compilers. We also need to support overriding CC.

mcrawforddt commented 9 months ago

CC can be overridden here, but since you mentioned another autoconf directive in slack I'll try including that one instead.

edmonds commented 9 months ago

Personally I'd just update to autoconf 2.70 and keep using AC_PROG_CC.

edmonds commented 9 months ago

@mcrawforddt You don't need to tamper with CFLAGS at all. All you need to do is use a new enough autoconf and call the AC_PROG_CC macro.

https://www.gnu.org/software/autoconf/manual/autoconf-2.71/html_node/C-Compiler.html#index-AC_005fPROG_005fCC-1

If necessary, options are added to CC to enable support for ISO Standard C features with extensions, preferring the newest edition of the C standard that is supported. Currently the newest edition Autoconf knows how to detect support for is ISO C 2011. After calling this macro you can check whether the C compiler has been set to accept standard C by inspecting the shell variable ac_prog_cc_stdc. Its value will be ‘c11’, ‘c99’, or ‘c89’, respectively, if the C compiler has been set to use the 2011, 1999, or 1990 edition of the C standard, and ‘no’ if the compiler does not support compiling standard C at all.

mcrawforddt commented 9 months ago

I think the problem we're hitting is that autoconf on centos7 is not new enough. I tried using that macro, and it didn't build correctly there. The current version builds on all supported targets, including centos7 and rocky9.

edmonds commented 9 months ago

I think the problem we're hitting is that autoconf on centos7 is not new enough. I tried using that macro, and it didn't build correctly there. The current version builds on all supported targets, including centos7 and rocky9.

The autoconf version only really matters on the development environment where the tarballs are produced (where you run make dist), and that can be as up-to-date as necessary. Then the release tarballs can be used to build on the older "EL" platforms and you get the benefits of the up-to-date autoconf macros. The whole point of autoconf is that it produces an independent, redistributable configure script that embeds the current versions of the macros.

If you're trying to run autoreconf on every end user platform that you're trying to support, that's not the way autoconf is supposed to be used and it will be frustrating because the older "EL" platforms ship with old versions of autoconf, like CentOS 7 apparently shipped with autoconf 2.69 which is more than a decade old at this point.

mcrawforddt commented 9 months ago

We'll examine alternatives for updating the build process. Right now, everything that isn't an extremely out of date version works, so we'll carry a patch for the short window of support for centos7 while we look at cross-platform improvements.