From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on starla X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=BODY_8BITS, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 170541F55F for ; Wed, 20 Sep 2023 10:52:20 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3BFE93857344 for ; Wed, 20 Sep 2023 10:52:19 +0000 (GMT) Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id 57E9D3858D20 for ; Wed, 20 Sep 2023 10:52:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 57E9D3858D20 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=loongson.cn Received: from loongson.cn (unknown [10.20.4.90]) by gateway (Coremail) with SMTP id _____8AxuerQzgplFz4qAA--.5667S3; Wed, 20 Sep 2023 18:52:01 +0800 (CST) Received: from [10.20.4.90] (unknown [10.20.4.90]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Dx+y7Ozgpl6H0MAA--.1363S2; Wed, 20 Sep 2023 18:51:58 +0800 (CST) Subject: Re: [PATCH] LoongArch: Add glibc.cpu.hwcap support. To: Xi Ruoyao , libc-alpha@sourceware.org Cc: adhemerval.zanella@linaro.org References: <20230917094855.3654948-1-caiyinyu@loongson.cn> From: caiyinyu Message-ID: <311e000d-ec04-9a73-8474-06f7c96a4791@loongson.cn> Date: Wed, 20 Sep 2023 18:51:58 +0800 User-Agent: Mozilla/5.0 (X11; Linux loongarch64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-CM-TRANSID: AQAAf8Dx+y7Ozgpl6H0MAA--.1363S2 X-CM-SenderInfo: 5fdl5xhq1xqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBj9fXoWfCw1Uur1rJr17ur4Uur1rGrX_yoW8uFWkZo WfKF4fXr4rGr4j9Fs8G3yDZry2qFyUGrnrtFW7WFZ7JF10yF45C3y0ya4Yg3y3Jrn5CFWU Jay7JFy2yFy7ur1fl-sFpf9Il3svdjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8wcxFpf 9Il3svdxBIdaVrn0xqx4xG64xvF2IEw4CE5I8CrVC2j2Jv73VFW2AGmfu7bjvjm3AaLaJ3 UjIYCTnIWjp_UUUYv7kC6x804xWl14x267AKxVWUJVW8JwAFc2x0x2IEx4CE42xK8VAvwI 8IcIk0rVWrJVCq3wAFIxvE14AKwVWUGVWUXwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xG Y2AK021l84ACjcxK6xIIjxv20xvE14v26r1I6r4UM28EF7xvwVC0I7IYx2IY6xkF7I0E14 v26r1j6r4UM28EF7xvwVC2z280aVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIEc7CjxVAF wI0_Cr1j6rxdM2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx 1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1Y6r17McIj6I8E87Iv 67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IY64vIr41lc7I2V7IY0VAS07 AlzVAYIcxG8wCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwCFI7km07C2 67AKxVWUAVWUtwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI 8E67AF67kF1VAFwI0_Jrv_JF1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWU CwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Jr0_Gr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r 1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Jr0_GrUvcSsG vfC2KfnxnUUI43ZEXa7IU8r9N3UUUUU== X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+e=80x24.org@sourceware.org 在 2023/9/19 下午6:11, Xi Ruoyao 写道: > By the way, GCC maintainers told me there may be future CPU models with > LSX/LASX but without UAL. Yes. > And if I read our string functions correctly, > the LSX/LASX ifuncs require UAL as well. Yes. > So we should only enable LSX > and LASX if UAL is also available, or make these string functions depend > on both LSX (LASX) and UAL. Is this properly implemented now? All lasx/lsx str/mem functions currently have only one assembly implementation. Therefore, when you enable lasx/lsx, there is only one lasx/lsx option available, regardless of whether UAL is enabled or not. However, we do not rule out the possibility of future alternative implementations for lasx/lsx. At that time, a combination of other features may be required. For example, both lasx and UAL would need to be enabled to select this new implementation. We hope to meet the selection criteria for different function implementations through various combinations of these options. > > On Sun, 2023-09-17 at 17:48 +0800, caiyinyu wrote: >> Key Points: >> 1. On lasx & lsx platforms, We must use _dl_runtime_{profile, resolve}_{lsx, lasx} >>    to save vector registers. >> 2. Via "tunables", users can choose str/mem_{lasx,lsx,unaligned} functions with >>    `export GLIBC_TUNABLES=glibc.cpu.hwcaps=LASX,...`. >>    Note: glibc.cpu.hwcaps doesn't affect _dl_runtime_{profile, resolve}_{lsx, lasx} >>    selection. >> >> Usage Notes: >> 1. Only valid inputs: LASX, LSX, UAL. Case-sensitive, comma-separated, no spaces. >> 2. Example: `export GLIBC_TUNABLES=glibc.cpu.hwcaps=LASX,UAL` turns on LASX & UAL. >>    Unmentioned features turn off. With default ifunc: lasx > lsx > unaligned > >>    aligned > generic, effect is: lasx > unaligned > aligned > generic; lsx off. >> 3. Incorrect GLIBC_TUNABLES settings will show error messages. >>    For example: On lsx platforms, you cannot enable lasx features. If you do >>    that, you will get error messages. >> 4. Valid input examples: >>    - GLIBC_TUNABLES=glibc.cpu.hwcaps=LASX: lasx > aligned > generic. >>    - GLIBC_TUNABLES=glibc.cpu.hwcaps=LSX,UAL: lsx > unaligned > aligned > generic. >>    - GLIBC_TUNABLES=glibc.cpu.hwcaps=LASX,UAL,LASX,UAL,LSX,LASX,UAL: Repetitions >>      allowed but not recommended. Results in: lasx > lsx > unaligned > aligned > >>      generic. >> --- >>  sysdeps/loongarch/Makefile                    |  4 + >>  sysdeps/loongarch/Versions                    |  5 ++ >>  sysdeps/loongarch/cpu-tunables.c              | 89 +++++++++++++++++++ >>  sysdeps/loongarch/dl-get-cpu-features.c       | 25 ++++++ >>  sysdeps/loongarch/dl-machine.h                | 27 +++++- >>  sysdeps/loongarch/dl-tunables.list            | 25 ++++++ >>  .../unix/sysv/linux/loongarch/cpu-features.c  | 29 ++++++ >>  .../unix/sysv/linux/loongarch/cpu-features.h  | 18 +++- >>  .../unix/sysv/linux/loongarch/dl-procinfo.c   | 60 +++++++++++++ >>  sysdeps/unix/sysv/linux/loongarch/dl-sysdep.c | 21 +++++ >>  .../unix/sysv/linux/loongarch/libc-start.c    | 34 +++++++ >>  11 files changed, 329 insertions(+), 8 deletions(-) >>  create mode 100644 sysdeps/loongarch/Versions >>  create mode 100644 sysdeps/loongarch/cpu-tunables.c >>  create mode 100644 sysdeps/loongarch/dl-get-cpu-features.c >>  create mode 100644 sysdeps/loongarch/dl-tunables.list >>  create mode 100644 sysdeps/unix/sysv/linux/loongarch/cpu-features.c >>  create mode 100644 sysdeps/unix/sysv/linux/loongarch/dl-procinfo.c >>  create mode 100644 sysdeps/unix/sysv/linux/loongarch/dl-sysdep.c >>  create mode 100644 sysdeps/unix/sysv/linux/loongarch/libc-start.c >> >> diff --git a/sysdeps/loongarch/Makefile b/sysdeps/loongarch/Makefile >> index 43d2f583cd..30a1f4a802 100644 >> --- a/sysdeps/loongarch/Makefile >> +++ b/sysdeps/loongarch/Makefile >> @@ -6,6 +6,10 @@ ifeq ($(subdir),elf) >>  gen-as-const-headers += dl-link.sym >>  endif >> >> +ifeq ($(subdir),elf) >> +  sysdep-dl-routines += dl-get-cpu-features >> +endif >> + >>  # LoongArch's assembler also needs to know about PIC as it changes the >>  # definition of some assembler macros. >>  ASFLAGS-.os += $(pic-ccflag) >> diff --git a/sysdeps/loongarch/Versions b/sysdeps/loongarch/Versions >> new file mode 100644 >> index 0000000000..33ae2cc079 >> --- /dev/null >> +++ b/sysdeps/loongarch/Versions >> @@ -0,0 +1,5 @@ >> +ld { >> +  GLIBC_PRIVATE { >> +    _dl_larch_get_cpu_features; >> +  } >> +} >> diff --git a/sysdeps/loongarch/cpu-tunables.c b/sysdeps/loongarch/cpu-tunables.c >> new file mode 100644 >> index 0000000000..8e9fab938b >> --- /dev/null >> +++ b/sysdeps/loongarch/cpu-tunables.c >> @@ -0,0 +1,89 @@ >> +/* LoongArch CPU feature tuning. >> +   This file is part of the GNU C Library. >> +   Copyright (C) 2023 Free Software Foundation, Inc. >> + >> +   The GNU C Library is free software; you can redistribute it and/or >> +   modify it under the terms of the GNU Lesser General Public >> +   License as published by the Free Software Foundation; either >> +   version 2.1 of the License, or (at your option) any later version. >> + >> +   The GNU C Library is distributed in the hope that it will be useful, >> +   but WITHOUT ANY WARRANTY; without even the implied warranty of >> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU >> +   Lesser General Public License for more details. >> + >> +   You should have received a copy of the GNU Lesser General Public >> +   License along with the GNU C Library; if not, see >> +   .  */ >> + >> +# include >> +# include >> +# include /* Get STDOUT_FILENO for _dl_printf.  */ >> +# include >> +# include >> +# include >> +# include >> +# include >> + >> +# define HWCAP_LOONGARCH_IFUNC \ >> +  (HWCAP_LOONGARCH_UAL | HWCAP_LOONGARCH_LSX | HWCAP_LOONGARCH_LASX) >> + >> +# define CHECK_GLIBC_IFUNC_CPU_OFF(f, name, len) \ >> +  _Static_assert (sizeof (#name) - 1 == len, #name " != " #len); \ >> +  if (!memcmp (f, #name, len) && \ >> +      (GLRO (dl_hwcap) & HWCAP_LOONGARCH_##name)) \ >> +    { \ >> +      hwcap |= (HWCAP_LOONGARCH_##name | (~HWCAP_LOONGARCH_IFUNC)); \ >> +      break; \ >> +    } \ >> + >> +attribute_hidden >> +void >> +TUNABLE_CALLBACK (set_hwcaps) (tunable_val_t *valp) >> +{ >> +  const char *p = valp->strval; >> +  size_t len; >> +  unsigned long hwcap = 0; >> +  const char *c; >> + >> +  do { >> +      for (c = p; *c != ','; c++) >> + if (*c == '\0') >> +   break; >> + >> +      len = c - p; >> + >> +      switch(len) >> +      { >> + default: >> +   _dl_fatal_printf ( >> +     "The valid values of glibc.cpu.hwcaps is UAL, LASX, LSX!!\n" >> +     ); >> +   break; >> + case 3: >> +   { >> +     CHECK_GLIBC_IFUNC_CPU_OFF (p, LSX, 3); >> +     CHECK_GLIBC_IFUNC_CPU_OFF (p, UAL, 3); >> +     _dl_fatal_printf ( >> + "Some features are invalid or not supported on this machine!!\n" >> + "The valid values of glibc.cpu.hwcaps is UAL, LASX, LSX!!\n" >> +                       ); >> +   } >> +   break; >> + case 4: >> +   { >> +     CHECK_GLIBC_IFUNC_CPU_OFF (p, LASX, 4); >> +     _dl_fatal_printf ( >> + "Some features are invalid or not supported on this machine!!\n" >> + "The valid values of glibc.cpu.hwcaps is UAL, LASX, LSX!!\n" >> +                       ); >> +   } >> +   break; >> +      } >> + >> +      p += len + 1; >> +    } >> +  while (*c != '\0'); >> + >> +  GLRO (dl_larch_cpu_features).hwcap &= hwcap; >> +} >> diff --git a/sysdeps/loongarch/dl-get-cpu-features.c b/sysdeps/loongarch/dl-get-cpu-features.c >> new file mode 100644 >> index 0000000000..7cd9bc15c3 >> --- /dev/null >> +++ b/sysdeps/loongarch/dl-get-cpu-features.c >> @@ -0,0 +1,25 @@ >> +/* Define _dl_larch_get_cpu_features. >> +   Copyright (C) 2023 Free Software Foundation, Inc. >> + >> +   The GNU C Library is free software; you can redistribute it and/or >> +   modify it under the terms of the GNU Lesser General Public >> +   License as published by the Free Software Foundation; either >> +   version 2.1 of the License, or (at your option) any later version. >> + >> +   The GNU C Library is distributed in the hope that it will be useful, >> +   but WITHOUT ANY WARRANTY; without even the implied warranty of >> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU >> +   Lesser General Public License for more details. >> + >> +   You should have received a copy of the GNU Lesser General Public >> +   License along with the GNU C Library; if not, see >> +   .  */ >> + >> + >> +#include >> + >> +const struct cpu_features * >> +_dl_larch_get_cpu_features (void) >> +{ >> +  return &GLRO(dl_larch_cpu_features); >> +} >> diff --git a/sysdeps/loongarch/dl-machine.h b/sysdeps/loongarch/dl-machine.h >> index 57913cefaa..b395a9283e 100644 >> --- a/sysdeps/loongarch/dl-machine.h >> +++ b/sysdeps/loongarch/dl-machine.h >> @@ -29,6 +29,8 @@ >>  #include >>  #include >> >> +#include >> + >>  #ifndef _RTLD_PROLOGUE >>  # define _RTLD_PROLOGUE(entry) \ >>   ".globl\t" __STRING (entry) "\n\t" \ >> @@ -53,6 +55,23 @@ >>  #define ELF_MACHINE_NO_REL 1 >>  #define ELF_MACHINE_NO_RELA 0 >> >> +#define DL_PLATFORM_INIT dl_platform_init () >> + >> +static inline void __attribute__ ((unused)) >> +dl_platform_init (void) >> +{ >> +  if (GLRO(dl_platform) != NULL && *GLRO(dl_platform) == '\0') >> +    /* Avoid an empty string which would disturb us.  */ >> +    GLRO(dl_platform) = NULL; >> + >> +#ifdef SHARED >> +  /* init_cpu_features has been called early from __libc_start_main in >> +     static executable.  */ >> +  init_cpu_features (&GLRO(dl_larch_cpu_features)); >> +#endif >> +} >> + >> + >>  /* Return nonzero iff ELF header is compatible with the running host.  */ >>  static inline int >>  elf_machine_matches_host (const ElfW (Ehdr) *ehdr) >> @@ -290,9 +309,9 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[], >>        if (profile != 0) >>   { >>  #if !defined __loongarch_soft_float >> -   if (SUPPORT_LASX) >> +   if (RTLD_SUPPORT_LASX) >>       gotplt[0] = (ElfW(Addr)) &_dl_runtime_profile_lasx; >> -   else if (SUPPORT_LSX) >> +   else if (RTLD_SUPPORT_LSX) >>       gotplt[0] = (ElfW(Addr)) &_dl_runtime_profile_lsx; >>     else >>  #endif >> @@ -310,9 +329,9 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[], >>        indicated by the offset on the stack, and then jump to >>        the resolved address.  */ >>  #if !defined __loongarch_soft_float >> -   if (SUPPORT_LASX) >> +   if (RTLD_SUPPORT_LASX) >>       gotplt[0] = (ElfW(Addr)) &_dl_runtime_resolve_lasx; >> -   else if (SUPPORT_LSX) >> +   else if (RTLD_SUPPORT_LSX) >>       gotplt[0] = (ElfW(Addr)) &_dl_runtime_resolve_lsx; >>     else >>  #endif >> diff --git a/sysdeps/loongarch/dl-tunables.list b/sysdeps/loongarch/dl-tunables.list >> new file mode 100644 >> index 0000000000..66b3427516 >> --- /dev/null >> +++ b/sysdeps/loongarch/dl-tunables.list >> @@ -0,0 +1,25 @@ >> +# LoongArch specific tunables. >> +# Copyright (C) 2023 Free Software Foundation, Inc. >> +# This file is part of the GNU C Library. >> + >> +# The GNU C Library is free software; you can redistribute it and/or >> +# modify it under the terms of the GNU Lesser General Public >> +# License as published by the Free Software Foundation; either >> +# version 2.1 of the License, or (at your option) any later version. >> + >> +# The GNU C Library is distributed in the hope that it will be useful, >> +# but WITHOUT ANY WARRANTY; without even the implied warranty of >> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU >> +# Lesser General Public License for more details. >> + >> +# You should have received a copy of the GNU Lesser General Public >> +# License along with the GNU C Library; if not, see >> +# . >> + >> +glibc { >> +  cpu { >> +    hwcaps { >> +      type: STRING >> +    } >> +  } >> +} >> diff --git a/sysdeps/unix/sysv/linux/loongarch/cpu-features.c b/sysdeps/unix/sysv/linux/loongarch/cpu-features.c >> new file mode 100644 >> index 0000000000..1290c4ce9f >> --- /dev/null >> +++ b/sysdeps/unix/sysv/linux/loongarch/cpu-features.c >> @@ -0,0 +1,29 @@ >> +/* Initialize CPU feature data.  LoongArch64 version. >> +   This file is part of the GNU C Library. >> +   Copyright (C) 2023 Free Software Foundation, Inc. >> + >> +   The GNU C Library is free software; you can redistribute it and/or >> +   modify it under the terms of the GNU Lesser General Public >> +   License as published by the Free Software Foundation; either >> +   version 2.1 of the License, or (at your option) any later version. >> + >> +   The GNU C Library is distributed in the hope that it will be useful, >> +   but WITHOUT ANY WARRANTY; without even the implied warranty of >> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU >> +   Lesser General Public License for more details. >> + >> +   You should have received a copy of the GNU Lesser General Public >> +   License along with the GNU C Library; if not, see >> +   .  */ >> + >> +#include >> +#include >> +#include >> +extern void TUNABLE_CALLBACK (set_hwcaps) (tunable_val_t *) attribute_hidden; >> + >> +static inline void >> +init_cpu_features (struct cpu_features *cpu_features) >> +{ >> +    GLRO (dl_larch_cpu_features).hwcap = GLRO (dl_hwcap); >> +    TUNABLE_GET (glibc, cpu, hwcaps, tunable_val_t *, TUNABLE_CALLBACK (set_hwcaps)); >> +} >> diff --git a/sysdeps/unix/sysv/linux/loongarch/cpu-features.h b/sysdeps/unix/sysv/linux/loongarch/cpu-features.h >> index d1a280a5ee..450963cebc 100644 >> --- a/sysdeps/unix/sysv/linux/loongarch/cpu-features.h >> +++ b/sysdeps/unix/sysv/linux/loongarch/cpu-features.h >> @@ -19,13 +19,23 @@ >>  #ifndef _CPU_FEATURES_LOONGARCH64_H >>  #define _CPU_FEATURES_LOONGARCH64_H >> >> +#include >>  #include >> >> -#define SUPPORT_UAL (GLRO (dl_hwcap) & HWCAP_LOONGARCH_UAL) >> -#define SUPPORT_LSX (GLRO (dl_hwcap) & HWCAP_LOONGARCH_LSX) >> -#define SUPPORT_LASX (GLRO (dl_hwcap) & HWCAP_LOONGARCH_LASX) >> +struct cpu_features >> + { >> +    uint64_t hwcap; >> + }; >> >> +/* Get a pointer to the CPU features structure.  */ >> +extern const struct cpu_features *_dl_larch_get_cpu_features (void) >> +     __attribute__ ((pure)); >> + >> +#define SUPPORT_UAL (GLRO (dl_larch_cpu_features).hwcap & HWCAP_LOONGARCH_UAL) >> +#define SUPPORT_LSX (GLRO (dl_larch_cpu_features).hwcap & HWCAP_LOONGARCH_LSX) >> +#define SUPPORT_LASX (GLRO (dl_larch_cpu_features).hwcap & HWCAP_LOONGARCH_LASX) >> +#define RTLD_SUPPORT_LSX (GLRO (dl_hwcap) & HWCAP_LOONGARCH_LSX) >> +#define RTLD_SUPPORT_LASX (GLRO (dl_hwcap) & HWCAP_LOONGARCH_LASX) >>  #define INIT_ARCH() >> >>  #endif /* _CPU_FEATURES_LOONGARCH64_H  */ >> - >> diff --git a/sysdeps/unix/sysv/linux/loongarch/dl-procinfo.c b/sysdeps/unix/sysv/linux/loongarch/dl-procinfo.c >> new file mode 100644 >> index 0000000000..6217fda983 >> --- /dev/null >> +++ b/sysdeps/unix/sysv/linux/loongarch/dl-procinfo.c >> @@ -0,0 +1,60 @@ >> +/* Data for LoongArch64 version of processor capability information. >> +   Linux version. >> +   Copyright (C) 2023 Free Software Foundation, Inc. >> +   This file is part of the GNU C Library. >> + >> +   The GNU C Library is free software; you can redistribute it and/or >> +   modify it under the terms of the GNU Lesser General Public >> +   License as published by the Free Software Foundation; either >> +   version 2.1 of the License, or (at your option) any later version. >> + >> +   The GNU C Library is distributed in the hope that it will be useful, >> +   but WITHOUT ANY WARRANTY; without even the implied warranty of >> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU >> +   Lesser General Public License for more details. >> + >> +   You should have received a copy of the GNU Lesser General Public >> +   License along with the GNU C Library; if not, see >> +   .  */ >> + >> +/* If anything should be added here check whether the size of each string >> +   is still ok with the given array size. >> + >> +   All the #ifdefs in the definitions are quite irritating but >> +   necessary if we want to avoid duplicating the information.  There >> +   are three different modes: >> + >> +   - PROCINFO_DECL is defined.  This means we are only interested in >> +     declarations. >> + >> +   - PROCINFO_DECL is not defined: >> + >> +     + if SHARED is defined the file is included in an array >> +       initializer.  The .element = { ... } syntax is needed. >> + >> +     + if SHARED is not defined a normal array initialization is >> +       needed. >> +  */ >> + >> +#ifndef PROCINFO_CLASS >> +# define PROCINFO_CLASS >> +#endif >> + >> +#if !IS_IN (ldconfig) >> +# if !defined PROCINFO_DECL && defined SHARED >> +  ._dl_larch_cpu_features >> +# else >> +PROCINFO_CLASS struct cpu_features _dl_larch_cpu_features >> +# endif >> +# ifndef PROCINFO_DECL >> += { } >> +# endif >> +# if !defined SHARED || defined PROCINFO_DECL >> +; >> +# else >> +, >> +# endif >> +#endif >> + >> +#undef PROCINFO_DECL >> +#undef PROCINFO_CLASS >> diff --git a/sysdeps/unix/sysv/linux/loongarch/dl-sysdep.c b/sysdeps/unix/sysv/linux/loongarch/dl-sysdep.c >> new file mode 100644 >> index 0000000000..455fd71abc >> --- /dev/null >> +++ b/sysdeps/unix/sysv/linux/loongarch/dl-sysdep.c >> @@ -0,0 +1,21 @@ >> +/* Operating system support for run-time dynamic linker.  LoongArch version. >> +   Copyright (C) 2023 Free Software Foundation, Inc. >> +   This file is part of the GNU C Library. >> + >> +   The GNU C Library is free software; you can redistribute it and/or >> +   modify it under the terms of the GNU Lesser General Public >> +   License as published by the Free Software Foundation; either >> +   version 2.1 of the License, or (at your option) any later version. >> + >> +   The GNU C Library is distributed in the hope that it will be useful, >> +   but WITHOUT ANY WARRANTY; without even the implied warranty of >> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU >> +   Lesser General Public License for more details. >> + >> +   You should have received a copy of the GNU Lesser General Public >> +   License along with the GNU C Library; if not, see >> +   .  */ >> + >> +#include >> +#include >> +#include >> diff --git a/sysdeps/unix/sysv/linux/loongarch/libc-start.c b/sysdeps/unix/sysv/linux/loongarch/libc-start.c >> new file mode 100644 >> index 0000000000..f1346ece0a >> --- /dev/null >> +++ b/sysdeps/unix/sysv/linux/loongarch/libc-start.c >> @@ -0,0 +1,34 @@ >> +/* Override csu/libc-start.c on LoongArch64. >> +   Copyright (C) 2023 Free Software Foundation, Inc. >> +   This file is part of the GNU C Library. >> + >> +   The GNU C Library is free software; you can redistribute it and/or >> +   modify it under the terms of the GNU Lesser General Public >> +   License as published by the Free Software Foundation; either >> +   version 2.1 of the License, or (at your option) any later version. >> + >> +   The GNU C Library is distributed in the hope that it will be useful, >> +   but WITHOUT ANY WARRANTY; without even the implied warranty of >> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU >> +   Lesser General Public License for more details. >> + >> +   You should have received a copy of the GNU Lesser General Public >> +   License along with the GNU C Library; if not, see >> +   .  */ >> + >> +#ifndef SHARED >> + >> +/* Mark symbols hidden in static PIE for early self relocation to work.  */ >> +# if BUILD_PIE_DEFAULT >> +#  pragma GCC visibility push(hidden) >> +# endif >> + >> +# include >> +# include >> + >> +extern struct cpu_features _dl_larch_cpu_features; >> + >> +# define ARCH_INIT_CPU_FEATURES() init_cpu_features (&_dl_larch_cpu_features) >> + >> +#endif >> +#include