diff mbox

[i386,musl] Add cpuinfo to static libgcc only on *-musl*

Message ID 5825E8BF.3020501@arm.com
State New
Headers show

Commit Message

Szabolcs Nagy Nov. 11, 2016, 3:50 p.m. UTC
The __cpu_indicator_init and __cpu_model symbols are not safe to use
from shared libgcc_s.so from ifunc resolvers, so since gcc-6, only
the definitions from static libgcc.a are used, however the symbols
are kept in libgcc_s as well for backward compatibility (with
appropriate symbol version).  On targets without such backward
compatibility concern add cpuinfo to the static library only (this
avoids running the ctor, reduces libgcc_s size and elf abi concerns
because of gnu symbol versions).

build tested on x86_64-linux-gnu and x86_64-linux-musl.

ok to commit?

i'd like to back port this to gcc-6 because musl dynamic linker
cannot load the libgcc_s.so.1 with the versioned symbols
(not an abi break: those symbols were never used on musl and
the current code does not work).

libgcc/ChangeLog:

2016-11-11  Szabolcs Nagy  <szabolcs.nagy@arm.com>

	* config.host (i[3456]86-*-musl*, x86_64-*-musl*): Use
	i386/t-cpuinfo-static instead of i386/t-cpuinfo.
	* config/i386/t-cpuinfo-static: New.

Comments

Uros Bizjak Nov. 11, 2016, 4:40 p.m. UTC | #1
On Fri, Nov 11, 2016 at 4:50 PM, Szabolcs Nagy <szabolcs.nagy@arm.com> wrote:
> The __cpu_indicator_init and __cpu_model symbols are not safe to use
> from shared libgcc_s.so from ifunc resolvers, so since gcc-6, only
> the definitions from static libgcc.a are used, however the symbols
> are kept in libgcc_s as well for backward compatibility (with
> appropriate symbol version).  On targets without such backward
> compatibility concern add cpuinfo to the static library only (this
> avoids running the ctor, reduces libgcc_s size and elf abi concerns
> because of gnu symbol versions).
>
> build tested on x86_64-linux-gnu and x86_64-linux-musl.
>
> ok to commit?
>
> i'd like to back port this to gcc-6 because musl dynamic linker
> cannot load the libgcc_s.so.1 with the versioned symbols
> (not an abi break: those symbols were never used on musl and
> the current code does not work).
>
> libgcc/ChangeLog:
>
> 2016-11-11  Szabolcs Nagy  <szabolcs.nagy@arm.com>
>
>         * config.host (i[3456]86-*-musl*, x86_64-*-musl*): Use
>         i386/t-cpuinfo-static instead of i386/t-cpuinfo.
>         * config/i386/t-cpuinfo-static: New.

LGTM, it is musl specific, but you know the musl part best ;)

Rubber-stamped OK for mainline and backports.

Thanks,
Uros.
Rich Felker Nov. 11, 2016, 4:43 p.m. UTC | #2
On Fri, Nov 11, 2016 at 05:40:04PM +0100, Uros Bizjak wrote:
> On Fri, Nov 11, 2016 at 4:50 PM, Szabolcs Nagy <szabolcs.nagy@arm.com> wrote:
> > The __cpu_indicator_init and __cpu_model symbols are not safe to use
> > from shared libgcc_s.so from ifunc resolvers, so since gcc-6, only
> > the definitions from static libgcc.a are used, however the symbols
> > are kept in libgcc_s as well for backward compatibility (with
> > appropriate symbol version).  On targets without such backward
> > compatibility concern add cpuinfo to the static library only (this
> > avoids running the ctor, reduces libgcc_s size and elf abi concerns
> > because of gnu symbol versions).
> >
> > build tested on x86_64-linux-gnu and x86_64-linux-musl.
> >
> > ok to commit?
> >
> > i'd like to back port this to gcc-6 because musl dynamic linker
> > cannot load the libgcc_s.so.1 with the versioned symbols
> > (not an abi break: those symbols were never used on musl and
> > the current code does not work).
> >
> > libgcc/ChangeLog:
> >
> > 2016-11-11  Szabolcs Nagy  <szabolcs.nagy@arm.com>
> >
> >         * config.host (i[3456]86-*-musl*, x86_64-*-musl*): Use
> >         i386/t-cpuinfo-static instead of i386/t-cpuinfo.
> >         * config/i386/t-cpuinfo-static: New.
> 
> LGTM, it is musl specific, but you know the musl part best ;)
> 
> Rubber-stamped OK for mainline and backports.

I would have preferred the previously-rejected fix getting rid of the
gratuitous dependency on binding to a non-default symver, that works
the same on all targets, but I'm fine with whatever fixes the problem
without introducing new ABI mess.

Rich
diff mbox

Patch

diff --git a/libgcc/config.host b/libgcc/config.host
index 4291cfe..64beb21 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -1320,7 +1320,14 @@  esac
 
 case ${host} in
 i[34567]86-*-* | x86_64-*-*)
-	tmake_file="${tmake_file} i386/t-cpuinfo"
+	case ${host} in
+	*-musl*)
+		tmake_file="${tmake_file} i386/t-cpuinfo-static"
+		;;
+	*)
+		tmake_file="${tmake_file} i386/t-cpuinfo"
+		;;
+	esac
 	;;
 esac
 
diff --git a/libgcc/config/i386/t-cpuinfo-static b/libgcc/config/i386/t-cpuinfo-static
new file mode 100644
index 0000000..504307d
--- /dev/null
+++ b/libgcc/config/i386/t-cpuinfo-static
@@ -0,0 +1,4 @@ 
+# If the compatibility cpuinfo symbols in shared libgcc_s are not needed
+# then they can be added to the static library only.
+
+LIB2ADD_ST += $(srcdir)/config/i386/cpuinfo.c