ApolloAuto / apollo

An open autonomous driving platform
Apache License 2.0
25.01k stars 9.67k forks source link

[FEA] Bazel support for Cross-compile for multi-platform. #15314

Open ZhenshengLee opened 6 months ago

ZhenshengLee commented 6 months ago

Is your feature request related to a problem? Please describe.

From the doc, apollo9.0 needs to be compiled natively both in x86 and aarch64(which is Orin) ubuntu.

https://github.com/ApolloAuto/apollo/blob/803170c79e5ef12bafd0adb1b39273b576e4589a/RELEASE.md?plain=1#L1-L3

Due to the limited computing resource, it's better compiling the target in the super computer, which is x86 PC, or even in the cloud, to save the life.

Describe the solution you'd like

bazel, as the build system, have a good support to multi-platform builds. It's suggested to use platforms after the version of bazel7.0.2, which is the latest LTS version. https://bazel.build/extending/platforms https://bazel.build/extending/toolchains

Describe alternatives you've considered

There can be a qemu-based arm docker running in x86 PC to support compiling arm target natively, but the performance is not clear. https://martin-grigorov.medium.com/building-linux-packages-for-different-cpu-architectures-with-docker-and-qemu-d29e4ebc9fa5

Additional context Add any other context or screenshots about the feature request here.

There is a arm-docker-image for Nvidia Jetson AGX Series, which is https://catalog.ngc.nvidia.com/orgs/nvidia/containers/l4t-base/tags There is a x86-docker-image for Nvidia Drive AGX Series, which is https://developer.nvidia.com/drive/docker-containers

@daohu527 What's your idea?

briandbl commented 2 months ago

i think that clang cross-compile can solve the question. clang natively support the cross-compile. only config these configs flags --target and -mcpu. you can compile the arm execution file in the x86 host machine. but the main question, how to solve the thirdparty library and some cmake questions.

ZhenshengLee commented 2 months ago

clang natively support the cross-compile.

gcc supports cross-compile too and compiler chossing is another topic.

lilejin322 commented 2 weeks ago

clang natively support the cross-compile.

gcc supports cross-compile too and compiler chossing is another topic.

We’ve tried to alter the compiler by assigning wllvm (a wrapper for clang/clang++) to handle the compilation task in Apollo 7.0, but we still encountered too many problems. For a detailed discussion, see: https://github.com/ApolloAuto/apollo/issues/15199#issuecomment-2310262299