Code compilation under g++ compared to clang++ - c++

I have some code that compiles in -m32, -m64, -mx32 in g++, in clang++ it compiles -m32, -m64, -mx32 but -mx32 is unable to link emitting the error copied bellow.
Does any body has experience with the above situation ?
What should I look at ? Is a bug of clang++ ?
fatal error: error in backend: Cannot select: 0x5bd7ec8: ch = brind
0x5ba0fc8:1, 0x5ba0fc8 [ORD=1] [ID=10] 0x5ba0fc8: i32,ch = load
0x5ba3d20:1, 0x5c8c1e0, 0x5ba3f30 [ORD=1] [ID=9]
0x5c8c1e0: i32 = add 0x5bd80d8, 0x5ba33d8 [ORD=1] [ID=8] 0x5bd80d8:
i32 = shl 0x5ba3d20, 0x5ba30c0 [ORD=1] [ID=7] 0x5ba3d20: i32,ch =
CopyFromReg 0x56b46c0, 0x5bd6678 [ORD=1] [ID=5] 0x5bd6678: i32 =
Register %vreg188 [ID=1] 0x5ba30c0: i8 = Constant<2> [ID=4] 0x5ba33d8:
i32 = X86ISD::Wrapper 0x5bd6ca8 [ID=6] 0x5bd6ca8: i32 =
TargetJumpTable<0> [ID=3] 0x5ba3f30: i32 = undef [ID=2] In function:
_Z8toString3objbbi clang: error: clang frontend command failed with exit code 70 (use -v to see invocation) Ubuntu clang version
3.5.0-4ubuntu2 (tags/RELEASE_350/final) (based on LLVM 3.5.0) Target: x86_64-pc-linux-gnux32 Thread model: posix clang: note: diagnostic
msg: PLEASE submit a bug report to http://bugs.debian.org/ and include
the crash backtrace, preprocessed source, and associated run script.
clang: note: diagnostic msg:
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: Preprocessed
source(s) and associated run script(s) are located at: clang: note:
diagnostic msg: /tmp/main-eedcc1.cpp clang: note: diagnostic msg:
/tmp/main-eedcc1.sh clang: note: diagnostic msg:
******************** napl21.mk:91: recipe for target 'Debug/main.cpp.o' failed make[1]: * [Debug/main.cpp.o] Error 70
make[1]: Leaving directory '/home/gk/.codelite/workspace01/napl21'
Makefile:4: recipe for target 'All' failed make: * [All] Error 2 0
errors, 8 warnings

Versions of your g++ and clang++ could be quite useful. Architecture as well.
One possible explanation could be that you are trying to link binary objects and/or libraries, produced by different versions of compilers. For instance, some SUN C libraries with clang libraries.
Practical steps:
Do clean build
Get latest clang
Compile and see if it works
If not, come back with more details as per above :)

Related

SeaBIOS cannot be compiled for qemu on Andriod/Termux

When I tried to compile SeaBIOS version 1.14 with a little touch of SMBIOS cpu speed modifications I got 3 errors, and a warning, here's the errors and warnings I got
clang-14: error: unknown argument: '-mpreferred-stack-boundary=2'
clang-14: error: unsupported option '-freg-struct-return' for target 'armv7a-unknown-linux-android24'
clang-14: error: the clang compiler does not support '-march=i386'
clang-14: warning: optimization flag '-fno-merge-constants' is not supported [-Wignored-optimization-argument]
make: *** [Makefile:141: out/src/misc.o] Error 1
SeaBIOS is an x86 program, and you appear to be trying to compile it with a compiler that creates Arm binaries. You need to use an x86 compiler (possibly a cross-compiler, if you really want to compile it on an Arm host).

I am getting Cmake compiler error "-lc++ and -lSystem"

Im trying to compile an c++ code using CMake but Im facing these errors ?
Couldnt manage to find any related content for these 2.
CMakeError.log is:
Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler: /Library/Developer/CommandLineTools/usr/bin/cc
Build flags:
Id flags:
The output was:
1
ld: library not found for -lSystem
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler: /Library/Developer/CommandLineTools/usr/bin/c++
Build flags:
Id flags:
The output was:
1
ld: library not found for -lc++
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Checking whether the ASM compiler is GNU using "--version" did not match "(GNU assembler)|(GCC)|(Free Software Foundation)":
Apple clang version 12.0.0 (clang-1200.0.32.28)
Target: x86_64-apple-darwin20.1.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
Im using Mac, OS X version: 11.0.1 and Apple clang version 12.0.0 (clang-1200.0.32.28)
Thanks in advance, but Im probably going to need some extra detailed information since it seems like not gonna get fixed by a simple version update..

