Skip to content

Commit

Permalink
build: do not pass target toolchain flags to host toolchain
Browse files Browse the repository at this point in the history
Fixes target toolchain arguments being passed to the host toolchain when
cross-compiling. For example, -m64 is not available on aarch64.

PR-URL: #48597
Reviewed-By: Richard Lau <rlau@redhat.com>
  • Loading branch information
tie authored and ruyadorno committed Sep 16, 2023
1 parent 4826379 commit 9cb18b3
Showing 1 changed file with 48 additions and 20 deletions.
68 changes: 48 additions & 20 deletions common.gypi
Expand Up @@ -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' ],
Expand Down

0 comments on commit 9cb18b3

Please sign in to comment.