Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,16 @@ Consult compiler documentation for further information on the above options.
Cross-compilation with "configure" script
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

If cross-compiling (i.e. specifying the CXX_FOR_BUILD variable), there are some additional
considerations regarding use of the "configure" script.
If the CXX_FOR_BUILD variable is specified, the "configure" script will assume the build is a
cross-build, unless all of the following conditions are met:

* Both the host compiler (CXX variable) and the build compiler (CXX_FOR_BUILD variable) are the
same.
* Their respective compiler flags (CXXFLAGS and CXXFLAGS_FOR_BUILD variables) are the same or both
unset.
* The CXXFLAGS_EXTRA variable is unset.

If all of these conditions are met, the "configure" script will instead assume the build is native.

Some build options are currently defaulted based on the detected platform (operating system). When
doing a cross-build, the target platform is not automatically detected, and "configure" prints a
Expand Down
15 changes: 15 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,21 @@ for arg in "$@"; do
esac
done

## Verify the build is a cross-build when CXX_FOR_BUILD is specified
if [ -n "${CXX_FOR_BUILD:-}" ]; then
# The $CXX_FOR_BUILD is a variable set by the user to the compiler for the build machine.
# Later parts of this script assume the build is a cross-build when the $CXX_FOR_BUILD is set.
# The following check ensures that either the host compiler and the build compiler and their
# respective compiler flags are actually different or that $CXX_FOR_BUILD is unset.
if [ "$CXX_FOR_BUILD" = "$CXX" ]; then
if [ -z "${CXXFLAGS_EXTRA:-}" ]; then
if [ "${CXXFLAGS:-}" = "${CXXFLAGS_FOR_BUILD:-}" ]; then
unset CXX_FOR_BUILD
fi
fi
fi
fi

## Check platform is specified for a cross-build
if [ -n "${CXX_FOR_BUILD:-}" ]; then
if [ -z "${PLATFORM:-}" ]; then
Expand Down
Loading