* [Buildroot] [PATCH 0/2] package/directfb,sdl: fix static link
@ 2017-02-23 21:29 Yann E. MORIN
2017-02-23 21:29 ` [Buildroot] [PATCH 1/2] package/directfb: hack .pc file for " Yann E. MORIN
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Yann E. MORIN @ 2017-02-23 21:29 UTC (permalink / raw)
To: buildroot
Hello All!
This series fix (works around) static linking to SDL+DirectFB, by
hacking the corresponding .pc files:
- include -lstdc++ to DirectFB's Libs.Private
- include 'directfb' to SDL's Requires
Regards,
Yann E. MORIN.
The following changes since commit c8b2bd81a1a5401c10287f2d5c6c8b4a14994764
trousers: update ARC comment (2017-02-23 22:08:39 +0100)
are available in the git repository at:
git://git.buildroot.org/~ymorin/git/buildroot.git
for you to fetch changes up to 3817238a2bff47662b0f46d309fd2d12b31da877
package/sdl: fix .pc file (2017-02-23 22:21:16 +0100)
----------------------------------------------------------------
Yann E. MORIN (2):
package/directfb: hack .pc file for static link
package/sdl: fix .pc file
package/directfb/directfb.mk | 6 ++++++
package/sdl/sdl.mk | 5 +++++
2 files changed, 11 insertions(+)
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Buildroot] [PATCH 1/2] package/directfb: hack .pc file for static link
2017-02-23 21:29 [Buildroot] [PATCH 0/2] package/directfb,sdl: fix static link Yann E. MORIN
@ 2017-02-23 21:29 ` Yann E. MORIN
2017-02-23 21:29 ` [Buildroot] [PATCH 2/2] package/sdl: fix .pc file Yann E. MORIN
2017-02-23 21:50 ` [Buildroot] [PATCH 0/2] package/directfb,sdl: fix static link Thomas Petazzoni
2 siblings, 0 replies; 4+ messages in thread
From: Yann E. MORIN @ 2017-02-23 21:29 UTC (permalink / raw)
To: buildroot
DirectFB is written in C++, but can be linked to by a C library or
program.
When doing shared link, this is fine because the linker gets help from
the DT_NEEDED flags and nows what libraries to pull in during the link.
However, during a static link, the linker does not get such help. So
pkg-config was invented to compensate for that deficiency, whereby a
library would define its dependencies in a .pc file.
Alas, the .pc file for DirectFB does not define that it requires
libstdc++, for the good reason that there is provision in pkg-config to
properly cover this case. See this thread:
https://lists.freedesktop.org/archives/pkg-config/2016-August/001053.html
So, we hack our way around this issue by appending -lstdc++ to the
Libs.Private field in directfb.pc. This is but a hack; as per the thread
above, this is perfectly acceptable given the conditions...
Step 1 at fixing:
http://autobuild.buildroot.org/results/3d3/3d3036d40ddad71d872d910aae7a24975706d2e9/
http://autobuild.buildroot.org/results/d1c/d1c35a6003396942b584f2f2a5e8bf4ac2fbe370/
http://autobuild.buildroot.org/results/d45/d4504871bd47930e8363032d380cdfcc5bb8aee7/
[...]
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
package/directfb/directfb.mk | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/package/directfb/directfb.mk b/package/directfb/directfb.mk
index 595d590..47cbf4e 100644
--- a/package/directfb/directfb.mk
+++ b/package/directfb/directfb.mk
@@ -166,6 +166,12 @@ HOST_DIRECTFB_BUILD_CMDS = \
HOST_DIRECTFB_INSTALL_CMDS = \
$(INSTALL) -m 0755 $(@D)/tools/directfb-csource $(HOST_DIR)/usr/bin
+define DIRECTFB_FIX_PC
+ $(SED) 's/^\(Libs.private:.*\)$$/\1 -lstdc++/' \
+ $(STAGING_DIR)/usr/lib/pkgconfig/direct.pc
+endef
+DIRECTFB_POST_INSTALL_STAGING_HOOKS += DIRECTFB_FIX_PC
+
$(eval $(autotools-package))
$(eval $(host-autotools-package))
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Buildroot] [PATCH 2/2] package/sdl: fix .pc file
2017-02-23 21:29 [Buildroot] [PATCH 0/2] package/directfb,sdl: fix static link Yann E. MORIN
2017-02-23 21:29 ` [Buildroot] [PATCH 1/2] package/directfb: hack .pc file for " Yann E. MORIN
@ 2017-02-23 21:29 ` Yann E. MORIN
2017-02-23 21:50 ` [Buildroot] [PATCH 0/2] package/directfb,sdl: fix static link Thomas Petazzoni
2 siblings, 0 replies; 4+ messages in thread
From: Yann E. MORIN @ 2017-02-23 21:29 UTC (permalink / raw)
To: buildroot
When DirectFB is enabled, SDL is linked with it, and states so by adding
the necessary libs to its Libs.Private section in sdl.pc. In doing so
this way, SDL misses a critical library from DirectFB: those in
DirectFB'sown Libs.Private field, which recently got expanded with
-lstdc++
And indeed, the correct way to depend on anothe library that provides a
.pc file is to list it in the Requires field.
Add a post-staging install hook that does so.
We leave the Libs.Private field untouched, beause filtering out the libs
from DirectFB is not trivial. It also does not impact the build: the
libs would be listed twice, which although incorrect in theory, is not a
problem in practice.
Step 2 at fixing:
http://autobuild.buildroot.org/results/3d3/3d3036d40ddad71d872d910aae7a24975706d2e9/
http://autobuild.buildroot.org/results/d1c/d1c35a6003396942b584f2f2a5e8bf4ac2fbe370/
http://autobuild.buildroot.org/results/d45/d4504871bd47930e8363032d380cdfcc5bb8aee7/
[...]
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
package/sdl/sdl.mk | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/package/sdl/sdl.mk b/package/sdl/sdl.mk
index 38b4b97..9d8aa5d 100644
--- a/package/sdl/sdl.mk
+++ b/package/sdl/sdl.mk
@@ -33,6 +33,11 @@ ifeq ($(BR2_PACKAGE_SDL_DIRECTFB),y)
SDL_DEPENDENCIES += directfb
SDL_CONF_OPTS += --enable-video-directfb=yes
SDL_CONF_ENV = ac_cv_path_DIRECTFBCONFIG=$(STAGING_DIR)/usr/bin/directfb-config
+define SDL_FIX_PC
+ $(SED) 's/^\(Requires:.*\)$$/\1 directfb/' \
+ $(STAGING_DIR)/usr/lib/pkgconfig/sdl.pc
+endef
+SDL_POST_INSTALL_STAGING_HOOKS += SDL_FIX_PC
else
SDL_CONF_OPTS += --enable-video-directfb=no
endif
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Buildroot] [PATCH 0/2] package/directfb,sdl: fix static link
2017-02-23 21:29 [Buildroot] [PATCH 0/2] package/directfb,sdl: fix static link Yann E. MORIN
2017-02-23 21:29 ` [Buildroot] [PATCH 1/2] package/directfb: hack .pc file for " Yann E. MORIN
2017-02-23 21:29 ` [Buildroot] [PATCH 2/2] package/sdl: fix .pc file Yann E. MORIN
@ 2017-02-23 21:50 ` Thomas Petazzoni
2 siblings, 0 replies; 4+ messages in thread
From: Thomas Petazzoni @ 2017-02-23 21:50 UTC (permalink / raw)
To: buildroot
Hello,
On Thu, 23 Feb 2017 22:29:19 +0100, Yann E. MORIN wrote:
> Yann E. MORIN (2):
> package/directfb: hack .pc file for static link
> package/sdl: fix .pc file
Thanks for working on this. However, can we instead patch the directfb
and sdl build system?
For example, the SDL build system should not add -ldirect to Libs: if
DirectFB was detected with pkg-config, it should add it to the
Requires: line.
For DirectFB, I think libstdc++ could be unconditionally added to
directfb.pc.in.
*But*: let's take a step back. Do we really care about using DirectFB
in static-only scenarios ? If only DirectFB and SDL were active
upstream projects, there would be some incentive to fix this problem
properly. But really, there is no such incentive. So what about making
DirectFB depend on !BR2_STATIC_LIBS instead, and be done with it ?
Nowhere in Buildroot we "select BR2_PACKAGE_DIRECTFB", which means it's
really a simple change to do, as we don't need to propagate this
dependency to any reverse dependency.
Best regards,
Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-02-23 21:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-23 21:29 [Buildroot] [PATCH 0/2] package/directfb,sdl: fix static link Yann E. MORIN
2017-02-23 21:29 ` [Buildroot] [PATCH 1/2] package/directfb: hack .pc file for " Yann E. MORIN
2017-02-23 21:29 ` [Buildroot] [PATCH 2/2] package/sdl: fix .pc file Yann E. MORIN
2017-02-23 21:50 ` [Buildroot] [PATCH 0/2] package/directfb,sdl: fix static link Thomas Petazzoni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox