Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] libmemcached: don't use -fPIE and -pie with FLAT binaries
@ 2015-05-11 20:55 Thomas Petazzoni
  2015-05-11 22:17 ` Romain Naour
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Thomas Petazzoni @ 2015-05-11 20:55 UTC (permalink / raw)
  To: buildroot

FLAT binaries cannot use -fPIE and -pie code, so let's teach
libmemcached to not use such flags when BR2_BINFMT_FLAT=y.

Fixes:

  http://autobuild.buildroot.org/results/8cb/8cbf57f9136cb42be31c88e0f1f32d3d2353e5ff/
  and many previous similar build failures

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
 package/libmemcached/libmemcached.mk | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/package/libmemcached/libmemcached.mk b/package/libmemcached/libmemcached.mk
index d442b3c..f32963d 100644
--- a/package/libmemcached/libmemcached.mk
+++ b/package/libmemcached/libmemcached.mk
@@ -18,4 +18,15 @@ LIBMEMCACHED_AUTORECONF = YES
 LIBMEMCACHED_LICENSE = BSD-3c
 LIBMEMCACHED_LICENSE_FILES = COPYING
 
+# Help libmemcached to understand that -fPIE and -pie should not be
+# used when FLAT binaries are used (shared libraries are not
+# supported).
+ifeq ($(BR2_BINFMT_FLAT),y)
+LIBMEMCACHED_CONF_ENV += \
+	ax_cv_check_cflags__Werror__fPIE=no \
+	ax_cv_check_cflags__Werror__pie=no \
+	ax_cv_check_cxxflags__Werror__fPIE=no \
+	ax_cv_check_cxxflags__Werror__pie=no
+endif
+
 $(eval $(autotools-package))
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Buildroot] [PATCH] libmemcached: don't use -fPIE and -pie with FLAT binaries
  2015-05-11 20:55 [Buildroot] [PATCH] libmemcached: don't use -fPIE and -pie with FLAT binaries Thomas Petazzoni
@ 2015-05-11 22:17 ` Romain Naour
  2015-05-11 22:19 ` Peter Korsgaard
  2015-05-12 14:17 ` Peter Korsgaard
  2 siblings, 0 replies; 8+ messages in thread
From: Romain Naour @ 2015-05-11 22:17 UTC (permalink / raw)
  To: buildroot

Hi Thomas,

Le 11/05/2015 22:55, Thomas Petazzoni a ?crit :
> FLAT binaries cannot use -fPIE and -pie code, so let's teach
> libmemcached to not use such flags when BR2_BINFMT_FLAT=y.
> 
> Fixes:
> 
>   http://autobuild.buildroot.org/results/8cb/8cbf57f9136cb42be31c88e0f1f32d3d2353e5ff/
>   and many previous similar build failures
> 
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>

I "build" tested your patch an get another error during the man build.
See http://patchwork.ozlabs.org/patch/471050/
With that fixed, libmemcached build fine on bfin.

Reviewed-by: Romain Naour <romain.naour@openwide.fr>
Tested-by: Romain Naour <romain.naour@openwide.fr>

Best regards,
Romain
> ---
>  package/libmemcached/libmemcached.mk | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/package/libmemcached/libmemcached.mk b/package/libmemcached/libmemcached.mk
> index d442b3c..f32963d 100644
> --- a/package/libmemcached/libmemcached.mk
> +++ b/package/libmemcached/libmemcached.mk
> @@ -18,4 +18,15 @@ LIBMEMCACHED_AUTORECONF = YES
>  LIBMEMCACHED_LICENSE = BSD-3c
>  LIBMEMCACHED_LICENSE_FILES = COPYING
>  
> +# Help libmemcached to understand that -fPIE and -pie should not be
> +# used when FLAT binaries are used (shared libraries are not
> +# supported).
> +ifeq ($(BR2_BINFMT_FLAT),y)
> +LIBMEMCACHED_CONF_ENV += \
> +	ax_cv_check_cflags__Werror__fPIE=no \
> +	ax_cv_check_cflags__Werror__pie=no \
> +	ax_cv_check_cxxflags__Werror__fPIE=no \
> +	ax_cv_check_cxxflags__Werror__pie=no
> +endif
> +
>  $(eval $(autotools-package))
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Buildroot] [PATCH] libmemcached: don't use -fPIE and -pie with FLAT binaries
  2015-05-11 20:55 [Buildroot] [PATCH] libmemcached: don't use -fPIE and -pie with FLAT binaries Thomas Petazzoni
  2015-05-11 22:17 ` Romain Naour
@ 2015-05-11 22:19 ` Peter Korsgaard
  2015-05-12 11:26   ` Thomas Petazzoni
  2015-05-12 14:17 ` Peter Korsgaard
  2 siblings, 1 reply; 8+ messages in thread
From: Peter Korsgaard @ 2015-05-11 22:19 UTC (permalink / raw)
  To: buildroot

>>>>> "Thomas" == Thomas Petazzoni <thomas.petazzoni@free-electrons.com> writes:

 > FLAT binaries cannot use -fPIE and -pie code, so let's teach
 > libmemcached to not use such flags when BR2_BINFMT_FLAT=y.

 > Fixes:

 >   http://autobuild.buildroot.org/results/8cb/8cbf57f9136cb42be31c88e0f1f32d3d2353e5ff/
 >   and many previous similar build failures

 > Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
 
 > +# Help libmemcached to understand that -fPIE and -pie should not be
 > +# used when FLAT binaries are used (shared libraries are not
 > +# supported).
 > +ifeq ($(BR2_BINFMT_FLAT),y)
 > +LIBMEMCACHED_CONF_ENV += \
 > +	ax_cv_check_cflags__Werror__fPIE=no \
 > +	ax_cv_check_cflags__Werror__pie=no \
 > +	ax_cv_check_cxxflags__Werror__fPIE=no \
 > +	ax_cv_check_cxxflags__Werror__pie=no
 > +endif

BINFMT_FLAT implies BR2_STATIC_LIBS and (elf) static libraries should
also not be built with -fPIE / -pie, right?

Is there any specific reason to only do this workaround for BINFMT_FLAT?

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Buildroot] [PATCH] libmemcached: don't use -fPIE and -pie with FLAT binaries
  2015-05-11 22:19 ` Peter Korsgaard
@ 2015-05-12 11:26   ` Thomas Petazzoni
  2015-05-12 12:20     ` Peter Korsgaard
  0 siblings, 1 reply; 8+ messages in thread
From: Thomas Petazzoni @ 2015-05-12 11:26 UTC (permalink / raw)
  To: buildroot

Dear Peter Korsgaard,

On Tue, 12 May 2015 00:19:14 +0200, Peter Korsgaard wrote:

> BINFMT_FLAT implies BR2_STATIC_LIBS and (elf) static libraries should
> also not be built with -fPIE / -pie, right?
> 
> Is there any specific reason to only do this workaround for BINFMT_FLAT?

Actually, I'm a bit confused. Shouldn't FLAT binaries be PIE ? Since
there's no MMU, each binary will be loaded at a different address, so
binaries should be PIE, no?

But the original reason why I removed -pie is because of:

  https://www.mail-archive.com/toolchain-devel at blackfin.uclinux.org/msg02113.html

For the exact same error, Mike Frysinger says to remove the -pie flag.

Hum, http://www.kdvelectronics.eu/uClinux-cisco2500/exotica.html seems
to indicate that PIE is not required in all cases for FLAT binaries.

I would tend to trust Mike Frysinger on this, though :)

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Buildroot] [PATCH] libmemcached: don't use -fPIE and -pie with FLAT binaries
  2015-05-12 11:26   ` Thomas Petazzoni
@ 2015-05-12 12:20     ` Peter Korsgaard
  2015-05-12 12:22       ` Thomas Petazzoni
  0 siblings, 1 reply; 8+ messages in thread
From: Peter Korsgaard @ 2015-05-12 12:20 UTC (permalink / raw)
  To: buildroot

>>>>> "Thomas" == Thomas Petazzoni <thomas.petazzoni@free-electrons.com> writes:

 > Dear Peter Korsgaard,
 > On Tue, 12 May 2015 00:19:14 +0200, Peter Korsgaard wrote:

 >> BINFMT_FLAT implies BR2_STATIC_LIBS and (elf) static libraries should
 >> also not be built with -fPIE / -pie, right?
 >> 
 >> Is there any specific reason to only do this workaround for BINFMT_FLAT?

 > Actually, I'm a bit confused. Shouldn't FLAT binaries be PIE ? Since
 > there's no MMU, each binary will be loaded at a different address, so
 > binaries should be PIE, no?

 > But the original reason why I removed -pie is because of:

 >   https://www.mail-archive.com/toolchain-devel at blackfin.uclinux.org/msg02113.html

 > For the exact same error, Mike Frysinger says to remove the -pie flag.

 > Hum, http://www.kdvelectronics.eu/uClinux-cisco2500/exotica.html seems
 > to indicate that PIE is not required in all cases for FLAT binaries.

 > I would tend to trust Mike Frysinger on this, though :)

That's also the understanding I get from reading:

http://retired.beyondlogic.org/uClinux/bflt.htm

The flat format has its own relocation table that gets applied when
loading.

I'm not quite sure how this would work with XIP though. The bottom of
that page mentions that the binary then has to be built in PIC mode.

But my question was actually why we shouldn't disable PIE/PIC for static
builds in general, and not just for flat mode?

-- 
Peter Korsgaard 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Buildroot] [PATCH] libmemcached: don't use -fPIE and -pie with FLAT binaries
  2015-05-12 12:20     ` Peter Korsgaard
@ 2015-05-12 12:22       ` Thomas Petazzoni
  2015-05-12 13:02         ` Peter Korsgaard
  0 siblings, 1 reply; 8+ messages in thread
From: Thomas Petazzoni @ 2015-05-12 12:22 UTC (permalink / raw)
  To: buildroot

Dear Peter Korsgaard,

On Tue, 12 May 2015 14:20:03 +0200, Peter Korsgaard wrote:

> That's also the understanding I get from reading:
> 
> http://retired.beyondlogic.org/uClinux/bflt.htm
> 
> The flat format has its own relocation table that gets applied when
> loading.

Ok.

> I'm not quite sure how this would work with XIP though. The bottom of
> that page mentions that the binary then has to be built in PIC mode.
> 
> But my question was actually why we shouldn't disable PIE/PIC for static
> builds in general, and not just for flat mode?

Yes, -fPIC is not needed for static, but it works (it generates
slightly less efficient code though). But I'm fine with turning this
BR2_BINFMT_FLAT condition to a BR2_STATIC_LIBS condition.

But in practice, they are lots of packages that build code only once to
generate both a shared library and a static library, and they use -fPIC
for both. Guaranteeing that all static libraries have non-PIC code
would be a major effort.

Should I resend an updated patch, or will you commit after doing the
change?

Thanks,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Buildroot] [PATCH] libmemcached: don't use -fPIE and -pie with FLAT binaries
  2015-05-12 12:22       ` Thomas Petazzoni
@ 2015-05-12 13:02         ` Peter Korsgaard
  0 siblings, 0 replies; 8+ messages in thread
From: Peter Korsgaard @ 2015-05-12 13:02 UTC (permalink / raw)
  To: buildroot

>>>>> "Thomas" == Thomas Petazzoni <thomas.petazzoni@free-electrons.com> writes:

Hi,

>> But my question was actually why we shouldn't disable PIE/PIC for static
 >> builds in general, and not just for flat mode?

 > Yes, -fPIC is not needed for static, but it works (it generates
 > slightly less efficient code though). But I'm fine with turning this
 > BR2_BINFMT_FLAT condition to a BR2_STATIC_LIBS condition.

 > But in practice, they are lots of packages that build code only once to
 > generate both a shared library and a static library, and they use -fPIC
 > for both. Guaranteeing that all static libraries have non-PIC code
 > would be a major effort.

 > Should I resend an updated patch, or will you commit after doing the
 > change?

I'll just fix it up when applying, thanks.

-- 
Venlig hilsen,
Peter Korsgaard 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Buildroot] [PATCH] libmemcached: don't use -fPIE and -pie with FLAT binaries
  2015-05-11 20:55 [Buildroot] [PATCH] libmemcached: don't use -fPIE and -pie with FLAT binaries Thomas Petazzoni
  2015-05-11 22:17 ` Romain Naour
  2015-05-11 22:19 ` Peter Korsgaard
@ 2015-05-12 14:17 ` Peter Korsgaard
  2 siblings, 0 replies; 8+ messages in thread
From: Peter Korsgaard @ 2015-05-12 14:17 UTC (permalink / raw)
  To: buildroot

>>>>> "Thomas" == Thomas Petazzoni <thomas.petazzoni@free-electrons.com> writes:

 > FLAT binaries cannot use -fPIE and -pie code, so let's teach
 > libmemcached to not use such flags when BR2_BINFMT_FLAT=y.

 > Fixes:

 >   http://autobuild.buildroot.org/results/8cb/8cbf57f9136cb42be31c88e0f1f32d3d2353e5ff/
 >   and many previous similar build failures

 > Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>

Committed after reworking (and rewording) to trigger based on
BR2_STATIC_LIBS instead, thanks.

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-05-12 14:17 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-11 20:55 [Buildroot] [PATCH] libmemcached: don't use -fPIE and -pie with FLAT binaries Thomas Petazzoni
2015-05-11 22:17 ` Romain Naour
2015-05-11 22:19 ` Peter Korsgaard
2015-05-12 11:26   ` Thomas Petazzoni
2015-05-12 12:20     ` Peter Korsgaard
2015-05-12 12:22       ` Thomas Petazzoni
2015-05-12 13:02         ` Peter Korsgaard
2015-05-12 14:17 ` Peter Korsgaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox