Skip to content

Future-proof the ./configure script - #28

Open
orlitzky wants to merge 5 commits into
spamhaus:masterfrom
orlitzky:clang16
Open

Future-proof the ./configure script#28
orlitzky wants to merge 5 commits into
spamhaus:masterfrom
orlitzky:clang16

Conversation

@orlitzky

@orlitzky orlitzky commented Oct 3, 2022

Copy link
Copy Markdown
Contributor

Ref: https://bugs.gentoo.org/870412

It's very likely that clang-16 will have -Werror=implicit-function-declaration -Werror=implicit-int -Werror=strict-prototypes in CFLAGS by default. From what I understand, they tried to do it in a minor release of clang-15, but put it off until clang-16 because it breaks so many things.

In any case, the ./configure script for rbldnsd has some trouble with this. This series of commits fixes the issues on my Gentoo system and hopefully does not introduce new problems elsewhere.

There is still one build failure remaining with --enable-dso, but I don't think that feature was done cooking and I don't want to interrupt its slumber.

One of the "does the compiler work?" test programs uses

  int main(){ ... }

which disagrees with the usual definition of main(int, char**). To
ensure future compatibility with pedantic compilers, we correct the
test program.
Several of the ./configure test programs use

  int main(){ ... }

which disagrees with the usual definition of main(int, char**). To
ensure future compatibility with pedantic compilers, we correct the
test programs.
Two ./configure test programs declare and define

  int foo() { ... }

simultaneously. A strict reading of the C standard, however, requires
that we use

  int foo(void) { ... }

so that the definition agrees with what its prototype would be. This
can be detected by the "strict-prototypes" warning in gcc or clang.
To test if connect() is available (and in what library, if any, it
lives), the ./configure script was compiling and linking

  int main(int argc, char **argv) {
    gethostbyname();
    connect();
    return 0;
  }

This program, however, is invalid and fails to build with pedantic
compilers. The functions gethostbyname() and connect() are undefined;
and once we include the necessary headers to define them, they're
called incorrectly, with the wrong number/type of arguments.

The program is never actually *run*, so we fix this by including the
headers that define gethostbyname() and connect(), and then by
changing those two calls to pass correctly-typed junk arguments to the
functions.

This can be detected by the "implicit-function-declaration" warning in
gcc or clang.
@orlitzky

Copy link
Copy Markdown
Contributor Author

It looks like GCC is in on the fun, too. Some other recent references:

@orlitzky

Copy link
Copy Markdown
Contributor Author

Ping? The future is fast approaching :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant