Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 1/1] package/libdcadec: Add -fPIC to static build, enable shared build
Date: Sun, 18 Oct 2015 22:02:01 +0200	[thread overview]
Message-ID: <20151018220201.077078ae@free-electrons.com> (raw)
In-Reply-To: <CAHXCMMLUFrW7TRn9qQDZE2PUBXUyZbCT8pKe8fP5B4TYZv75-A@mail.gmail.com>

Hello,

On Sun, 18 Oct 2015 21:52:38 +0200, Samuel Martin wrote:

> > None of these configurations have BR2_STATIC_LIBS=y, so I fail to see
> > why adding -fPIC when BR2_STATIC_LIBS=y would fix those issues.
> >
> > Moreover, using -fPIC for statically linked configurations generally
> > doesn't make sense: the point of PIC code is to be Position
> > Independent, which is needed for shared libraries. But not for
> > statically linked programs.
> 
> AFAI understand these build failures, the problem comes from the
> static library libdcadec.a that is unconditionnally built.
> When the config has BR2_SHARED_LIBS=y, this static library got built
> without -fPIC, then is used by ffmpeg to be linked against for some
> shared objects libraries (e.g. libavcodec.so). That's right here that
> error occurs.

This, I'm OK with.

> >> The upstream Makefile also allows building a shared library if
> >> CONFIG_SHARED=1 is added to _BUILD_CMDS.
> >
> > This probably fixes the problem however.
> 
> To fix this the options are:
> 1) build libdcadec as a shared library, if it is supported;
> 2) or, add -fPIC when BR2_SHARED_LIBS=y;
> 3) or, unconditionally add -fPIC.
> 
> My preference is option 1).

Obviously, (1) is the right solution here.

> > So, can you explain the addition of -fPIC for BR2_STATIC_LIBS=y
> > configurations?
> 
> IIRC, -fPIC on static libs does not have any harmful consequences,
> only a slight overhead at some point due to some indirection.

Correct. But it doesn't make sense to explicitly add -fPIC when
BR2_STATIC_LIBS=y.

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

      reply	other threads:[~2015-10-18 20:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-18 16:08 [Buildroot] [PATCH 1/1] package/libdcadec: Add -fPIC to static build, enable shared build Bernd Kuhls
2015-10-18 19:05 ` Thomas Petazzoni
2015-10-18 19:52   ` Samuel Martin
2015-10-18 20:02     ` Thomas Petazzoni [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151018220201.077078ae@free-electrons.com \
    --to=thomas.petazzoni@free-electrons.com \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox