[coreutils/coreutils] Can't build with LLVM 5.0 (#11)
(too old to reply)
Paul Eggert
2017-09-22 17:55:58 UTC
[Responding to https://github.com/coreutils/coreutils/issues/11 and
CC'ing to bug-coreutils.]

Thanks for the heads-up. That's odd, as I just looked at the LLVM source
code, and cfe-5.0.0.src/lib/Frontend/InitPreprocessor.cpp defines
__GNUC__ to 4, whereas Coreutils (via Gnulib) doesn't use
__builtin_mul_overflow_p unless __GNUC__ is at least 7.

To help debug this, what is the value of __GNUC__ on your platform? For
example, what is the output of the following shell command?

echo __GNUC__ | /usr/bin/clang -E -

and what happens if you append this line to lib/mbsstr.c

"__GNUC__" __GNUC__

and then run this (long, one-line) command:

/usr/bin/clang -E -I. -I./lib -Ilib -I./lib -Isrc -I./src -Os -gdwarf-4 -Wstrict-aliasing=2 -pipe -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fPIC -flto -fPIC -D_GNU_SOURCE=1 lib/mbsstr.c >lib/mbsstr.i

and look at the last few lines of lib/mbsttr.i?

On Fedora 26, which has clang version 4.0.1 (tags/RELEASE_401/final), these commands say that __GNUC__ is 4, which is what I would expect.

Also, does the attached patch to lib/intprops.h work around the problem?
Paul Eggert
2017-09-24 23:03:52 UTC
here is the output form
# 1 "<stdin>"
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 316 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "<stdin>" 2
Can you investigate why __GNUC__ is 7 on your platform? As I said, I looked at
the LLVM/clang 5.0.0 source code and it sets __GNUC__ to 4.

Are you using a version of clang that uses the GNU C preprocessor? If so, that
would explain the problem. That combination is not supported, since preprocessor
variables must describe the compiler accurately.

Also, please try the patch to lib/intprops.h that I suggested. You can find it here: