diff mbox series

[7/9] gcc-configure-common.inc: add multlib support for i686/i586/x86_64 nativesdk gcc

Message ID 20250121085526.1370937-7-hongxu.jia@windriver.com
State New
Headers show
Series [1/9] perl: fix do_install failed for nativesdk-perl | expand

Commit Message

Hongxu Jia Jan. 21, 2025, 8:55 a.m. UTC
We have patch 0016-handle-sysroot-support-for-nativesdk-gcc.patch to handle
sysroot support for nativesdk-gcc, and add %r target_relocatable_prefix
into spec file for nativesdk-gcc relocation. It was used for injected
paths SYSTEMLIBS_DIR

Due to the supported SDKMACHINE includes:

  aarch64, i586, i686, loongarch64, ppc64, ppc64le, riscv64, x86_64

Only i586 and x86_64, i686 and x86_64 have multilib relationship,
for i586,i686 and x86_64, this commit:

- Tweak target_relocatable_prefix, set ${root_prefix} to it, and tweak
libdir32 and libdir64 based on ${root_prefix} prefix with "/lib" and
"/lib64" suffix.

- Harcode dirnames ['m64', 'm32'] and osdirnames ['../lib64', '../lib']

Above setting also covers gcc-nativesdk without multilib

For other situation, the configuration is the same as usual

