-
Notifications
You must be signed in to change notification settings - Fork 10
ci: fix remote cross compilation #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| [build] | ||
| # Custom Docker images with proper build environment for native dependencies | ||
|
|
||
| [target.x86_64-unknown-linux-gnu] | ||
| dockerfile = "Dockerfile.cross-x86_64" | ||
|
|
||
| [target.aarch64-unknown-linux-gnu] | ||
| dockerfile = "Dockerfile.cross-aarch64" | ||
|
|
||
| [build.env] | ||
| passthrough = [ | ||
| "RUST_LOG", | ||
| "CARGO_TERM_COLOR", | ||
| ] |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,27 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| FROM ghcr.io/cross-rs/cross:main | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Install ARM64 cross-compilation toolchain | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| RUN apt-get update && \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| apt-get install -y \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| gcc-aarch64-linux-gnu \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| g++-aarch64-linux-gnu \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| libc6-dev-arm64-cross \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pkg-config-aarch64-linux-gnu \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| build-essential \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| clang \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| libclang-dev && \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| rm -rf /var/lib/apt/lists/* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Set up environment variables for ARM64 cross-compilation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Keep host compiler for build scripts, only set target-specific variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ENV CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ENV CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ENV AR_aarch64_unknown_linux_gnu=aarch64-linux-gnu-ar | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ENV STRIP_aarch64_unknown_linux_gnu=aarch64-linux-gnu-strip | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ENV PKG_CONFIG_aarch64_unknown_linux_gnu=aarch64-linux-gnu-pkg-config | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ENV BINDGEN_EXTRA_CLANG_ARGS="-I/usr/aarch64-linux-gnu/include -I/usr/include" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ENV CFLAGS_aarch64_unknown_linux_gnu="-I/usr/aarch64-linux-gnu/include -I/usr/include" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ENV CPPFLAGS_aarch64_unknown_linux_gnu="-I/usr/aarch64-linux-gnu/include -I/usr/include" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ENV JEMALLOC_SYS_WITH_LG_PAGE=16 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ENV PKG_CONFIG_ALLOW_CROSS=1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+15
to
+27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Environment-variable inconsistency will confuse Cross / bindgen For x86_64 you used a target-scoped variable Align naming and avoid accidental host pollution: -ENV BINDGEN_EXTRA_CLANG_ARGS="-I/usr/aarch64-linux-gnu/include -I/usr/include"
+ENV BINDGEN_EXTRA_CLANG_ARGS_aarch64_unknown_linux_gnu="-I/usr/aarch64-linux-gnu/include -I/usr/include"Do the same for π Committable suggestion
Suggested change
π€ Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| FROM ghcr.io/cross-rs/cross:main | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| # Install additional build tools and headers | ||
| RUN apt-get update && \ | ||
| apt-get install -y \ | ||
| build-essential \ | ||
| pkg-config \ | ||
| libclang-dev \ | ||
| clang && \ | ||
| rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Set up environment variables for x86_64 cross-compilation | ||
| ENV CC_x86_64_unknown_linux_gnu=x86_64-linux-gnu-gcc | ||
| ENV CXX_x86_64_unknown_linux_gnu=x86_64-linux-gnu-g++ | ||
| ENV AR_x86_64_unknown_linux_gnu=x86_64-linux-gnu-ar | ||
| ENV STRIP_x86_64_unknown_linux_gnu=x86_64-linux-gnu-strip | ||
| ENV BINDGEN_EXTRA_CLANG_ARGS_x86_64_unknown_linux_gnu="-I/usr/include -I/usr/include/x86_64-linux-gnu" | ||
| ENV CFLAGS_x86_64_unknown_linux_gnu="-I/usr/include -I/usr/include/x86_64-linux-gnu" | ||
| ENV CPPFLAGS_x86_64_unknown_linux_gnu="-I/usr/include -I/usr/include/x86_64-linux-gnu" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For improved build reproducibility and stability in CI/CD pipelines, it's generally recommended to pin Docker base images to a specific version tag or a digest instead of using a mutable tag like
main. Whilecross:mainmight be intended to be stable, a specific version (e.g.,cross:0.2.xorcross@sha256:digest) would prevent unexpected build failures if themaintag is updated with breaking changes.