ffmpeg armv7s compile segmentation fault

I use https://github.com/kewlbear/FFmpeg-iOS-build-script to compile ffmpeg,
but when i try to compile, for armv7s architecture i have next error
all other archs compile fine
clang: error: unable to execute command: Segmentation fault: 11 clang:
error: clang frontend command failed due to signal (use -v to see
invocation) Apple LLVM version 6.1.0 (clang-602.0.49) (based on LLVM
3.6.0svn) Target: arm-apple-darwin14.3.0 Thread model: posix clang: note: diagnostic msg: PLEASE submit a bug report to
http://developer.apple.com/bugreporter/ and include the crash
backtrace, preprocessed source, and associated run script. clang:
note: diagnostic msg:
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: Preprocessed
source(s) and associated run script(s) are located at: clang: note:
diagnostic msg:
/var/folders/zk/wj2cn08s26x64nlzk3_kjnv80000gn/T/vp8-c6ec27.c clang:
note: diagnostic msg:
/var/folders/zk/wj2cn08s26x64nlzk3_kjnv80000gn/T/vp8-c6ec27.sh clang:
note: diagnostic msg:
******************** make: * [libavcodec/vp8.o] Error 254 make: * Waiting for unfinished jobs.... CC libavcodec/wmv2enc.o
Couple months ago all compiled without any errors.
Tried on couple versions of ffmpeg
Here is Clang -v
Apple LLVM version 6.1.0 (clang-602.0.49) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.3.0 Thread model: posix
and xcode version is Version 6.3.1 (6D1002)
I think i found a solution, as you can understand from this article http://www.cocoanetics.com/2014/10/xcode-6-drops-armv7s/ xcode doesn't have armv7s support for now, so armv7s will use armv7 version and it must not reduce performance.

Can not compile asterisk on OS X 10.9 Mavericks

I download the source code of asterisk on my macbook pro, which the OS X version is 10.9 ,then following the README.txt to compile it, but it failed ,and then I tried almost all the release version, but all the compiled results are the same, the compile error is as following,please help me to check it ,and how can I compile it on Mavericks; Appreciate!
ranlib libmxml.a gcc -o menuselect menuselect.o strcompat.o
menuselect_stub.o mxml/libmxml.a Generating input for menuselect
... menuselect/menuselect --check-deps menuselect.makeopts
menuselect/menuselect --check-deps menuselect.makeopts
Generating embedded module rules ...
[CC] stereorize.c ->
stereorize.o error: invalid value '6' in '-O6' make[1]: *
[stereorize.o] Error 1 make: [utils] Error 2
"-O4" nor "-O3" work...
sh-3.2# make ASTCFLAGS="-O4" [LD] chan_iax2.o iax2-parser.o iax2-provision.o -> chan_iax2.so
ld: lto: could not merge in
iax2-parser.o because 'Linking globals named 'ast_tvdiff_sec': symbol
multiply defined!', using libLTO version 'LLVM version 3.3svn, from
Apple Clang 5.0 (build 500.2.79)' for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: * [chan_iax2.so] Error 1
make: * [channels] Error 2

Compile errors with Assembler messages

