aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-08-27 09:56:43 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-08-27 09:56:43 +0200
commit28c69585d564a85b5f7cf84d690deac453067a70 (patch)
treec0a4fdc90b7c3253bd6a657b5a95cb2f89b6a4d9
parent4caed823a8c762676fe57ff646bf19b6c14e9f6e (diff)
Tweak cross-compilation detection in buildfile
-rw-r--r--libbuild2/buildfile15
1 files changed, 11 insertions, 4 deletions
diff --git a/libbuild2/buildfile b/libbuild2/buildfile
index 3c4566a..7ed593f 100644
--- a/libbuild2/buildfile
+++ b/libbuild2/buildfile
@@ -72,13 +72,20 @@ for t: cxx{ *.test...} \
obja{*}: cxx.poptions += -DLIBBUILD2_STATIC_BUILD
objs{*}: cxx.poptions += -DLIBBUILD2_SHARED_BUILD
-# Pass our compiler target to be used as build2 host and our out_root to
-# be used as the build system import path (not forgetting to escape
-# backslashes on Windows).
+# Pass our compiler target to be used as build2 host and our out_root to be
+# used as the build system import path (unless cross-compiling and not
+# forgetting to escape backslashes on Windows).
#
obj{context}: cxx.poptions += "-DBUILD2_HOST_TRIPLET=\"$cxx.target\""
-if ($cxx.target == $build.host)
+# Note that we used to compare complete target triplets but that proved too
+# strict. For example, we may be running on x86_64-apple-darwin17.7.0 while
+# the compiler is targeting x86_64-apple-darwin17.3.0.
+#
+cross = ($cxx.target.cpu != $build.host.cpu || \
+ $cxx.target.system != $build.host.system)
+
+if! $cross
obj{context}: cxx.poptions += \
"-DBUILD2_IMPORT_PATH=\"$regex.replace($out_root, '\\', '\\\\')\""