i'm using this guide: http://llvm.org/releases/3.0/docs/WritingAnLLVMPass.html for creating an llvm pass, but i have the following error when i use
opt -load ../../../Debug+Asserts/lib/Hello.so -hello < hello.bc > /dev/null
Error opening '../../../Release/lib/Hello.so': ../../../Release/lib/Hello.so: undefined symbol: _ZN4llvm12PassRegistry12registerPassERKNS_8PassInfoEb
-load request ignored.
opt: Unknown command line argument '-hello'. Try: 'opt -help'
note that i haven't the folder "Debug+Asserts" but "Release"
someone know what's the problem?
maybe because for creating the Hello.bc file i use llvm-clang instead of llvm-gcc? (this guide says to use llvm-gcc but it doesn'n work: http://llvm.org/releases/3.0/docs/GettingStarted.html#tutorial) or maybe because i have opt version 2.8 while i'm using llvm-3.0 ?
You should use the same version of opt as the LLVM version you're building the pass against.
Related
I need to use meson build system, for a project, I am forced to give CXXFLAGS via, meson.build itself. According to offical meson documentation To add compiler options via add_project_arguments meson I need to give clang and opt options in the meson.build itself. This is how I do it in meson.build, I am supposed to use clang-14. The problem is as per the error log file, It accepts the clang options ( Those not prefixed by -mllvm ) like -O3 or -ftlo, because I see no error log for these clang options, but the options with ( -mllvm -some_opt_option ) gives me error clang-14: error: unknown argument: 'some_opt_option' how do I get past this error, and make meson to accept these opt options and not just clang options.
if cc.get_id() == 'clang'
# Thread safety annotation
add_project_arguments('-O3', language : 'cpp')
I am a llvm beginner. I run the command:
../llvm-6.0.0.src/build/bin/opt -load=./test.so -Hello < main.bc
according to the tutorial but got the error:
opt: CommandLine Error: Option 'use-dbg-addr' registered more than once!
LLVM ERROR: inconsistency in registered CommandLine options
I googled again and again, and got nothing about this error.
You need a LLVM build with shared libraries enabled, which corresponds to cmake options BUILD_SHARED_LIBS=On. You can check what type of LLVM you have installed by either checking its lib directory or executing:
llvm-config --shared-mode
This should report shared; anything else will require you to recompile.
I am developing an LLVM pass and want to run it as a plugin via the Clang LLVM driver:
clang -Xclang -load -Xclang myPlugin.so ...
At first I got an error similar to that described here
undefined symbol for self-built llvm opt?
After applying the flag -D_GLIBCXX_USE_CXX11_ABI=0 as suggested, I'm getting this error:
error: unable to load plugin 'myPlugin.so': 'myPlugin.so: undefined symbol: _ZNK4llvm12FunctionPass17createPrinterPassERNS_11raw_ostreamERKSs
This page suggests that there may be an ABI compatibility issue (which I don't fully understand)
http://clang-developers.42468.n3.nabble.com/Loading-Static-Analyzer-plugin-fails-with-CommandLine-Errors-td4034194.html
My objective is to compile the pass with either GCC or Clang and run it with the system Clang installation (Ubuntu 16.04, LLVM 3.8) rather than building Clang/LLVM from source.
The problem could come from multiple clang installations. The clang version you have used to compile your plugin may be different from the clang called in
clang -Xclang -load -Xclang myPlugin.so ...
If you use cmake to build your plugin, then
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
will generate the file compile_commands.json that will contain the llvm version you have used. bear make or make -n are alternatives if you don't use cmake for your plugin.
If compile_commands.json contains for example
"command": "c++ -c -I/usr/lib/llvm-4.0/include ..."
and if clang -v is clang version 3.8.0, you are likely to obtain this error message especially if llvm::FunctionPass::createPrinterPass is in llvm-4.0 and not in llvm-3.8.
A solution may be to compile with
clang-xxx -Xclang -load -Xclang myPlugin.so ...
where clang-xxx contains the llvm-xxx that is referenced in compile_commands.json.
I was receiving that error because first argument I passed into the RegisterPass had the same name as the pass itself:
static RegisterPass<MyPass> X("MyPass", "DPVariableNamePass", false, false);
Changing it fixed the issue:
static RegisterPass<MyPass> X("my-pass", "DPVariableNamePass", false, false);
Maybe it helps
I was trying an openmp code with clang compiler as specified in
http://clang-omp.github.io/
I downloaded the code via git and did make and make install. It successfully installed the clang compiler with openmp support. But when I try to compile a sample code (specified in the above link), I get the following error :
/usr/bin/ld: cannot find -liomp5
I did not specify path to include and lib as mentioned in the site, but I intend to specify them while compiling on command line with -L and -I options.
$clang -I/usr/lib/gcc/i686-linux-gnu/4.6/include -fopenmp test.c -o test
However, I could not find path for iomp5 lib and hence I got the above error. Can someone please tell me how to resolve this?
At first you need to build openmp library libiomp5. You can take the latest source code here
http://llvm.org/svn/llvm-project/openmp/trunk/
I am using Ubuntu 12.10 with a gcc version 4.6.3. I am trying to build my code and getting an error when using 'make' command
g++: error: unrecognized option ‘--as-needed’
My Makefile looks as follows:
LFLAGS = -Wl,-rpath,. -Wl,-rpath-link,../bin --as-needed
LDFLAGS = $(RPATH) $(RPATHLINK) -L$(USRLIB) --as-needed
Previously this code was successfully building on RedHat Linux. But now I need to run this code on Ubuntu.
If anyone knows about this. Please help
Regards
Gaurav
#FatalError is right
And also better late than never answering this question.
you need to use -Wl,--as-needed
Seems like you had an extra space between the ld specifier "-Wl" and the option to be passed to ls "--as-needed". For the linker to get the extra option from g++ command, it should be "-Wl,--as-needed"