[ YOCTO #15722 ]

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
 meta/recipes-devtools/gcc/gcc-configure-common.inc       | 9 +++++++++
 meta/recipes-devtools/gcc/gcc-multilib-config.inc        | 5 +++++
 .../0016-handle-sysroot-support-for-nativesdk-gcc.patch  | 2 +-
 3 files changed, 15 insertions(+), 1 deletion(-)

Comments

Khem Raj Jan. 22, 2025, 4:20 a.m. UTC | #1
seems ok to me.

On Tue, Jan 21, 2025 at 12:55 AM hongxu via lists.openembedded.org
<hongxu.jia=eng.windriver.com@lists.openembedded.org> wrote:
>
> We have patch 0016-handle-sysroot-support-for-nativesdk-gcc.patch to handle
> sysroot support for nativesdk-gcc, and add %r target_relocatable_prefix
> into spec file for nativesdk-gcc relocation. It was used for injected
> paths SYSTEMLIBS_DIR
>
> Due to the supported SDKMACHINE includes:
>
>   aarch64, i586, i686, loongarch64, ppc64, ppc64le, riscv64, x86_64
>
> Only i586 and x86_64, i686 and x86_64 have multilib relationship,
> for i586,i686 and x86_64, this commit:
>
> - Tweak target_relocatable_prefix, set ${root_prefix} to it, and tweak
> libdir32 and libdir64 based on ${root_prefix} prefix with "/lib" and
> "/lib64" suffix.
>
> - Harcode dirnames ['m64', 'm32'] and osdirnames ['../lib64', '../lib']
>
> Above setting also covers gcc-nativesdk without multilib
>
> For other situation, the configuration is the same as usual
>
> [ YOCTO #15722 ]
>
> Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
> ---
>  meta/recipes-devtools/gcc/gcc-configure-common.inc       | 9 +++++++++
>  meta/recipes-devtools/gcc/gcc-multilib-config.inc        | 5 +++++
>  .../0016-handle-sysroot-support-for-nativesdk-gcc.patch  | 2 +-
>  3 files changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/meta/recipes-devtools/gcc/gcc-configure-common.inc b/meta/recipes-devtools/gcc/gcc-configure-common.inc
> index 5c79936242..bd5c953334 100644
> --- a/meta/recipes-devtools/gcc/gcc-configure-common.inc
> +++ b/meta/recipes-devtools/gcc/gcc-configure-common.inc
> @@ -73,6 +73,14 @@ SYSTEMHEADERS = "${target_includedir}"
>  SYSTEMLIBS = "${target_base_libdir}/"
>  SYSTEMLIBS1 = "${target_libdir}/"
>
> +def tune_target_relocatable_prefix(d):
> +    if d.getVar("SDK_ARCH") in ["x86_64", "i686", "i586"]:
> +        return d.getVar("root_prefix")
> +    else:
> +        return d.getVar("SYSTEMLIBS")
> +TARGET_RELOCATE_PREFIX = "${SYSTEMLIBS}"
> +TARGET_RELOCATE_PREFIX:class-nativesdk = "${@tune_target_relocatable_prefix(d)}"
> +
>  do_configure:prepend () {
>         # teach gcc to find correct target includedir when checking libc ssp support
>         mkdir -p ${B}/gcc
> @@ -83,6 +91,7 @@ do_configure:prepend () {
>  #define STANDARD_STARTFILE_PREFIX_1 "${SYSTEMLIBS}"
>  #define STANDARD_STARTFILE_PREFIX_2 "${SYSTEMLIBS1}"
>  #define SYSTEMLIBS_DIR "${SYSTEMLIBS}"
> +#define TARGET_RELOCATE_PREFIX "${TARGET_RELOCATE_PREFIX}"
>  #endif /* ! GCC_DEFAULTS_H */
>  _EOF
>         mv ${B}/gcc/defaults.h.new ${B}/gcc/defaults.h
> diff --git a/meta/recipes-devtools/gcc/gcc-multilib-config.inc b/meta/recipes-devtools/gcc/gcc-multilib-config.inc
> index 2dbbc23c94..31336f75eb 100644
> --- a/meta/recipes-devtools/gcc/gcc-multilib-config.inc
> +++ b/meta/recipes-devtools/gcc/gcc-multilib-config.inc
> @@ -172,6 +172,11 @@ python gcc_multilib_setup() {
>      target_arch = (d.getVar('TARGET_ARCH_MULTILIB_ORIGINAL') if mlprefix
>                      else d.getVar('TARGET_ARCH'))
>      if pn == "nativesdk-gcc":
> +        if d.getVar('SDK_ARCH') in ['x86_64', 'i686', 'i586']:
> +            libdir32 = '%r/lib'
> +            libdir64 = '%r/lib64'
> +            target_config_files = gcc_target_config_files[d.getVar("SDK_ARCH")]
> +            write_config(builddir, target_config_files, ['m64', 'm32'], ['64', '32'], ['../lib64', '../lib'])
>          header_config_files = gcc_header_config_files[d.getVar("SDK_ARCH")]
>          write_headers(builddir, header_config_files, libdir32, libdir64, libdirx32, libdirn32)
>          return
> diff --git a/meta/recipes-devtools/gcc/gcc/0016-handle-sysroot-support-for-nativesdk-gcc.patch b/meta/recipes-devtools/gcc/gcc/0016-handle-sysroot-support-for-nativesdk-gcc.patch
> index edd100ee46..7d96a42027 100644
> --- a/meta/recipes-devtools/gcc/gcc/0016-handle-sysroot-support-for-nativesdk-gcc.patch
> +++ b/meta/recipes-devtools/gcc/gcc/0016-handle-sysroot-support-for-nativesdk-gcc.patch
> @@ -389,7 +389,7 @@ index e3e9374d1cc..b080609341b 100644
>   #endif
>   static const char *target_system_root = DEFAULT_TARGET_SYSTEM_ROOT;
>
> -+static char target_relocatable_prefix[4096] __attribute__ ((section (".gccrelocprefix"))) = SYSTEMLIBS_DIR;
> ++static char target_relocatable_prefix[4096] __attribute__ ((section (".gccrelocprefix"))) = TARGET_RELOCATE_PREFIX;
>  +
>   /* Nonzero means pass the updated target_system_root to the compiler.  */
>
> --
> 2.34.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#210079): https://lists.openembedded.org/g/openembedded-core/message/210079
> Mute This Topic: https://lists.openembedded.org/mt/110730425/1997914
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
diff mbox series

Patch

diff --git a/meta/recipes-devtools/gcc/gcc-configure-common.inc b/meta/recipes-devtools/gcc/gcc-configure-common.inc
index 5c79936242..bd5c953334 100644
--- a/meta/recipes-devtools/gcc/gcc-configure-common.inc
+++ b/meta/recipes-devtools/gcc/gcc-configure-common.inc
@@ -73,6 +73,14 @@  SYSTEMHEADERS = "${target_includedir}"
 SYSTEMLIBS = "${target_base_libdir}/"
 SYSTEMLIBS1 = "${target_libdir}/"
 
+def tune_target_relocatable_prefix(d):
+    if d.getVar("SDK_ARCH") in ["x86_64", "i686", "i586"]:
+        return d.getVar("root_prefix")
+    else:
+        return d.getVar("SYSTEMLIBS")
+TARGET_RELOCATE_PREFIX = "${SYSTEMLIBS}"
+TARGET_RELOCATE_PREFIX:class-nativesdk = "${@tune_target_relocatable_prefix(d)}"
+
 do_configure:prepend () {
 	# teach gcc to find correct target includedir when checking libc ssp support
 	mkdir -p ${B}/gcc
@@ -83,6 +91,7 @@  do_configure:prepend () {
 #define STANDARD_STARTFILE_PREFIX_1 "${SYSTEMLIBS}"
 #define STANDARD_STARTFILE_PREFIX_2 "${SYSTEMLIBS1}"
 #define SYSTEMLIBS_DIR "${SYSTEMLIBS}"
+#define TARGET_RELOCATE_PREFIX "${TARGET_RELOCATE_PREFIX}"
 #endif /* ! GCC_DEFAULTS_H */
 _EOF
 	mv ${B}/gcc/defaults.h.new ${B}/gcc/defaults.h
diff --git a/meta/recipes-devtools/gcc/gcc-multilib-config.inc b/meta/recipes-devtools/gcc/gcc-multilib-config.inc
index 2dbbc23c94..31336f75eb 100644
--- a/meta/recipes-devtools/gcc/gcc-multilib-config.inc
+++ b/meta/recipes-devtools/gcc/gcc-multilib-config.inc
@@ -172,6 +172,11 @@  python gcc_multilib_setup() {
     target_arch = (d.getVar('TARGET_ARCH_MULTILIB_ORIGINAL') if mlprefix
                     else d.getVar('TARGET_ARCH'))
     if pn == "nativesdk-gcc":
+        if d.getVar('SDK_ARCH') in ['x86_64', 'i686', 'i586']:
+            libdir32 = '%r/lib'
+            libdir64 = '%r/lib64'
+            target_config_files = gcc_target_config_files[d.getVar("SDK_ARCH")]
+            write_config(builddir, target_config_files, ['m64', 'm32'], ['64', '32'], ['../lib64', '../lib'])
         header_config_files = gcc_header_config_files[d.getVar("SDK_ARCH")]
         write_headers(builddir, header_config_files, libdir32, libdir64, libdirx32, libdirn32)
         return
diff --git a/meta/recipes-devtools/gcc/gcc/0016-handle-sysroot-support-for-nativesdk-gcc.patch b/meta/recipes-devtools/gcc/gcc/0016-handle-sysroot-support-for-nativesdk-gcc.patch
index edd100ee46..7d96a42027 100644
--- a/meta/recipes-devtools/gcc/gcc/0016-handle-sysroot-support-for-nativesdk-gcc.patch
+++ b/meta/recipes-devtools/gcc/gcc/0016-handle-sysroot-support-for-nativesdk-gcc.patch
@@ -389,7 +389,7 @@  index e3e9374d1cc..b080609341b 100644
  #endif
  static const char *target_system_root = DEFAULT_TARGET_SYSTEM_ROOT;
  
-+static char target_relocatable_prefix[4096] __attribute__ ((section (".gccrelocprefix"))) = SYSTEMLIBS_DIR;
++static char target_relocatable_prefix[4096] __attribute__ ((section (".gccrelocprefix"))) = TARGET_RELOCATE_PREFIX;
 +
  /* Nonzero means pass the updated target_system_root to the compiler.  */