From 78e42e46ec34f3095dcf405cc0e5772692a55824 Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Wed, 12 Jul 2023 17:57:05 +0300 Subject: [PATCH] build: do not pass target toolchain flags to host toolchain Fixes target toolchain arguments being passed to the host toolchain when cross-compiling. For example, -m64 is not available on aarch64. PR-URL: https://github.com/nodejs/node/pull/48597 Reviewed-By: Richard Lau --- common.gypi | 68 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 48 insertions(+), 20 deletions(-) diff --git a/common.gypi b/common.gypi index 65720283c54..4b8e6f62ae0 100644 --- a/common.gypi +++ b/common.gypi @@ -411,28 +411,56 @@ 'cflags': [ '-I/usr/local/include' ], 'ldflags': [ '-Wl,-z,wxneeded' ], }], + ['_toolset=="host"', { + 'conditions': [ + [ 'host_arch=="ia32"', { + 'cflags': [ '-m32' ], + 'ldflags': [ '-m32' ], + }], + [ 'host_arch=="x64"', { + 'cflags': [ '-m64' ], + 'ldflags': [ '-m64' ], + }], + [ 'host_arch=="ppc" and OS not in "aix os400"', { + 'cflags': [ '-m32' ], + 'ldflags': [ '-m32' ], + }], + [ 'host_arch=="ppc64" and OS not in "aix os400"', { + 'cflags': [ '-m64', '-mminimal-toc' ], + 'ldflags': [ '-m64' ], + }], + [ 'host_arch=="s390x" and OS=="linux"', { + 'cflags': [ '-m64', '-march=z196' ], + 'ldflags': [ '-m64', '-march=z196' ], + }], + ], + }], + ['_toolset=="target"', { + 'conditions': [ + [ 'target_arch=="ia32"', { + 'cflags': [ '-m32' ], + 'ldflags': [ '-m32' ], + }], + [ 'target_arch=="x64"', { + 'cflags': [ '-m64' ], + 'ldflags': [ '-m64' ], + }], + [ 'target_arch=="ppc" and OS not in "aix os400"', { + 'cflags': [ '-m32' ], + 'ldflags': [ '-m32' ], + }], + [ 'target_arch=="ppc64" and OS not in "aix os400"', { + 'cflags': [ '-m64', '-mminimal-toc' ], + 'ldflags': [ '-m64' ], + }], + [ 'target_arch=="s390x" and OS=="linux"', { + 'cflags': [ '-m64', '-march=z196' ], + 'ldflags': [ '-m64', '-march=z196' ], + }], + ], + }], ], 'conditions': [ - [ 'target_arch=="ia32"', { - 'cflags': [ '-m32' ], - 'ldflags': [ '-m32' ], - }], - [ 'target_arch=="x64"', { - 'cflags': [ '-m64' ], - 'ldflags': [ '-m64' ], - }], - [ 'target_arch=="ppc" and OS not in "aix os400"', { - 'cflags': [ '-m32' ], - 'ldflags': [ '-m32' ], - }], - [ 'target_arch=="ppc64" and OS not in "aix os400"', { - 'cflags': [ '-m64', '-mminimal-toc' ], - 'ldflags': [ '-m64' ], - }], - [ 'target_arch=="s390x" and OS=="linux"', { - 'cflags': [ '-m64', '-march=z196' ], - 'ldflags': [ '-m64', '-march=z196' ], - }], [ 'OS=="solaris"', { 'cflags': [ '-pthreads' ], 'ldflags': [ '-pthreads' ],