apollo icon indicating copy to clipboard operation
apollo copied to clipboard

Compile apollo using wllvm

Open E00N777 opened this issue 2 years ago • 3 comments

I want to use llvm to compile apollo (no matter which version), but apollo uses bazel. I tried to modify the .bazelrc and .apollo.bazelrc and tools/bazel.rc files to change bazel's default compiler to llvm, but I still encountered Got this error: (04:48:24) ERROR: /apollo/.cache/bazel/540135163923dd7d5820f3ee4b306b32/external/zlib/BUILD.bazel:31:11: C++ compilation of rule '@zlib//:zlib' failed (Exit 1): wllvm failed: error executing command (cd /apollo/.cache/bazel/540135163923dd7d5820f3ee4b306b32/execroot/apollo && \ exec env - \ LD_LIBRARY_PATH=/usr/local/libtorch_gpu/lib:/usr/local/nvidia/lib:/usr/local/nvidia/lib64 \ PATH=/apollo/modules/teleop/common/scripts:/apollo/bazel-bin/modules/tools/visualizer:/apollo/bazel-bin/cyber/tools/cyber_launch:/apollo/bazel-bin/cyber/tools/cyber_service:/apollo/bazel-bin/cyber/tools/cyber_node:/apollo/bazel-bin/cyber/tools/cyber_channel:/apollo/bazel-bin/cyber/tools/cyber_monitor:/apollo/bazel-bin/cyber/tools/cyber_recorder:/apollo/bazel-bin/cyber/mainboard:/usr/local/cuda/bin:/opt/apollo/neo/bin:/opt/apollo/sysroot/bin:/usr/local/nvidia/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \ PWD=/proc/self/cwd \ /usr/local/bin/wllvm -U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -fcolor-diagnostics -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections -fdata-sections -MD -MF bazel-out/host/bin/external/zlib/_objs/zlib/uncompr.pic.d '-frandom-seed=bazel-out/host/bin/external/zlib/_objs/zlib/uncompr.pic.o' -fPIC -iquote external/zlib -iquote bazel-out/host/bin/external/zlib -isystem external/zlib/zlib/include -isystem bazel-out/host/bin/external/zlib/zlib/include -g0 -mavx2 -Wno-unused-variable -Wno-implicit-function-declaration -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c external/zlib/uncompr.c -o bazel-out/host/bin/external/zlib/_objs/zlib/uncompr.pic.o) Execution platform: @local_config_platform//:host CRITICAL: No compiler set. Please set environment variable LLVM_COMPILER I tried export LLVM_COMPILER=clang but it's uselness.

Do I need to redefine the tool chain?

Has anyone tried using llvm to compile apollo and extract the bitcode? I need help

E00N777 avatar Nov 19 '23 10:11 E00N777

Apollo is compiled by GCC-7 by default. Here is a repository based on Baidu Apollo 3.0 and 5.0 that uses LLVM for compilation, but I'm not sure if it's still usable. Currently, a Ph.D. student from Nanjing University, China and I have been unable to reproduce the build, and we don't know where the problem lies. It doesn't directly specify Clang in the Bazel script but instead uses the python wllvm package https://github.com/travitch/whole-program-llvm, to extract the LLVM Intermediate Representation for the purpose of static analysis (model checking). https://github.com/h1994st/ApolloLLVMCompile Anyone has suggestions?

lilejin322 avatar Aug 13 '24 08:08 lilejin322

don't use wllvm,just use llvm compile apollo directly. if you need instrumentation when you are compiling,you have to combine your pass into llvm. don't use old version llvm and apollo,there will be a lot of problems. I have successfully compiled apollo 7.0 with bazel and llvm(maybe6.0 I forget)

On Tue, Aug 13, 2024, 4:22 PM Lejin Li @.***> wrote:

Here is a repository based on Baidu Apollo 3.0 and 5.0 that uses LLVM for compilation, but I'm not sure if it's still usable. Currently, a Ph.D. student from Nanjing University, China and I have been unable to reproduce the build, and we don't know where the problem lies. This guide is quite strange; it doesn't directly specify Clang in the Bazel script but instead uses the python wllvm package, to extract the LLVM Intermediate Representation for the purpose of static analysis (model checking). https://github.com/h1994st/ApolloLLVMCompile Anyone has suggestions?

— Reply to this email directly, view it on GitHub https://github.com/ApolloAuto/apollo/issues/15199#issuecomment-2285653905, or unsubscribe https://github.com/notifications/unsubscribe-auth/BDKQFSCCN6UWW7UYPIYUS7LZRG65BAVCNFSM6AAAAABMNXRROCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOBVGY2TGOJQGU . You are receiving this because you authored the thread.Message ID: @.***>

E00N777 avatar Aug 25 '24 16:08 E00N777

don't use wllvm,just use llvm compile apollo directly. if you need instrumentation when you are compiling,you have to combine your pass into llvm. don't use old version llvm and apollo,there will be a lot of problems. I have successfully compiled apollo 7.0 with bazel and llvm(maybe6.0 I forget)

Compile Baidu Apollo 6.0 | 7.0 | 8.0 | 9.0 using wllvm: https://github.com/lilejin322/ApolloLLVMCompile

lilejin322 avatar Jul 29 '25 04:07 lilejin322