configure: fix cross-compilation best practices#3183
Merged
Conversation
- Move Darwin clang/clang++ preference (`: ${CC:=clang}`) before
AC_PROG_CC so the hint actually takes effect; previously it ran after
CC was already chosen.
- Remove global AC_LANG_WERROR; it caused false-negative feature checks
with strict cross-compilers.
- Add cross-compilation warning block (fires when build != host) that
alerts the user when PKG_CONFIG_SYSROOT_DIR / PKG_CONFIG_LIBDIR are
unset and when build-host paths (Homebrew, DPDK, PCAP_HOME+PF_RING)
may not apply to the target.
- Guard Homebrew include/lib injection with `test "$cross_compiling" != yes`
so it is skipped when cross-compiling from a macOS host.
- Make pfring_config execution conditional on the binary being present
and executable (guards against absent or target-arch binary).
- Save and restore PKG_CONFIG_PATH around the custom libpcap pkg-config
lookup to prevent it leaking into subsequent checks; also quote
$PKG_CONFIG in the shell interpolation.
- Quote previously unquoted variables in test expressions: $OS_TYPE,
$HOMEBREW_DIR, $HOME/DPDK, $PCAP_HOME.
- Replace BSD-only `date -r FILE` with `stat -c`/`stat -f` fallback
chain that works on both GNU/Linux and macOS.
Also add utils/cross-compile-test.sh: a self-contained script that
exercises the cross-compilation path on Ubuntu x86-64 targeting
AArch64 (aarch64-linux-gnu). Supports a fast --library-only mode and
a --full mode that installs arm64 multiarch dev libraries, configures
with PKG_CONFIG_SYSROOT_DIR, builds examples and unit tests, and runs
ndpiReader -H under QEMU user-mode emulation to verify the resulting
binary executes correctly on the build host.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Move AC_CANONICAL_HOST before PKG_PROG_PKG_CONFIG so the source-level ordering matches the required expansion order (PKG_PROG_PKG_CONFIG uses AC_PATH_TOOL which requires AC_CANONICAL_HOST). Remove AC_PROG_CPP_WERROR: it makes all AC_CHECK_HEADERS calls use -Werror on the preprocessor, which can produce false negatives when cross-compiling with a stricter cross-compiler. Same rationale as the earlier removal of AC_LANG_WERROR. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



: ${CC:=clang}) before AC_PROG_CC so the hint actually takes effect; previously it ran after CC was already chosen.test "$cross_compiling" != yesso it is skipped when cross-compiling from a macOS host.date -r FILEwithstat -c/stat -ffallback chain that works on both GNU/Linux and macOS.Also add
utils/cross-compile-test.sh: a self-contained script that exercises the cross-compilation path on Ubuntu x86-64 targeting AArch64 (aarch64-linux-gnu). Supports a fast--library-onlymode and a--fullmode that installs arm64 multiarch dev libraries, configures with PKG_CONFIG_SYSROOT_DIR, builds examples and unit tests, and runsndpiReader -Hunder QEMU user-mode emulation to verify the resulting binary executes correctly on the build host.