autotools: cross-compile using --host instead of env
Metadata
Current evaluation
Fixed autotools cross-compilation by replacing CC and CXX environment variables with proper --host triplet arguments. Merged after reviewer approval and passing CI checks, ensuring correct toolchain detection including cross-strip.
Suggested action: —
No scores available.
Issue body
- [x] Have you followed the [guidelines for contributing](https://github.com/snapcore/snapcraft/blob/master/CONTRIBUTING.md)?
- [x] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)?
- [x] If this is a bugfix. Have you checked that there is a bug report open for the issue you are trying to fix on [bug reports](https://bugs.launchpad.net/snapcraft)?
- [x] If this is a new feature. Have you discussed the design on the [forum](https://forum.snapcraft.io)?
- [x] Have you successfully run `./runtests.sh static`?
- [x] Have you successfully run `./runtests.sh unit`?
-----
Take a look at the `configure` output for our autotools cross-compile integration test (I'm doing this by hand, running `snapcraft --target-arch=armhf`):
```
[...]
./configure --prefix= --host=armhf
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for armhf-strip... no
checking for strip... strip
[...]
```
Note that it's using the build system's `strip`, not the cross-toolchain's `strip`. What is `armhf-strip` anyway? Nothing, I tell you! We're setting --host to the deb arch instead of the triplet.
Currently the autotools plugin uses the CC and CXX environment variables to force autotools to cross-compile. However, autotools will do this on its own if one sets the --host parameter correctly, and will actually do a better job (e.g. use the cross-toolchain's strip as well).
Remove the environment variables, and set the --host to the target triplet if cross-compiling. More info on how to cross-compile using autotools (including details on --host) can be found [here](https://www.gnu.org/software/automake/manual/html_node/Cross_002dCompilation.html).
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| qwen/qwen3.6-35b-a3b | — | — | Fixed autotools cross-compilation by replacing CC and CXX environment variables with proper --host triplet arguments. Merged after reviewer approval and passing CI checks, ensuring correct toolchain detection including cross-strip. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged. Replaced CC/CXX environment variables with the correct --host triplet for autotools cross-compilation. This ensures proper use of cross-toolchain utilities like strip. Validated for armhf/arm64 builds and merged. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged. Fixes autotools cross-compilation by replacing CC/CXX environment variables with the correct --host triplet parameter. This ensures autotools uses the proper cross-toolchain tools like strip. Approved after successful armhf/arm64 testing and passing unit checks. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #1383 autotools: Enable cross-compilation support | snapcraft | merged | Merged changes enabling cross-compilation support for Autotools by setting CC and CXX environment variables. Initial CI failures were fixed, tests passed, and the PR was approved and merged. | |
| #1566331 snapcraft autotools plugin doesn't support building other architectures | snapcraft (launchpad) | open | Feature request for the autotools plugin to support cross-compilation for other architectures via environment variables. Implemented by merged PR #1383 (CC/CXX env vars) and refined by #1654 (--host triplet). No maintainer interaction; ready to close. | |
| #5350 docs: add how-to for cross compiling autotools | snapcraft | merged | Merged documentation update adding a how-to guide for cross-compiling autotools. Approved by two reviewers, passed CI checks, and added 198 lines across four files. Resolves CRAFT-4328. | |
| #3523 autotools v2 plugin: adding cross compilation support | snapcraft | closed | Closed without merging. Proposed cross-compilation support for the autotools v2 plugin. Maintainers raised concerns about build environment compliance and CC handling. The maintainer closed the PR pending further forum discussion. |