Skip to content

Set CXX and AR environment variables for cross-compilation#997

Draft
colincasey wants to merge 1 commit into
mainfrom
cross-compile-cxx-ar-env-vars
Draft

Set CXX and AR environment variables for cross-compilation#997
colincasey wants to merge 1 commit into
mainfrom
cross-compile-cxx-ar-env-vars

Conversation

@colincasey

@colincasey colincasey commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Refactors cross_compile_assistance() to store a toolchain prefix per platform case and derive gcc, g++, and ar binary names via format!
  • Sets CXX_* and AR_* environment variables alongside existing CC_* and CARGO_TARGET_*_LINKER for cross-compilation
  • Ensures crates using CMake or the cc crate for C++ code (such as aws-lc-sys) find the correct cross-compiler toolchain

Context

The cross-compile toolchain docs recommend setting CC, CXX, and AR for the target platform, but we were only setting CC. This is possibly causing cross-compilation failures for crates that build C++ code via CMake (see heroku/buildpacks-deb-packages#181).

Fixes #725

Also set the CXX_* and AR_* environment variables (in addition to the
existing CC_* and CARGO_TARGET_*_LINKER) when configuring cross-compilation
toolchains. This ensures crates that use CMake or the cc crate to build
C++ code (such as aws-lc-sys) find the correct cross-compiler.

Refactors the match arms to store a toolchain prefix and derive all tool
binary names from it via format!().

Fixes #725
@colincasey colincasey self-assigned this Apr 9, 2026
colincasey added a commit to heroku/buildpacks-deb-packages that referenced this pull request Apr 9, 2026
Adds a workflow that cross-compiles the buildpack for both x86_64 and
aarch64 using libcnb-cargo from the cross-compile-cxx-ar-env-vars branch
which sets CXX_* and AR_* env vars during cross-compilation.

Also switches libcnb/libcnb-test deps to git dependencies on the same
branch to ensure consistent builds.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cross-compilation assistance: Set the CXX_* and AR_* environment variables too

1 participant