| Message ID | 20260128062928.97927-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! I have merged it upstream as
https://git.yoctoproject.org/meta-darwin/commit/?id=2ddb2d2c52e9b0cdc6bdf57b001aa6eef23f6fef
. I have only removed those lines from the commit message. I've assumed
they were not intentional:
```
commit da00745de4531722df9b955892c5835a7c26c03f
Author: Eric L. Hernes <dev@qinc.tv>
Date: Mon Jan 19 09:54:57 2026 -0600
additional patch for gcc to build on arm64 build for arm64 host
```
Étienne
On Wed, Jan 28, 2026 at 7:30 AM 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 <dev@qinc.tv>
> Signed-off-by: Eric L. Hernes <dev@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 | 32 +++++++++++++++++++
> recipes-devtools/gcc/gcc-source_%.bbappend | 4 +++
> 2 files changed, 36 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..f6da25f
> --- /dev/null
> +++ b/recipes-devtools/gcc/files/0102-aarch64-on-aarch64.patch
> @@ -0,0 +1,32 @@
> +Upstream-Status: Inappropriate [OE specific]
> +Signed-off-by: Eric L. Hernes <dev@qinc.tv>
> +--- 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 (#3123):
> https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.yoctoproject.org_g_yocto-2Dpatches_message_3123&d=DwIFAg&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=luqjbFFHyORi_5ZXAun64M_bUjePIK0pc0LC21NZneN6pB1fP8OvQ8plT2YcOs9m&s=B9EwMJhHfWbxd5CfimNqcVqVlMdKO6IdmDcz1QOMSmk&e=
> Mute This Topic:
> https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.yoctoproject.org_mt_117503969_7048771&d=DwIFAg&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=luqjbFFHyORi_5ZXAun64M_bUjePIK0pc0LC21NZneN6pB1fP8OvQ8plT2YcOs9m&s=rXld_pMTINIRmwre1iv3SeyKSMhlveSrQsKbsz8tJMg&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=luqjbFFHyORi_5ZXAun64M_bUjePIK0pc0LC21NZneN6pB1fP8OvQ8plT2YcOs9m&s=j-zD9JWZuWc_CdtEVoRIA6oYkFUlqyij8BOeJTRTa_Q&e=
> [ecordonnier@snap.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>
>
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..f6da25f --- /dev/null +++ b/recipes-devtools/gcc/files/0102-aarch64-on-aarch64.patch @@ -0,0 +1,32 @@ +Upstream-Status: Inappropriate [OE specific] +Signed-off-by: Eric L. Hernes <dev@qinc.tv> +--- 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 \ +"