Failed to build libunwind the libcxx's __config header

I'm building LLVM with Clang, LLD, compiler-rt, libunwind, libcxx and libcxxabi.

I'm using GCC 7.1.1 and binutils 2.28.0 to build.

The compilation is aborted during libunwind build due to gcc not being able to parse libcxx's __config:

    /usr/bin/cc -DLLVM_BUILD_GLOBAL_ISEL -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iprojects/libunwind/src -I../projects/libunwind/src -Iinclude -I../include -I../projects/libunwind/include -I../projects/libcxx/include -fPIC -Werror=date-time -Wall -W -Wno-unused-parameter -Wwrite-strings -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-comment -ffunction-sections -fdata-sections -O3 -DNDEBUG -Werror=return-type -W -Wall -Wchar-subscripts -Wconversion -Wmissing-braces -Wno-unused-function -Wshadow -Wsign-compare -Wsign-conversion -Wstrict-aliasing=2 -Wstrict-overflow=4 -Wunused-parameter -Wunused-variable -Wwrite-strings -Wundef -Wno-error -pedantic -D_DEBUG -UNDEBUG -D_LIBUNWIND_IS_NATIVE_ONLY -fPIC -fno-exceptions -funwind-tables -std=c99 -fPIC -Werror=date-time -Wall -W -Wno-unused-parameter -Wwrite-strings -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-comment -ffunction-sections -fdata-sections -funwind-tables -MD -MT projects/libunwind/src/CMakeFiles/unwind_objects.dir/UnwindLevel1.c.o -MF projects/libunwind/src/CMakeFiles/unwind_objects.dir/UnwindLevel1.c.o.d -o projects/libunwind/src/CMakeFiles/unwind_objects.dir/UnwindLevel1.c.o -c ../projects/libunwind/src/UnwindLevel1.c
    In file included from ../projects/libcxx/include/inttypes.h:234:0,
                     from ../projects/libunwind/src/UnwindLevel1.c:22:
    ../projects/libcxx/include/__config:1140:18: error: missing binary operator before token "("
         __has_feature(attribute_availability_with_strict) && \
                      ^
The exact line that fails: https://github.com/llvm-mirror/libcxx/blob/master/include/__config#L1140

Does anyone else have this problem? What can possibly cause such error?

Regards,
Dmitry

Hi Dmitry,

Hi Tim,

You can find the preprocessed UnwindLevel1.c and UnwindLevel1-gcc-ext.c attached.

Regards,
Dmitry

UnwindLevel1-gcc-ext.c.pp (157 KB)

UnwindLevel1.c.pp (169 KB)

Hi Tim,

You can find the preprocessed UnwindLevel1.c and UnwindLevel1-gcc-ext.c attached.

I first sent it without compression, so it turned out to be over 100Kb and should be approved first before it can make to the mailing list, so I gzipped the files. Expect to get a duplicate of this message when the first copy gets its approval.

Regards,
Dmitry

preprocessed.tar.gz (54.7 KB)

The bug here is that the default definition for __has_feature is withing a
#ifdef __cplusplus block, but the usage at the end of the file is not.
You're processing the __config header in C, not C++, so that's why you're
seeing this and most people are not.

I'll fix this up over the weekend.

/Eric