How can I use Clang to compile a project? And I load pass.so
simulateneously.
The following command can compile a single .cpp
file.
clang++
-flegacy-pass-manager
-Xclang
-load
../build/skeleton/libSkeletonPass.so // here is pass.so
-c
main.cpp
And my problem is: how can I compile a project using similar approch?
A project, such as, main.cpp dep1.cpp dep2.cpp dep3.cpp
.
pogo59
April 27, 2022, 4:04pm
#2
Whatever build system you would normally use to build the project should let you specify command-line options to use when invoking the compiler.
jrtc27
April 27, 2022, 5:06pm
#3
I don’t think -Xclang -load foo.so
works, pretty sure it needs to be -Xclang -load -Xclang foo.so
.
Yes, you are right. I made a typo. And I wanna know how to compile a project in a similar way. Could you give me some recommendations? Tks~
pogo59:
Whatever build system
I used VSCode, so I have to write command line myself. So do you have any suggestion for build system automatically compiling a project with Clang? Tks!
Switch to a proper build system. Something like CMake or Make.
tobiashieta:
CMake or Make
Sorry, I think cmake also need to write commd?
So, how to write CMakeLists.txt
for clang to compie a project?Tks!
I don’t think this forum is the best for CMake help. You can find many good tutorials on cmake.org and similar sites.