diff mbox series

[2/2] sparc: Run SUBTARGET_INIT_BUILTINS if it exists

Message ID 20210213122030.GA1488@SDF.ORG
State New
Headers show
Series [1/2] aarch64: Run SUBTARGET_INIT_BUILTINS if it exists | expand

Commit Message

Maya Rashish Feb. 13, 2021, 12:20 p.m. UTC
Some subtargets don't provide the canonical function names as
the symbol name in C libraries, and libcalls will only work if
the builtins are patched to emit the correct library name.

For example, on NetBSD, cabsl has the symbol name __c99_cabsl,
and the patching is done via netbsd_patch_builtin.

With this change, libgfortran.so is correctly built with a
reference to __c99_cabsl, instead of "cabsl" which is not defined.

gcc/ChangeLog:
        * config/sparc/sparc.c
          (sparc_init_builtins): Call SUBTARGET_INIT_BUILTINS.
---
 gcc/config/sparc/sparc.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Li, Pan2 via Gcc-patches Feb. 13, 2021, 12:30 p.m. UTC | #1
I hope that writing the detailed commit message will encourage someone
with better knowledge of GCC internals to point out a better place for
this logic. I can follow through with any suggestions :)

On Sat, Feb 13, 2021 at 12:20:30PM +0000, Maya Rashish wrote:
> Some subtargets don't provide the canonical function names as
> the symbol name in C libraries, and libcalls will only work if
> the builtins are patched to emit the correct library name.
> 
> For example, on NetBSD, cabsl has the symbol name __c99_cabsl,
> and the patching is done via netbsd_patch_builtin.
> 
> With this change, libgfortran.so is correctly built with a
> reference to __c99_cabsl, instead of "cabsl" which is not defined.
Eric Botcazou Feb. 15, 2021, 3:12 p.m. UTC | #2
> Some subtargets don't provide the canonical function names as
> the symbol name in C libraries, and libcalls will only work if
> the builtins are patched to emit the correct library name.
> 
> For example, on NetBSD, cabsl has the symbol name __c99_cabsl,
> and the patching is done via netbsd_patch_builtin.
> 
> With this change, libgfortran.so is correctly built with a
> reference to __c99_cabsl, instead of "cabsl" which is not defined.

The change is OK modulo a couple of nits:

> gcc/ChangeLog:
>         * config/sparc/sparc.c
>           (sparc_init_builtins): Call SUBTARGET_INIT_BUILTINS.

The name of the function on the first line.

> ---
>  gcc/config/sparc/sparc.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c
> index f3557936114..fe6475f2520 100644
> --- a/gcc/config/sparc/sparc.c
> +++ b/gcc/config/sparc/sparc.c
> @@ -10962,6 +10962,9 @@ sparc_init_builtins (void)
> 
>    if (TARGET_VIS)
>      sparc_vis_init_builtins ();
> +#ifdef SUBTARGET_INIT_BUILTINS
> +  SUBTARGET_INIT_BUILTINS;
> +#endif
>  }

Missing blank line before the change.
diff mbox series

Patch

diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c
index f3557936114..fe6475f2520 100644
--- a/gcc/config/sparc/sparc.c
+++ b/gcc/config/sparc/sparc.c
@@ -10962,6 +10962,9 @@  sparc_init_builtins (void)
 
   if (TARGET_VIS)
     sparc_vis_init_builtins ();
+#ifdef SUBTARGET_INIT_BUILTINS
+  SUBTARGET_INIT_BUILTINS;
+#endif
 }
 
 /* Create builtin functions for FPU instructions.  */