configure error when CFLAGS='-Wall -Werror

From: Andy Fan <zhihuifan1213(at)163(dot)com>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: configure error when CFLAGS='-Wall -Werror
Date: 2024-06-21 02:26:53
Message-ID: 87r0crni8i.fsf@163.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Hi,

I relies on some compiler's check to reduce some simple coding issues, I
use clang 18.1.6 for now. however "CFLAGS='-Wall -Werror ' ./configure"
would fail, and if I run ' ./configure' directly, it is OK. I'm not sure
why it happens. More details is below:

(master)> echo $CC
clang
(master)> clang --version
clang version 18.1.6 (https://gitee.com/mirrors/llvm-project.git 1118c2e05e67a36ed8ca250524525cdb66a55256)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin

(master)> CFLAGS='-Wall -Werror ' ./configure

checking for clang option to accept ISO C89... unsupported
checking for clang option to accept ISO C99... unsupported
configure: error: C compiler "clang" does not support C99

In config.log, we can see:

configure:4433: clang -qlanglvl=extc89 -c -Wall -Werror conftest.c >&5
clang: error: unknown argument: '-qlanglvl=extc89'

and clang does doesn't support -qlanglvl.

in 'configure', we can see the related code is:

"""
for ac_arg in '' -std=gnu99 -std=c99 -c99 -AC99 -D_STDC_C99= -qlanglvl=extc99
do
CC="$ac_save_CC $ac_arg"
if ac_fn_c_try_compile "$LINENO"; then :
ac_cv_prog_cc_c99=$ac_arg
fi
rm -f core conftest.err conftest.$ac_objext
test "x$ac_cv_prog_cc_c99" != "xno" && break
done
rm -f conftest.$ac_ext
CC=$ac_save_CC

....

# Error out if the compiler does not support C99, as the codebase
# relies on that.
if test "$ac_cv_prog_cc_c99" = no; then
as_fn_error $? "C compiler \"$CC\" does not support C99" "$LINENO" 5
fi
"""

So my questions are:
1. based on the fact clang doesn't support '-qlanglvl' all the time, why
removing the CFLAGS matters.

2. If you are using clang as well, what CFLAGS you use and it works?
for example: IIRC, clang doesn't report error when a variable is set
but no used by default, we have to add some extra flags to make it.

--
Best Regards
Andy Fan

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message jian he 2024-06-21 02:30:08 minor doc issue in 9.16.2.1.1. Boolean Predicate Check Expressions
Previous Message Michael Paquier 2024-06-21 02:03:29 Re: PG 17 and GUC variables