C++ clang linker problem
I think you need to install a linker. GNU ld will be fine; you should be able to install it via your package manager.
Edit: There also is a LLVM linker, less popular, but which would run out of the box with clang once installed (just add it to the PATH
a re-run clang
.)
YAKOVM
Updated on June 18, 2022Comments
-
YAKOVM about 2 years
I want to do the analysis of debug information of C++ code . As I understand clang should be able to handle C++.
I tried
clang myFile.cpp
But I getclang: error: unable to execute command: program not executable clang error: linker command failed due to signal 1 (use -v to see invocation).
Update: After setting path for llvm-ld it partially works.I mean if I perform
clang C:myFile.cpp -S -emit-llvm -o -
it outputs some info .But it still fails forclang myFile.cpp
with errorclang version 2.9 (tags/RELEASE_29/final) Target: i686-pc-win32 Thread model: posix "C:/FrontEnd/llvm/bin/Debug/clang.exe" -cc1 -triple i686-pc-win32 -emit-obj -mrelax-all -disable-free -main-file-name BinarySearch_Kernels.cpp -mrelocation-model static -mdisable-fp-elim -masm-verbose -mconstructor-aliases -momit-leaf-frame-pointer -v -resource-dir C:/FrontEnd/l lvm/bin/Debug..\lib\clang\2.9 -ferror-limit 19 -fmessage-length 280 -fcxx-exceptions -fexceptions -fms-extensions -fmsc-version=1300 -fgnu-runtime -fdiagnostics-show-option -fcolor-diagnostics -o C:/Users/ilipov/AppData/Local/Temp/cc-563130.o -x c++ C:\clang\BinarySearch_Kernels .cpp clang -cc1 version 2.9 based upon llvm 2.9 hosted on i686-pc-win32 ignoring nonexistent directory "/usr/local/include" ignoring nonexistent directory "/usr/include" #include "..." search starts here: #include <...> search starts here: C:/FrontEnd/llvm/bin/Debug/../lib/clang/2.9/include C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include End of search list. "link.exe" -out:a.out -defaultlib:libcmt -nologo C:/Users/ilipov/AppData/Local/Temp/cc-563130.o clang: error: unable to execute command: program not executable clang: error: linker command failed due to signal 1 (use -v to see invocation)
Any case what I want to do is to get as full debug info as possible
For example for
class stamBase { public: int get1(){return 2;}; int get0(){return 0;} }; class stamDer : public stamBase { public: int get1(){return 1;} }; void func() { stamDer d; int x = d.get1(); }I get
From my investigation of clang debug info code I thought that I should get the info for stamBase too! How I run clang correctly for acceptig full debug info and preventing clang errorstarget datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f80:128:128-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32" target triple = "i686-pc-win32" %class.stamDer = type { i8 } define void @_Z4funcv() { entry: %d = alloca %class.stamDer, align 1 %x = alloca i32, align 4 %call = call i32 @_ZN7stamDer4get1Ev(%class.stamDer* %d) store i32 %call, i32* %x, align 4 ret void } define linkonce_odr i32 @_ZN7stamDer4get1Ev(%class.stamDer* %this) nounwind align 2 { entry: %this.addr = alloca %class.stamDer*, align 4 store %class.stamDer* %this, %class.stamDer** %this.addr, align 4 %this1 = load %class.stamDer** %this.addr ret i32 1 }
-
YAKOVM almost 13 yearsI use clang with llvm - is there anothe option for the linker?
-
Matthieu M. almost 13 years@Yakov: either ld or gold, both should work. ld has the advantage of being standard and cross-platform.
-
YAKOVM almost 13 yearsSuppose I installed llvm-ld or GNU-ld either-ld.how should I run clang now with my cpp file?
-
YAKOVM almost 13 yearsI have llvm-ld exe. It was added to path.But I still get the same error.
-
slaphappy almost 13 years@Yakov: You should run it with
-v
to have more details about your error, and post relevant information here. -
YAKOVM almost 13 years-cc1 -triple i686-pc-win32 -emit-obj -mrelax-all -disable-free -main-file-n lvm/bin/Debug\..\lib\clang\2.9 -ferror-limit 19 -fmessage-length 280 -fcxx-exceptions -fexceptions -fms-extensions.cpp clang -cc1 version 2.9 based upon llvm 2.9 hosted on i686-pc-win32 ignoring nonexistent directory "/usr/local/include" ignoring nonexistent directory "/usr/include" #include "..." search starts here: #include <...> search starts here: C:/llvm/bin/Debug/../lib/clang/2.9/include C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\\includ
-
slaphappy almost 13 yearsThis has been stripped by the comment system, can you put that into the question ?
-
echristo almost 13 yearsllvm-ld is not a general purpose linker and will not solve this problem. You need the developer tools for your platform installed in order to get binaries linked.