From 67a1018389f17fdba994ceebff38345808f350df 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 4e645cf50671d4..3e1902fb7892bb 100644 --- a/common.gypi +++ b/common.gypi @@ -411,28 +411,56 @@ 'cflags': [ '-I/usr/local/include' ], 'ldflags': [ '-Wl,-z,wxneeded' ], }], - ], - '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' ], + ['_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' ], + }], + ], }], - [ 'target_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': [ [ 'OS=="solaris"', { 'cflags': [ '-pthreads' ], 'ldflags': [ '-pthreads' ],