I'm working with Point Cloud Library. It's mostly in C++ When I compile it, gives such error:
[ 0%] Building CXX object common/CMakeFiles/pcl_common.dir/src/intersections.cpp.o
In file included from /home/lv/pcl-trunk/common/include/pcl/point_types.h:301:0,
from /home/lv/pcl-trunk/common/include/pcl/common/impl/common.hpp:41,
from /home/lv/pcl-trunk/common/include/pcl/common/common.h:186,
from /home/lv/pcl-trunk/common/include/pcl/common/intersections.h:41,
from /home/lv/pcl-trunk/common/src/intersections.cpp:38:
/home/lv/pcl-trunk/common/include/pcl/impl/point_types.hpp:1009:68: warning: ‘SHOT’ is deprecated [-Wdeprecated-declarations]
/tmp/ccRLy4Re.s: Assembler messages:
/tmp/ccRLy4Re.s:2488: Error: no such instruction: `vfmadd312ss (%r9),%xmm2,%xmm1'
/tmp/ccRLy4Re.s:2638: Error: no such instruction: `vfmadd312ss (%rdx),%xmm2,%xmm1'
/tmp/ccRLy4Re.s:3039: Error: no such instruction: `vfmadd312ss (%rax,%r11,4),%xmm5,%xmm1'
/tmp/ccRLy4Re.s:3402: Error: no such instruction: `vfmadd312ss (%rax,%r11,4),%xmm5,%xmm1'
/tmp/ccRLy4Re.s:3534: Error: no such instruction: `vfmadd312ss (%rax,%rdx,4),%xmm1,%xmm2'
/tmp/ccRLy4Re.s:3628: Error: no such instruction: `vfmadd312ss (%rax,%rdx,4),%xmm1,%xmm2'
/tmp/ccRLy4Re.s:6103: Error: no such instruction: `vfmadd312ss (%r11),%xmm0,%xmm4'
/tmp/ccRLy4Re.s:6121: Error: no such instruction: `vfmadd312ss (%r11,%rbx,4),%xmm0,%xmm3'
/tmp/ccRLy4Re.s:6131: Error: no such instruction: `vfmadd312ss (%r11,%rbp,4),%xmm0,%xmm2'
/tmp/ccRLy4Re.s:6135: Error: no such instruction: `vfmadd312ss (%r11,%r13,4),%xmm0,%xmm1'
/tmp/ccRLy4Re.s:6344: Error: no such instruction: `vfmadd312ss (%r10),%xmm0,%xmm1'
/tmp/ccRLy4Re.s:11760: Error: no such instruction: `vfnmadd312ss (%rdx),%xmm0,%xmm0'
/tmp/ccRLy4Re.s:13976: Error: no such instruction: `vfmadd312ss (%rdi),%xmm0,%xmm1'
/tmp/ccRLy4Re.s:14125: Error: no such instruction: `vfmadd312ss (%rdx),%xmm0,%xmm1'
make[2]: *** [common/CMakeFiles/pcl_common.dir/src/intersections.cpp.o] Error 1
make[1]: *** [common/CMakeFiles/pcl_common.dir/all] Error 2
make: *** [all] Error 2
Could anyone tell me how to read these errors and give me some suggestions to solve?
You can use the command below to see what is your CPU (for the compiler):
gcc -march=native -Q --help=target | grep march
Then you can add your cpu type in the ccmake CMAKE_CXX_FLAGS option, for me:
CMAKE_CXX_FLAGS = -march=corei7-avx
You can add -march=native -mno-avx This worked for me.
In my CMakeLists.txt, I added the above to the CMAKE_CXX_FLAGS :
SET(CMAKE_CXX_FLAGS "-ggdb -O3 -fPIC -std=c++0x -march=native -mno-avx")
[Source can be found in this page.]
I faced this issue when trying to install glove.
The problem I faced was resolved by upgrading the g++ version installed in my ubuntu 14.04 machine.
My original g++ version was 4.6.4 and I upgraded it to the g++-5 (5.4.1 when I upgraded it).
There are error message from assembler, which means assembler doesn't know these assembly code, for example vfmadd312ss.
This happens when compiler generate some CPU only assembly code, for example intel E5 with arch core-avx2 have extra instruction set advanced vector extensions, but if "as" is tool old to know the new CPUs, this error would happen.
Try a new version Binutils, the latest is 2.29 now.
If you compile code from another tool, for example bazel, make sure it will call the new "as".
Have you tried using a different compiler?
I had assembler errors in a project using Point Cloud Library. It was possibly due to using Ubuntu 12.04 on an core i7 processor (see https://github.com/uzh-rpg/rpg_svo/issues/7).
I was able to compile by installing the 'clang' compiler
sudo apt-get install clang
and then running cmake with:
cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ .
I have met the same error messages,
I removed the -march=native from CXXFLAGS and CFLAGS in my makefile,
it works in my case. But since you didn't put out your makefile, I am not sure this will works in your case, any way you can have a try.
You probably need to enable advanced vector extensions when compiling (and use toolchain that supports this). Try -march=core-avx2 or something similar.
If you compiled library yourself, it is possible you need to configure it to not use AVX.