| Message ID | 20260120170246.94746-1-dev@qinc.tv |
|---|---|
| State | New |
| Headers | show |
| Series | [meta-darwin] Patch GCC for aarch64 macOS host build on aarch64 linux host | expand |
Hi Eric, Thanks for the patch! Can you please add an upstream-status to the file 0102-aarch64-on-aarch64.patch ( https://docs.yoctoproject.org/scarthgap/contributor-guide/recipe-style-guide.html ). The QA_ERROR patch-status is enabled per default on recent yocto releases and we'll need it on all patches for updating meta-darwin to the next version. Étienne On Tue, Jan 20, 2026 at 6:03 PM Eric L. Hernes via lists.yoctoproject.org <dev=qinc.tv@lists.yoctoproject.org> wrote: > From: "Eric L. Hernes" <eric@qinc.tv> > > The configure script and aarch64.h get a bit confused when building > the darwin cross canadian. `driver-aarch64.c` gets added which has > more build problems and isn't needed on the cross build. The > `aarch64.h` file looks for `sysctl/..h` headers when targeting MACHO > binaries , which also do not exist on the linux build machine. > > There should be a CPP macro for "linux_build_host" or > similar to use for the system dependent includes and config. Since we > don't have this, we use (!defined(darwin_macosx_version_min)), which > seems to be "darwin builds only". It's a bit of a hack, but should be > ok for this deep corner case. > > Without this patch, cross builds targeting macOS/arm64 on a Linux > Intel machine work; but linux arm64 does not. This is maybe a more > common situation. With Apple Intel machines out of production for 5+ > years now, Docker on Apple Silicon should be much more common, and > getting more so. > > It is possible to configure an Intel Docker image on Apple Silicon > with Rosetta 2, but the builds with native arm64 are significantly > faster. > > commit da00745de4531722df9b955892c5835a7c26c03f > Author: Eric L. Hernes <ehernes@portrait.com> > Signed-off-by: Eric L. Hernes <eric@qinc.tv> > Date: Mon Jan 19 09:54:57 2026 -0600 > > additional patch for gcc to build on arm64 build for arm64 host > --- > .../gcc/files/0102-aarch64-on-aarch64.patch | 30 +++++++++++++++++++ > recipes-devtools/gcc/gcc-source_%.bbappend | 4 +++ > 2 files changed, 34 insertions(+) > create mode 100644 > recipes-devtools/gcc/files/0102-aarch64-on-aarch64.patch > > diff --git a/recipes-devtools/gcc/files/0102-aarch64-on-aarch64.patch > b/recipes-devtools/gcc/files/0102-aarch64-on-aarch64.patch > new file mode 100644 > index 0000000..fd7ef2c > --- /dev/null > +++ b/recipes-devtools/gcc/files/0102-aarch64-on-aarch64.patch > @@ -0,0 +1,30 @@ > +--- gcc-13.4.0/gcc/config.host~ 2026-01-08 23:01:47.056268010 +0000 > ++++ gcc-13.4.0/gcc/config.host 2026-01-08 23:10:07.958588006 +0000 > +@@ -102,6 +102,9 @@ > + aarch64*-*-freebsd* | aarch64*-*-linux* | aarch64*-*-fuchsia* |\ > + aarch64*-*-darwin*) > + case ${target} in > ++ *-oesdk-*) > ++ # don't add driver-aarch64.o for oesdk cross builds > ++ ;; > + aarch64*-*-*) > + host_extra_gcc_objs="driver-aarch64.o" > + host_xmake_file="${host_xmake_file} aarch64/x-aarch64" > +--- gcc-13.4.0/gcc/config/aarch64/aarch64.h~ 2026-01-08 > 23:01:46.859268010 +0000 > ++++ gcc-13.4.0/gcc/config/aarch64/aarch64.h 2026-01-08 > 23:08:14.417236009 +0000 > +@@ -1223,7 +1223,14 @@ > + > + /* Extra specs when building a native AArch64-hosted compiler. > + Option rewriting rules based on host system. */ > +-#if defined(__aarch64__) > ++ > ++// > ++// XXX-ELH: we don't do this for crosssdk builds, > ++// so how do we know that? For now we just pick a symbol that is defined > in the build > ++// > ++// g++ -fno-PIE -dM -E ..... -MT gcc.o -MMD -MP -MF ./.deps/gcc.TPo > ../../../../../../../work-shared/gcc-13.4.0-r0/gcc-13.4.0/gcc/gcc.cc > ++// > ++#if defined(__aarch64__) && !defined(darwin_macosx_version_min) > + extern const char *host_detect_local_cpu (int argc, const char **argv); > + #define HAVE_LOCAL_CPU_DETECT > + # define EXTRA_SPEC_FUNCTIONS \ > diff --git a/recipes-devtools/gcc/gcc-source_%.bbappend > b/recipes-devtools/gcc/gcc-source_%.bbappend > index 73b4843..d1089e5 100644 > --- a/recipes-devtools/gcc/gcc-source_%.bbappend > +++ b/recipes-devtools/gcc/gcc-source_%.bbappend > @@ -9,3 +9,7 @@ SRC_URI:append = " \ > SRC_URI:append = " \ > file://0101-aarch64-Darwin-support-gcc-13-darwin.patch \ > " > +# Patch to allow building aarch64 toolchain for mac on aarch64 linux > +SRC_URI:append = " \ > + file://0102-aarch64-on-aarch64.patch \ > +" > -- > 2.50.1 (Apple Git-155) > > > > -=-=-=-=-=-=-=-=-=-=-=- > Links: You receive all messages sent to this group. > View/Reply Online (#3034): > https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.yoctoproject.org_g_yocto-2Dpatches_message_3034&d=DwIFAg&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=v_cXEb90NejE92y4oHgGGaxyjMe0vXc0NQVyod-CBBjQCoe7w_WAVPnpNOERnMcH&s=nvE2CScun7jrUsSqv8R5GZrhQ85vrrkjT_Hx9pvZh9M&e= > Mute This Topic: > https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.yoctoproject.org_mt_117366348_7048771&d=DwIFAg&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=v_cXEb90NejE92y4oHgGGaxyjMe0vXc0NQVyod-CBBjQCoe7w_WAVPnpNOERnMcH&s=tfNwfVQqI75MWPFBK9kj_nq8wkP4FfSZWqKzzKG5ko4&e= > Group Owner: yocto-patches+owner@lists.yoctoproject.org > Unsubscribe: > https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.yoctoproject.org_g_yocto-2Dpatches_leave_13184993_7048771_1814342232_xyzzy&d=DwIFAg&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=v_cXEb90NejE92y4oHgGGaxyjMe0vXc0NQVyod-CBBjQCoe7w_WAVPnpNOERnMcH&s=2PQ6gTEChT_YXwK8n3kAvN8UEKKPgXf-WnlinWMlkUE&e= > [ecordonnier@snap.com] > -=-=-=-=-=-=-=-=-=-=-=- > > >
Thanks Etienne, What is the correct indentation? I guess I didn’t look closely enough at it. The target is an oversight on my part, I’ll fix that. The ‘with-mpft’ was taken straight from the `gcc-cross-canadian_%.bbappend` patch, the same issue is in there too. I will fix both. -Eric
diff --git a/recipes-devtools/gcc/files/0102-aarch64-on-aarch64.patch b/recipes-devtools/gcc/files/0102-aarch64-on-aarch64.patch new file mode 100644 index 0000000..fd7ef2c --- /dev/null +++ b/recipes-devtools/gcc/files/0102-aarch64-on-aarch64.patch @@ -0,0 +1,30 @@ +--- gcc-13.4.0/gcc/config.host~ 2026-01-08 23:01:47.056268010 +0000 ++++ gcc-13.4.0/gcc/config.host 2026-01-08 23:10:07.958588006 +0000 +@@ -102,6 +102,9 @@ + aarch64*-*-freebsd* | aarch64*-*-linux* | aarch64*-*-fuchsia* |\ + aarch64*-*-darwin*) + case ${target} in ++ *-oesdk-*) ++ # don't add driver-aarch64.o for oesdk cross builds ++ ;; + aarch64*-*-*) + host_extra_gcc_objs="driver-aarch64.o" + host_xmake_file="${host_xmake_file} aarch64/x-aarch64" +--- gcc-13.4.0/gcc/config/aarch64/aarch64.h~ 2026-01-08 23:01:46.859268010 +0000 ++++ gcc-13.4.0/gcc/config/aarch64/aarch64.h 2026-01-08 23:08:14.417236009 +0000 +@@ -1223,7 +1223,14 @@ + + /* Extra specs when building a native AArch64-hosted compiler. + Option rewriting rules based on host system. */ +-#if defined(__aarch64__) ++ ++// ++// XXX-ELH: we don't do this for crosssdk builds, ++// so how do we know that? For now we just pick a symbol that is defined in the build ++// ++// g++ -fno-PIE -dM -E ..... -MT gcc.o -MMD -MP -MF ./.deps/gcc.TPo ../../../../../../../work-shared/gcc-13.4.0-r0/gcc-13.4.0/gcc/gcc.cc ++// ++#if defined(__aarch64__) && !defined(darwin_macosx_version_min) + extern const char *host_detect_local_cpu (int argc, const char **argv); + #define HAVE_LOCAL_CPU_DETECT + # define EXTRA_SPEC_FUNCTIONS \ diff --git a/recipes-devtools/gcc/gcc-source_%.bbappend b/recipes-devtools/gcc/gcc-source_%.bbappend index 73b4843..d1089e5 100644 --- a/recipes-devtools/gcc/gcc-source_%.bbappend +++ b/recipes-devtools/gcc/gcc-source_%.bbappend @@ -9,3 +9,7 @@ SRC_URI:append = " \ SRC_URI:append = " \ file://0101-aarch64-Darwin-support-gcc-13-darwin.patch \ " +# Patch to allow building aarch64 toolchain for mac on aarch64 linux +SRC_URI:append = " \ + file://0102-aarch64-on-aarch64.patch \ +"