Cross compile in the direct way #3518
Xuanwo
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Background
Databend used
crossfor cross-compilation for some time. But we have met many problems:crossitself is lack of maintenance, and will be transferred out of rust embedded team: RFC for moving cross to its own organisation rust-embedded/wg#590Is it really that hard to cross-compile? You know, this is a problem that has existed since the beginning of the C language.
So I did some research. Finally, I found out that: This problem would be particularly simple if we only needed to support specific architectures. For example, let's say we only support Debian architectures that support cross-compilation.
Setup
Let me show you how I support cross build
aarch64-unknown-linux-gnuonx86_64:We can use docker to prevent installing too many dependencies on our host machine:
Let me explain them one by one.
FROM rust:latestUse the rust upstream image, so that we don't need to set the basic rust environment.
RUN dpkg...Install cross compile required deps, as explained in #3371
ENV PKG_CONFIG_ALLOW_CROSS=1Make
pkg-configallow cross-build (Yes, we have set up the dependencies)COPY cargo-config /usr/local/cargo/configWe need to use the correct linker, the config content is:
Showtime
So we can build databend now:
--network=hostuse the host network so my HTTP proxy will works correctly.--rm -v "$PWD":/usr/src/myapp -w /usr/src/myappborrowed from rust upstream image.How do you feel?
Next step
cross?cross?Beta Was this translation helpful? Give feedback.
All reactions