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

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Hubert Tong via cfe-dev

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?

 

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
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Can't compile C++ complex type number example after building Clang with non-standard gcc installation (AARCH64)

Hubert Tong via cfe-dev
Hi Simone,

Have you tried compiling with -save-temps and looking at the preprocessor output (.ii) ?

Csaba


On Mon, 7 Sep 2020 at 23:27, Simone Atzeni via cfe-dev <[hidden email]> 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?

 

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
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev


--
You can get very substantial performance improvements
by not doing the right thing. - Scott Meyers, An Effective C++11/14 Sampler
So if you're looking for a completely portable, 100% standards-conformant way
to get the wrong information: this is what you want. - Scott Meyers (C++TDaWYK)

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Can't compile C++ complex type number example after building Clang with non-standard gcc installation (AARCH64)

Hubert Tong via cfe-dev
In reply to this post by Hubert Tong via cfe-dev
On Mon, 7 Sep 2020, 14:27 Simone Atzeni via cfe-dev, <[hidden email]> 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
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Can't compile C++ complex type number example after building Clang with non-standard gcc installation (AARCH64)

Hubert Tong via cfe-dev

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 <[hidden email]>
Sent: Monday, September 7, 2020 4:21 PM
To: Simone Atzeni <[hidden email]>
Cc: [hidden email]
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, <[hidden email]> 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
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev


_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Can't compile C++ complex type number example after building Clang with non-standard gcc installation (AARCH64)

Hubert Tong via cfe-dev
On Mon, 7 Sep 2020 at 17:18, Simone Atzeni <[hidden email]> wrote:

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).


This probably means that your system didn't have a C++ <complex.h> that Clang could find before, and so the C <complex.h> was picked up instead.
 

Thanks.

Simone

 

From: Richard Smith <[hidden email]>
Sent: Monday, September 7, 2020 4:21 PM
To: Simone Atzeni <[hidden email]>
Cc: [hidden email]
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, <[hidden email]> 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
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev


_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev