From: Dan McGregor <danismostlikely@gmail.com>
To: openembedded-core@lists.openembedded.org
Cc: Daniel McGregor <daniel.mcgregor@vecima.com>
Subject: [PATCH 2/3] gcc: set the default target arch
Date: Wed, 28 Sep 2022 16:13:19 -0600 [thread overview]
Message-ID: <20220928221320.1763684-2-danismostlikely@gmail.com> (raw)
In-Reply-To: <20220928221320.1763684-1-danismostlikely@gmail.com>
From: Daniel McGregor <daniel.mcgregor@vecima.com>
The default x86-64 architecture for target gcc (ie, the one in poky
build appliances) is native. Since we have a variety of build systems
it will occasionally produce instructions that don't work on all of
our development system.
Instead, set gcc's default architecture to the one specified in
TUNE_CC_ARCH, that guarantees that gcc-runtime and any binaries
produced are compatible with the target machine type.
Signed-off-by: Daniel McGregor <daniel.mcgregor@vecima.com>
---
meta/recipes-devtools/gcc/gcc-common.inc | 10 ++++++++++
meta/recipes-devtools/gcc/gcc-target.inc | 2 +-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/meta/recipes-devtools/gcc/gcc-common.inc b/meta/recipes-devtools/gcc/gcc-common.inc
index 2abc0e355d7..d3b36937bf4 100644
--- a/meta/recipes-devtools/gcc/gcc-common.inc
+++ b/meta/recipes-devtools/gcc/gcc-common.inc
@@ -32,6 +32,16 @@ def get_gcc_float_setting(bb, d):
get_gcc_float_setting[vardepvalue] = "${@get_gcc_float_setting(bb, d)}"
+def get_gcc_x86_64_arch_setting(bb, d):
+ import re
+ march = re.match(r'^.*-march=([^\s]*)', d.getVar('TUNE_CCARGS'))
+ if march:
+ return "--with-arch=%s " % march.group(1)
+ # The earliest supported x86-64 CPU
+ return "--with-arch=core2"
+
+get_gcc_x86_64_arch_setting[vardepvalue] = "${@get_gcc_x86_64_arch_setting(bb, d)}"
+
def get_gcc_mips_plt_setting(bb, d):
if d.getVar('TRANSLATED_TARGET_ARCH') in [ 'mips', 'mipsel' ] and bb.utils.contains('DISTRO_FEATURES', 'mplt', True, False, d):
return "--with-mips-plt"
diff --git a/meta/recipes-devtools/gcc/gcc-target.inc b/meta/recipes-devtools/gcc/gcc-target.inc
index cc65e995c30..7dac3ef422c 100644
--- a/meta/recipes-devtools/gcc/gcc-target.inc
+++ b/meta/recipes-devtools/gcc/gcc-target.inc
@@ -19,7 +19,7 @@ EXTRA_OECONF:append:armv6:class-target = " --with-arch=armv6${ARMFPARCHEXT}"
EXTRA_OECONF:append:armv7a:class-target = " --with-arch=armv7-a${ARMFPARCHEXT}"
EXTRA_OECONF:append:armv7ve:class-target = " --with-arch=armv7ve${ARMFPARCHEXT}"
EXTRA_OECONF:append:arc:class-target = " --with-cpu=${TUNE_PKGARCH}"
-EXTRA_OECONF:append:x86-64:class-target = " --with-arch=native"
+EXTRA_OECONF:append:x86-64:class-target = " ${@get_gcc_x86_64_arch_setting(bb, d)}"
# libcc1 requres gcc_cv_objdump when cross build, but gcc_cv_objdump is
# set in subdir gcc, so subdir libcc1 can't use it, export it here to
--
2.37.3
next prev parent reply other threads:[~2022-09-28 22:13 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-28 22:13 [PATCH 1/3] coreutils: add openssl PACKAGECONFIG Dan McGregor
2022-09-28 22:13 ` Dan McGregor [this message]
2022-09-29 11:19 ` [OE-core] [PATCH 2/3] gcc: set the default target arch Ross Burton
[not found] ` <08a4803c-628e-c898-eef4-7d40775e27bf@vecima.com>
2022-09-29 15:33 ` Ross Burton
2022-09-28 22:13 ` [PATCH 3/3] systemd: generate manpages indexes Dan McGregor
2022-09-29 7:16 ` [OE-core] " Richard Purdie
2022-09-29 15:41 ` Dan McGregor
2022-09-29 19:03 ` Dan McGregor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220928221320.1763684-2-danismostlikely@gmail.com \
--to=danismostlikely@gmail.com \
--cc=daniel.mcgregor@vecima.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).