Message ID | 20220819151734.926106-9-Ben.Wolsieffer@hefring.com |
---|---|
State | Deferred |
Headers | show |
Series | Add support for FDPIC binaries on ARM | expand |
Ben, All, On 2022-08-19 11:17 -0400, Ben Wolsieffer spake thusly: > Patch the target matching code in libtool to understand > arm-*-uclinuxfdpiceabi targets. To avoid the need to run autoreconf, > this patching must be performed in the configure script. > > Without this patch, libtool refuses to build ARM FDPIC shared libraries. > This is especially important because NPTL thread-local storage is broken > in static libraries that are linked into dynamic FDPIC executables. If static build is known to be broken with FDPIC, then maybe we should just forbid it: config BR2_STATIC_LIBS bool "static only" depends on BR2_BINFMT_SUPPORTS_STATIC depends on !BR2_TOOLCHAIN_USES_GLIBC comment "static only needs a toolchain w/ uclibc or musl" depends on BR2_BINFMT_SUPPORTS_STATIC depends on BR2_TOOLCHAIN_USES_GLIBC config BR2_SHARED_LIBS bool "shared only" depends on BR2_BINFMT_SUPPORTS_SHARED config BR2_SHARED_STATIC_LIBS bool "both static and shared" depends on BR2_BINFMT_SUPPORTS_STATIC && BR2_BINFMT_SUPPORTS_SHARED BR2_BINFMT_SUPPORTS_STATIC would be a new symbol that BR2_BINFMT_ELF and BR2_BINFMT_FLAT would select, but not BR2_BINFMT_FDPIC. Regards, Yann E. MORIN. > Signed-off-by: Ben Wolsieffer <Ben.Wolsieffer@hefring.com> > --- > package/pkg-autotools.mk | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) > > diff --git a/package/pkg-autotools.mk b/package/pkg-autotools.mk > index b6224b349d..60e70a6e2f 100644 > --- a/package/pkg-autotools.mk > +++ b/package/pkg-autotools.mk > @@ -87,6 +87,16 @@ define CONFIGURE_FIX_POWERPC64_HOOK > support/scripts/fix-configure-powerpc64.sh $($(PKG)_DIR) > endef > > +# > +# Hook to add support for arm-*-uclinuxfdpiceabi to the configure script > +# > +define CONFIGURE_FIX_UCLINUXFDPICEABI_HOOK > + @$(call MESSAGE,"Adding uclinuxfdpiceabi to configure") > + find $($(PKG)_DIR) -name configure \ > + -exec grep -qF 'Generated by GNU Autoconf' {} \; \ > + -exec sed -Ei 's#((\s|^)linux\*\B)#\1 | uclinuxfdpiceabi#' '{}' \; > +endef > + > # > # Hook to gettextize the package if needed > # > @@ -269,6 +279,13 @@ ifneq ($$(filter powerpc64%,$$(if $$(filter target,$(4)),$$(ARCH),$$(HOSTARCH))) > $(2)_PRE_CONFIGURE_HOOKS += CONFIGURE_FIX_POWERPC64_HOOK > endif > > +# Append a configure hook if building for ARM with FDPIC enabled. > +# Must be added after other pre-configure hooks that might regenerate the > +# configure script and overwrite the changes made here. > +ifeq ($(BR2_arm)$(BR2_armeb):$(BR2_BINFMT_FDPIC),y:y) > +$(2)_PRE_CONFIGURE_HOOKS += CONFIGURE_FIX_UCLINUXFDPICEABI_HOOK > +endif > + > # > # Build step. Only define it if not already defined by the package .mk > # file. > -- > 2.37.0 > > _______________________________________________ > buildroot mailing list > buildroot@buildroot.org > https://lists.buildroot.org/mailman/listinfo/buildroot
diff --git a/package/pkg-autotools.mk b/package/pkg-autotools.mk index b6224b349d..60e70a6e2f 100644 --- a/package/pkg-autotools.mk +++ b/package/pkg-autotools.mk @@ -87,6 +87,16 @@ define CONFIGURE_FIX_POWERPC64_HOOK support/scripts/fix-configure-powerpc64.sh $($(PKG)_DIR) endef +# +# Hook to add support for arm-*-uclinuxfdpiceabi to the configure script +# +define CONFIGURE_FIX_UCLINUXFDPICEABI_HOOK + @$(call MESSAGE,"Adding uclinuxfdpiceabi to configure") + find $($(PKG)_DIR) -name configure \ + -exec grep -qF 'Generated by GNU Autoconf' {} \; \ + -exec sed -Ei 's#((\s|^)linux\*\B)#\1 | uclinuxfdpiceabi#' '{}' \; +endef + # # Hook to gettextize the package if needed # @@ -269,6 +279,13 @@ ifneq ($$(filter powerpc64%,$$(if $$(filter target,$(4)),$$(ARCH),$$(HOSTARCH))) $(2)_PRE_CONFIGURE_HOOKS += CONFIGURE_FIX_POWERPC64_HOOK endif +# Append a configure hook if building for ARM with FDPIC enabled. +# Must be added after other pre-configure hooks that might regenerate the +# configure script and overwrite the changes made here. +ifeq ($(BR2_arm)$(BR2_armeb):$(BR2_BINFMT_FDPIC),y:y) +$(2)_PRE_CONFIGURE_HOOKS += CONFIGURE_FIX_UCLINUXFDPICEABI_HOOK +endif + # # Build step. Only define it if not already defined by the package .mk # file.
Patch the target matching code in libtool to understand arm-*-uclinuxfdpiceabi targets. To avoid the need to run autoreconf, this patching must be performed in the configure script. Without this patch, libtool refuses to build ARM FDPIC shared libraries. This is especially important because NPTL thread-local storage is broken in static libraries that are linked into dynamic FDPIC executables. Signed-off-by: Ben Wolsieffer <Ben.Wolsieffer@hefring.com> --- package/pkg-autotools.mk | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)