[cfe-dev] Can't compile C++ complex type number example after building Clang with non-standard gcc installation (AARCH64)

Simone Atzeni via cfe-dev cfe-dev at lists.llvm.org
Mon Sep 7 17:18:29 PDT 2020


Thanks Csaba and Richard.

I understand now, indeed if I add a “#define complex _Complex”, it compiles.
I can’t understand why before adding the define, it worked with Clang 5 and fails with Clang 8, though. Looks like this behavior changed after clang 5 (not sure about the exact version).

Thanks.
Simone

From: Richard Smith <richard at metafoo.co.uk>
Sent: Monday, September 7, 2020 4:21 PM
To: Simone Atzeni <satzeni at nvidia.com>
Cc: cfe-dev at lists.llvm.org
Subject: Re: [cfe-dev] Can't compile C++ complex type number example after building Clang with non-standard gcc installation (AARCH64)

External email: Use caution opening links or attachments

On Mon, 7 Sep 2020, 14:27 Simone Atzeni via cfe-dev, <cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>> wrote:
Hi,

I built Clang using my own build of gcc-7.4.0.

My cmake command looks like this:

toolchain=/path/to/gcc-7.4.0/install
CC=${toolchain}/bin/gcc
CXX=${toolchain}/bin/g++
cmake -G "Ninja"
-DGCC_INSTALL_PREFIX=${toolchain}
-DCMAKE_CXX_LINK_FLAGS="-Wl,-rpath,${toolchain}/lib64 -L${toolchain}/lib64"
-DTARGET_TRIPLE=aarch64-unknown-linux-gnu
-DCMAKE_INSTALL_PREFIX="${install_dir}"
-DCMAKE_BUILD_TYPE="Release"
-DLLVM_ENABLE_PROJECTS="clang;compiler-rt"
${src}

Then when I try to compile this example:

$ cat complex.cpp
#include <complex.h>

int main()
{
    typedef float complex kmp_cmplx32;
}

I get the the error below.
The include paths used by clang have `complex.h`, etc. The same example in “C” compiles fine.
What am I missing?
<complex.h> in C++ has nothing to do with <complex.h> in C, and in particular does not define a "complex" macro expanding to _Complex.
Thanks!
Simone

$ /home/sw/thirdparty/llvm-project/install/Linux_aarch64/llvm-8.0/bin/clang++  complex.cpp -v
clang version 8.0.1
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/sw/thirdparty/llvm-project/install/Linux_aarch64/llvm-8.0/bin
Found candidate GCC installation: /home/sw/thirdparty/llvm-project/toolchains/install/Linux_aarch64/gcc-7.4.0/lib/gcc/aarch64-unknown-linux-gnu/7.4.0
Selected GCC installation: /home/sw/thirdparty/llvm-project/toolchains/install/Linux_aarch64/gcc-7.4.0/lib/gcc/aarch64-unknown-linux-gnu/7.4.0
Candidate multilib: .;@m64
Selected multilib: .;@m64
"/home/sw/thirdparty/llvm-project/install/Linux_aarch64/llvm-8.0/bin/clang-8" -cc1 -triple aarch64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name complex.cpp -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -fuse-init-array -target-cpu generic -target-feature +neon -target-abi aapcs -fallow-half-arguments-and-returns -dwarf-column-info -debugger-tuning=gdb -v -resource-dir /home/sw/thirdparty/llvm-project/install/Linux_aarch64/llvm-8.0/lib/clang/8.0.1 -internal-isystem /home/sw/thirdparty/llvm-project/toolchains/install/Linux_aarch64/gcc-7.4.0/lib/gcc/aarch64-unknown-linux-gnu/7.4.0/../../../../include/c++/7.4.0 -internal-isystem /home/sw/thirdparty/llvm-project/toolchains/install/Linux_aarch64/gcc-7.4.0/lib/gcc/aarch64-unknown-linux-gnu/7.4.0/../../../../include/c++/7.4.0/aarch64-unknown-linux-gnu -internal-isystem /home/sw/thirdparty/llvm-project/toolchains/install/Linux_aarch64/gcc-7.4.0/lib/gcc/aarch64-unknown-linux-gnu/7.4.0/../../../../include/c++/7.4.0/backward -internal-isystem /usr/local/include -internal-isystem /home/sw/thirdparty/llvm-project/install/Linux_aarch64/llvm-8.0/lib/clang/8.0.1/include -internal-externc-isystem /usr/include/aarch64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -fdebug-compilation-dir /home/satzeni -ferror-limit 19 -fmessage-length 191 -fno-signed-char -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/complex-b60b10.o -x c++ complex.cpp -faddrsig
clang -cc1 version 8.0.1 based upon LLVM 8.0.1 default target aarch64-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
/home/sw/thirdparty/llvm-project/toolchains/install/Linux_aarch64/gcc-7.4.0/lib/gcc/aarch64-unknown-linux-gnu/7.4.0/../../../../include/c++/7.4.0
/home/sw/thirdparty/llvm-project/toolchains/install/Linux_aarch64/gcc-7.4.0/lib/gcc/aarch64-unknown-linux-gnu/7.4.0/../../../../include/c++/7.4.0/aarch64-unknown-linux-gnu
/home/sw/thirdparty/llvm-project/toolchains/install/Linux_aarch64/gcc-7.4.0/lib/gcc/aarch64-unknown-linux-gnu/7.4.0/../../../../include/c++/7.4.0/backward
/usr/local/include
/home/sw/thirdparty/llvm-project/install/Linux_aarch64/llvm-8.0/lib/clang/8.0.1/include
/usr/include/aarch64-linux-gnu
/usr/include
End of search list.
complex.cpp:5:26: error: expected ';' at end of declaration
    typedef float complex kmp_cmplx32;
                         ^
                         ;
1 error generated.
_______________________________________________
cfe-dev mailing list
cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200908/84560430/attachment-0001.html>


More information about the cfe-dev mailing list