All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] ffmpeg: fix static linking build failure when using libavutil
@ 2018-09-11 20:42 Giulio Benetti
  2018-09-11 21:47 ` Giulio Benetti
  2018-09-16 20:22 ` Thomas Petazzoni
  0 siblings, 2 replies; 15+ messages in thread
From: Giulio Benetti @ 2018-09-11 20:42 UTC (permalink / raw)
  To: buildroot

When static linking programs using ffmpeg libraries, if linking against
libavutil, -ldrm is listed before -lavutil. This leads to linking failure
due to undefined reference of drmGetVersion() and drmFreeVersion().
This is why when pkg-config generates libavutil.pc doesn't append -ldrm
after -lavutil.
Subsequentely if a package uses pkg-config and ffmpeg it will load
library dependencies from libavutil.pc without placing -ldrm at the tail.
Without this fix the only way is to workaround the problem directly in
the single package, like this:
https://github.com/buildroot/buildroot/commit/daf7dd87f4d93923df5e757fd43b3ad214a4a2ae

Add patch to assure -ldrm comes after -lavutil when static linking.

Fixes:
http://autobuild.buildroot.net/results/515/5152dcca58944cf732d09fba6e6c9af8a9243c75//
http://autobuild.buildroot.net/results/395/395be1a9cab824b82ef34c2ebd84d54243029b33//

Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
---
 ...igure-add-LIBDRM-to-extralibs_avutil.patch | 44 +++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100644 package/ffmpeg/0002-configure-add-LIBDRM-to-extralibs_avutil.patch

diff --git a/package/ffmpeg/0002-configure-add-LIBDRM-to-extralibs_avutil.patch b/package/ffmpeg/0002-configure-add-LIBDRM-to-extralibs_avutil.patch
new file mode 100644
index 0000000000..ae1f3423ae
--- /dev/null
+++ b/package/ffmpeg/0002-configure-add-LIBDRM-to-extralibs_avutil.patch
@@ -0,0 +1,44 @@
+From f4c9a7f55229d5275edb89c29ac9b18a737faf65 Mon Sep 17 00:00:00 2001
+From: Giulio Benetti <giulio.benetti@micronovasrl.com>
+Date: Tue, 11 Sep 2018 19:22:27 +0200
+Subject: [PATCH] configure: add LIBDRM to extralibs_avutil
+
+When static linking programs using ffmpeg libraries, if linking against
+libavutil, -ldrm is listed before -lavutil. This leads to linking failure
+due to undefined reference of drmGetVersion() and drmFreeVersion().
+This is why when pkg-config create libavutil.pc doesn't append -ldrm
+after -lavutil.
+
+Add -ldrm to LIBDRM in case libdrm is enabled and add $LIBDRM to
+extralibs_avutil.
+
+Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
+---
+ configure | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure b/configure
+index 7377046d0a..7599fcc2bd 100755
+--- a/configure
++++ b/configure
+@@ -5919,7 +5919,7 @@ enabled libcelt           && require libcelt celt/celt.h celt_decode -lcelt0 &&
+                                die "ERROR: libcelt must be installed and version must be >= 0.11.0."; }
+ enabled libcaca           && require_pkg_config libcaca caca caca.h caca_create_canvas
+ enabled libdc1394         && require_pkg_config libdc1394 libdc1394-2 dc1394/dc1394.h dc1394_new
+-enabled libdrm            && require_pkg_config libdrm libdrm xf86drm.h drmGetVersion
++enabled libdrm            && require_pkg_config libdrm libdrm xf86drm.h drmGetVersion && LIBDRM="-ldrm"
+ enabled libfdk_aac        && { use_pkg_config libfdk_aac fdk-aac "fdk-aac/aacenc_lib.h" aacEncOpen ||
+                                { require libfdk_aac fdk-aac/aacenc_lib.h aacEncOpen -lfdk-aac &&
+                                  warn "using libfdk without pkg-config"; } }
+@@ -7096,7 +7096,7 @@ source_path=${source_path}
+ LIBPREF=${LIBPREF}
+ LIBSUF=${LIBSUF}
+ 
+-extralibs_avutil="$LIBRT $LIBM"
++extralibs_avutil="$LIBDRM $LIBRT $LIBM"
+ extralibs_avcodec="$extralibs"
+ extralibs_avformat="$extralibs"
+ extralibs_avdevice="$extralibs"
+-- 
+2.17.1
+
-- 
2.17.1

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

* [Buildroot] [PATCH] ffmpeg: fix static linking build failure when using libavutil
  2018-09-11 20:42 [Buildroot] [PATCH] ffmpeg: fix static linking build failure when using libavutil Giulio Benetti
@ 2018-09-11 21:47 ` Giulio Benetti
  2018-09-13  8:15   ` Giulio Benetti
  2018-09-16 20:22 ` Thomas Petazzoni
  1 sibling, 1 reply; 15+ messages in thread
From: Giulio Benetti @ 2018-09-11 21:47 UTC (permalink / raw)
  To: buildroot

Hello,

Il 11/09/2018 22:42, Giulio Benetti ha scritto:
> When static linking programs using ffmpeg libraries, if linking against
> libavutil, -ldrm is listed before -lavutil. This leads to linking failure
> due to undefined reference of drmGetVersion() and drmFreeVersion().
> This is why when pkg-config generates libavutil.pc doesn't append -ldrm
> after -lavutil.
> Subsequentely if a package uses pkg-config and ffmpeg it will load
> library dependencies from libavutil.pc without placing -ldrm at the tail.
> Without this fix the only way is to workaround the problem directly in
> the single package, like this:
> https://github.com/buildroot/buildroot/commit/daf7dd87f4d93923df5e757fd43b3ad214a4a2ae
> 
> Add patch to assure -ldrm comes after -lavutil when static linking.
> 
> Fixes:
> http://autobuild.buildroot.net/results/515/5152dcca58944cf732d09fba6e6c9af8a9243c75//
> http://autobuild.buildroot.net/results/395/395be1a9cab824b82ef34c2ebd84d54243029b33//
> 
> Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
> ---
>   ...igure-add-LIBDRM-to-extralibs_avutil.patch | 44 +++++++++++++++++++
>   1 file changed, 44 insertions(+)
>   create mode 100644 package/ffmpeg/0002-configure-add-LIBDRM-to-extralibs_avutil.patch
> 
> diff --git a/package/ffmpeg/0002-configure-add-LIBDRM-to-extralibs_avutil.patch b/package/ffmpeg/0002-configure-add-LIBDRM-to-extralibs_avutil.patch
> new file mode 100644
> index 0000000000..ae1f3423ae
> --- /dev/null
> +++ b/package/ffmpeg/0002-configure-add-LIBDRM-to-extralibs_avutil.patch
> @@ -0,0 +1,44 @@
> +From f4c9a7f55229d5275edb89c29ac9b18a737faf65 Mon Sep 17 00:00:00 2001
> +From: Giulio Benetti <giulio.benetti@micronovasrl.com>
> +Date: Tue, 11 Sep 2018 19:22:27 +0200
> +Subject: [PATCH] configure: add LIBDRM to extralibs_avutil
> +
> +When static linking programs using ffmpeg libraries, if linking against
> +libavutil, -ldrm is listed before -lavutil. This leads to linking failure
> +due to undefined reference of drmGetVersion() and drmFreeVersion().
> +This is why when pkg-config create libavutil.pc doesn't append -ldrm
> +after -lavutil.
> +
> +Add -ldrm to LIBDRM in case libdrm is enabled and add $LIBDRM to
> +extralibs_avutil.
> +
> +Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
> +---
> + configure | 4 ++--
> + 1 file changed, 2 insertions(+), 2 deletions(-)
> +
> +diff --git a/configure b/configure
> +index 7377046d0a..7599fcc2bd 100755
> +--- a/configure
> ++++ b/configure
> +@@ -5919,7 +5919,7 @@ enabled libcelt           && require libcelt celt/celt.h celt_decode -lcelt0 &&
> +                                die "ERROR: libcelt must be installed and version must be >= 0.11.0."; }
> + enabled libcaca           && require_pkg_config libcaca caca caca.h caca_create_canvas
> + enabled libdc1394         && require_pkg_config libdc1394 libdc1394-2 dc1394/dc1394.h dc1394_new
> +-enabled libdrm            && require_pkg_config libdrm libdrm xf86drm.h drmGetVersion
> ++enabled libdrm            && require_pkg_config libdrm libdrm xf86drm.h drmGetVersion && LIBDRM="-ldrm"
> + enabled libfdk_aac        && { use_pkg_config libfdk_aac fdk-aac "fdk-aac/aacenc_lib.h" aacEncOpen ||
> +                                { require libfdk_aac fdk-aac/aacenc_lib.h aacEncOpen -lfdk-aac &&
> +                                  warn "using libfdk without pkg-config"; } }
> +@@ -7096,7 +7096,7 @@ source_path=${source_path}
> + LIBPREF=${LIBPREF}
> + LIBSUF=${LIBSUF}
> +
> +-extralibs_avutil="$LIBRT $LIBM"
> ++extralibs_avutil="$LIBDRM $LIBRT $LIBM"
> + extralibs_avcodec="$extralibs"
> + extralibs_avformat="$extralibs"
> + extralibs_avdevice="$extralibs"
> +--
> +2.17.1
> +
> 

The patch above has been upstreamed:
https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/c50dc77ac708e98d02da7c422a6b9cbf9f565aa5

-- 
Giulio Benetti
CTO

MICRONOVA SRL
Sede: Via A. Niedda 3 - 35010 Vigonza (PD)
Tel. 049/8931563 - Fax 049/8931346
Cod.Fiscale - P.IVA 02663420285
Capitale Sociale ? 26.000 i.v.
Iscritta al Reg. Imprese di Padova N. 02663420285
Numero R.E.A. 258642

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

* [Buildroot] [PATCH] ffmpeg: fix static linking build failure when using libavutil
  2018-09-11 21:47 ` Giulio Benetti
@ 2018-09-13  8:15   ` Giulio Benetti
  0 siblings, 0 replies; 15+ messages in thread
From: Giulio Benetti @ 2018-09-13  8:15 UTC (permalink / raw)
  To: buildroot

Il 11/09/2018 23:47, Giulio Benetti ha scritto:
> Hello,
> 
> Il 11/09/2018 22:42, Giulio Benetti ha scritto:
>> When static linking programs using ffmpeg libraries, if linking against
>> libavutil, -ldrm is listed before -lavutil. This leads to linking failure
>> due to undefined reference of drmGetVersion() and drmFreeVersion().
>> This is why when pkg-config generates libavutil.pc doesn't append -ldrm
>> after -lavutil.
>> Subsequentely if a package uses pkg-config and ffmpeg it will load
>> library dependencies from libavutil.pc without placing -ldrm at the tail.
>> Without this fix the only way is to workaround the problem directly in
>> the single package, like this:
>> https://github.com/buildroot/buildroot/commit/daf7dd87f4d93923df5e757fd43b3ad214a4a2ae 
>>
>>
>> Add patch to assure -ldrm comes after -lavutil when static linking.
>>
>> Fixes:
>> http://autobuild.buildroot.net/results/515/5152dcca58944cf732d09fba6e6c9af8a9243c75// 
>>
>> http://autobuild.buildroot.net/results/395/395be1a9cab824b82ef34c2ebd84d54243029b33// 
>>
>>
>> Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
>> ---
>> ? ...igure-add-LIBDRM-to-extralibs_avutil.patch | 44 +++++++++++++++++++
>> ? 1 file changed, 44 insertions(+)
>> ? create mode 100644 
>> package/ffmpeg/0002-configure-add-LIBDRM-to-extralibs_avutil.patch
>>
>> diff --git 
>> a/package/ffmpeg/0002-configure-add-LIBDRM-to-extralibs_avutil.patch 
>> b/package/ffmpeg/0002-configure-add-LIBDRM-to-extralibs_avutil.patch
>> new file mode 100644
>> index 0000000000..ae1f3423ae
>> --- /dev/null
>> +++ b/package/ffmpeg/0002-configure-add-LIBDRM-to-extralibs_avutil.patch
>> @@ -0,0 +1,44 @@
>> +From f4c9a7f55229d5275edb89c29ac9b18a737faf65 Mon Sep 17 00:00:00 2001
>> +From: Giulio Benetti <giulio.benetti@micronovasrl.com>
>> +Date: Tue, 11 Sep 2018 19:22:27 +0200
>> +Subject: [PATCH] configure: add LIBDRM to extralibs_avutil
>> +
>> +When static linking programs using ffmpeg libraries, if linking against
>> +libavutil, -ldrm is listed before -lavutil. This leads to linking 
>> failure
>> +due to undefined reference of drmGetVersion() and drmFreeVersion().
>> +This is why when pkg-config create libavutil.pc doesn't append -ldrm
>> +after -lavutil.
>> +
>> +Add -ldrm to LIBDRM in case libdrm is enabled and add $LIBDRM to
>> +extralibs_avutil.
>> +
>> +Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
>> +---
>> + configure | 4 ++--
>> + 1 file changed, 2 insertions(+), 2 deletions(-)
>> +
>> +diff --git a/configure b/configure
>> +index 7377046d0a..7599fcc2bd 100755
>> +--- a/configure
>> ++++ b/configure
>> +@@ -5919,7 +5919,7 @@ enabled libcelt?????????? && require libcelt 
>> celt/celt.h celt_decode -lcelt0 &&
>> +??????????????????????????????? die "ERROR: libcelt must be installed 
>> and version must be >= 0.11.0."; }
>> + enabled libcaca?????????? && require_pkg_config libcaca caca caca.h 
>> caca_create_canvas
>> + enabled libdc1394???????? && require_pkg_config libdc1394 
>> libdc1394-2 dc1394/dc1394.h dc1394_new
>> +-enabled libdrm??????????? && require_pkg_config libdrm libdrm 
>> xf86drm.h drmGetVersion
>> ++enabled libdrm??????????? && require_pkg_config libdrm libdrm 
>> xf86drm.h drmGetVersion && LIBDRM="-ldrm"
>> + enabled libfdk_aac??????? && { use_pkg_config libfdk_aac fdk-aac 
>> "fdk-aac/aacenc_lib.h" aacEncOpen ||
>> +??????????????????????????????? { require libfdk_aac 
>> fdk-aac/aacenc_lib.h aacEncOpen -lfdk-aac &&
>> +????????????????????????????????? warn "using libfdk without 
>> pkg-config"; } }
>> +@@ -7096,7 +7096,7 @@ source_path=${source_path}
>> + LIBPREF=${LIBPREF}
>> + LIBSUF=${LIBSUF}
>> +
>> +-extralibs_avutil="$LIBRT $LIBM"
>> ++extralibs_avutil="$LIBDRM $LIBRT $LIBM"
>> + extralibs_avcodec="$extralibs"
>> + extralibs_avformat="$extralibs"
>> + extralibs_avdevice="$extralibs"
>> +--
>> +2.17.1
>> +
>>
> 
> The patch above has been upstreamed:
> https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/c50dc77ac708e98d02da7c422a6b9cbf9f565aa5 
> 
> 

For completeness I point that the "Fixes:" are for "Motion" package.

Best regards
-- 
Giulio Benetti
CTO

MICRONOVA SRL
Sede: Via A. Niedda 3 - 35010 Vigonza (PD)
Tel. 049/8931563 - Fax 049/8931346
Cod.Fiscale - P.IVA 02663420285
Capitale Sociale ? 26.000 i.v.
Iscritta al Reg. Imprese di Padova N. 02663420285
Numero R.E.A. 258642

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

* [Buildroot] [PATCH] ffmpeg: fix static linking build failure when using libavutil
  2018-09-11 20:42 [Buildroot] [PATCH] ffmpeg: fix static linking build failure when using libavutil Giulio Benetti
  2018-09-11 21:47 ` Giulio Benetti
@ 2018-09-16 20:22 ` Thomas Petazzoni
  2018-09-24 10:26   ` Giulio Benetti
  1 sibling, 1 reply; 15+ messages in thread
From: Thomas Petazzoni @ 2018-09-16 20:22 UTC (permalink / raw)
  To: buildroot

Hello Giulio,

On Tue, 11 Sep 2018 22:42:30 +0200, Giulio Benetti wrote:
> When static linking programs using ffmpeg libraries, if linking against
> libavutil, -ldrm is listed before -lavutil.

I think this is not relevant in the explanation, the fact that motion
links with libdrm directly is independent from the fact that ffmpeg may
use libdrm internally.

> This leads to linking failure
> due to undefined reference of drmGetVersion() and drmFreeVersion().
> This is why when pkg-config generates libavutil.pc doesn't append -ldrm

pkg-config does not generate .pc files, it only reads them.

> after -lavutil.
> Subsequentely if a package uses pkg-config and ffmpeg it will load
> library dependencies from libavutil.pc without placing -ldrm at the tail.

Well, the fact that it's at the tail is a detail, but the main problem
is that the libavutil.pc file does not list *at all* the dependency on
libdrm.

> Without this fix the only way is to workaround the problem directly in
> the single package, like this:

"the single package" is not very clear, I would say "in each package
using ffmpeg".

> https://github.com/buildroot/buildroot/commit/daf7dd87f4d93923df5e757fd43b3ad214a4a2ae
> 
> Add patch to assure -ldrm comes after -lavutil when static linking.

No, that's not what the patch does. The patch ensures that libavutil.pc
tells pkg-config that linking against libdrm is needed.


> ++enabled libdrm            && require_pkg_config libdrm libdrm xf86drm.h drmGetVersion && LIBDRM="-ldrm"
> + enabled libfdk_aac        && { use_pkg_config libfdk_aac fdk-aac "fdk-aac/aacenc_lib.h" aacEncOpen ||
> +                                { require libfdk_aac fdk-aac/aacenc_lib.h aacEncOpen -lfdk-aac &&
> +                                  warn "using libfdk without pkg-config"; } }
> +@@ -7096,7 +7096,7 @@ source_path=${source_path}
> + LIBPREF=${LIBPREF}
> + LIBSUF=${LIBSUF}
> + 
> +-extralibs_avutil="$LIBRT $LIBM"
> ++extralibs_avutil="$LIBDRM $LIBRT $LIBM"

This fix is in fact not the most correct one. Indeed, it does the
following change to libavutil.pc:

-Libs: -L${libdir}  -lavutil -lm
+Libs: -L${libdir}  -lavutil -ldrm -lm

but the proper change would be:

 Libs: -L${libdir}  -lavutil -lm
-Libs.private:
+Libs.private: -ldrm

Indeed, when we're dynamic linking, there is no need to link consumers
of libavutil with libdrm. It is only when we're statically linking that
it should be done. And that's exactly what Libs vs. Libs.private is for.

Best regards,

Thomas Petazzoni
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

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

* [Buildroot] [PATCH] ffmpeg: fix static linking build failure when using libavutil
  2018-09-16 20:22 ` Thomas Petazzoni
@ 2018-09-24 10:26   ` Giulio Benetti
  2018-09-24 11:09     ` Thomas Petazzoni
  0 siblings, 1 reply; 15+ messages in thread
From: Giulio Benetti @ 2018-09-24 10:26 UTC (permalink / raw)
  To: buildroot

Hello Thomas,

Il 16/09/2018 22:22, Thomas Petazzoni ha scritto:
> Hello Giulio,
> 
> On Tue, 11 Sep 2018 22:42:30 +0200, Giulio Benetti wrote:
>> When static linking programs using ffmpeg libraries, if linking against
>> libavutil, -ldrm is listed before -lavutil.
> 
> I think this is not relevant in the explanation, the fact that motion
> links with libdrm directly is independent from the fact that ffmpeg may
> use libdrm internally.
> 
>> This leads to linking failure
>> due to undefined reference of drmGetVersion() and drmFreeVersion().
>> This is why when pkg-config generates libavutil.pc doesn't append -ldrm
> 
> pkg-config does not generate .pc files, it only reads them.
> 
>> after -lavutil.
>> Subsequentely if a package uses pkg-config and ffmpeg it will load
>> library dependencies from libavutil.pc without placing -ldrm at the tail.
> 
> Well, the fact that it's at the tail is a detail, but the main problem
> is that the libavutil.pc file does not list *at all* the dependency on
> libdrm.
> 
>> Without this fix the only way is to workaround the problem directly in
>> the single package, like this:
> 
> "the single package" is not very clear, I would say "in each package
> using ffmpeg".
> 
>> https://github.com/buildroot/buildroot/commit/daf7dd87f4d93923df5e757fd43b3ad214a4a2ae
>>
>> Add patch to assure -ldrm comes after -lavutil when static linking.
> 
> No, that's not what the patch does. The patch ensures that libavutil.pc
> tells pkg-config that linking against libdrm is needed.
> 
> 
>> ++enabled libdrm            && require_pkg_config libdrm libdrm xf86drm.h drmGetVersion && LIBDRM="-ldrm"
>> + enabled libfdk_aac        && { use_pkg_config libfdk_aac fdk-aac "fdk-aac/aacenc_lib.h" aacEncOpen ||
>> +                                { require libfdk_aac fdk-aac/aacenc_lib.h aacEncOpen -lfdk-aac &&
>> +                                  warn "using libfdk without pkg-config"; } }
>> +@@ -7096,7 +7096,7 @@ source_path=${source_path}
>> + LIBPREF=${LIBPREF}
>> + LIBSUF=${LIBSUF}
>> +
>> +-extralibs_avutil="$LIBRT $LIBM"
>> ++extralibs_avutil="$LIBDRM $LIBRT $LIBM"
> 
> This fix is in fact not the most correct one. Indeed, it does the
> following change to libavutil.pc:
> 
> -Libs: -L${libdir}  -lavutil -lm
> +Libs: -L${libdir}  -lavutil -ldrm -lm
> 
> but the proper change would be:
> 
>   Libs: -L${libdir}  -lavutil -lm
> -Libs.private:
> +Libs.private: -ldrm
> 
> Indeed, when we're dynamic linking, there is no need to link consumers
> of libavutil with libdrm. It is only when we're statically linking that
> it should be done. And that's exactly what Libs vs. Libs.private is for.

You've explained me it very well, but by now FFmpeg upstreamed my patch:
https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/c50dc77ac708e98d02da7c422a6b9cbf9f565aa5

So, do I rework and resubmit to them or can I re-create a patch for BR
with what you've pointed me above?

Thanks
Kind regards
-- 
Giulio Benetti
CTO

MICRONOVA SRL
Sede: Via A. Niedda 3 - 35010 Vigonza (PD)
Tel. 049/8931563 - Fax 049/8931346
Cod.Fiscale - P.IVA 02663420285
Capitale Sociale ? 26.000 i.v.
Iscritta al Reg. Imprese di Padova N. 02663420285
Numero R.E.A. 258642

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

* [Buildroot] [PATCH] ffmpeg: fix static linking build failure when using libavutil
  2018-09-24 10:26   ` Giulio Benetti
@ 2018-09-24 11:09     ` Thomas Petazzoni
  2018-09-24 11:11       ` Giulio Benetti
  0 siblings, 1 reply; 15+ messages in thread
From: Thomas Petazzoni @ 2018-09-24 11:09 UTC (permalink / raw)
  To: buildroot

Hello,

On Mon, 24 Sep 2018 12:26:05 +0200, Giulio Benetti wrote:

> > Indeed, when we're dynamic linking, there is no need to link consumers
> > of libavutil with libdrm. It is only when we're statically linking that
> > it should be done. And that's exactly what Libs vs. Libs.private is for.  
> 
> You've explained me it very well, but by now FFmpeg upstreamed my patch:
> https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/c50dc77ac708e98d02da7c422a6b9cbf9f565aa5
> 
> So, do I rework and resubmit to them or can I re-create a patch for BR
> with what you've pointed me above?

Both ? :-)

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

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

* [Buildroot] [PATCH] ffmpeg: fix static linking build failure when using libavutil
  2018-09-24 11:09     ` Thomas Petazzoni
@ 2018-09-24 11:11       ` Giulio Benetti
  2018-10-12 17:38         ` Giulio Benetti
  0 siblings, 1 reply; 15+ messages in thread
From: Giulio Benetti @ 2018-09-24 11:11 UTC (permalink / raw)
  To: buildroot

Il 24/09/2018 13:09, Thomas Petazzoni ha scritto:
> Hello,
> 
> On Mon, 24 Sep 2018 12:26:05 +0200, Giulio Benetti wrote:
> 
>>> Indeed, when we're dynamic linking, there is no need to link consumers
>>> of libavutil with libdrm. It is only when we're statically linking that
>>> it should be done. And that's exactly what Libs vs. Libs.private is for.
>>
>> You've explained me it very well, but by now FFmpeg upstreamed my patch:
>> https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/c50dc77ac708e98d02da7c422a6b9cbf9f565aa5
>>
>> So, do I rework and resubmit to them or can I re-create a patch for BR
>> with what you've pointed me above?
> 
> Both ? :-)

Ok!

-- 
Giulio Benetti
CTO

MICRONOVA SRL
Sede: Via A. Niedda 3 - 35010 Vigonza (PD)
Tel. 049/8931563 - Fax 049/8931346
Cod.Fiscale - P.IVA 02663420285
Capitale Sociale ? 26.000 i.v.
Iscritta al Reg. Imprese di Padova N. 02663420285
Numero R.E.A. 258642

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

* [Buildroot] [PATCH] ffmpeg: fix static linking build failure when using libavutil
  2018-09-24 11:11       ` Giulio Benetti
@ 2018-10-12 17:38         ` Giulio Benetti
  2018-10-12 19:50           ` Thomas Petazzoni
  0 siblings, 1 reply; 15+ messages in thread
From: Giulio Benetti @ 2018-10-12 17:38 UTC (permalink / raw)
  To: buildroot

Hello Thomas,

Il 24/09/2018 13:11, Giulio Benetti ha scritto:
> Il 24/09/2018 13:09, Thomas Petazzoni ha scritto:
>> Hello,
>>
>> On Mon, 24 Sep 2018 12:26:05 +0200, Giulio Benetti wrote:
>>
>>>> Indeed, when we're dynamic linking, there is no need to link consumers
>>>> of libavutil with libdrm. It is only when we're statically linking that
>>>> it should be done. And that's exactly what Libs vs. Libs.private is for.
>>>
>>> You've explained me it very well, but by now FFmpeg upstreamed my patch:
>>> https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/c50dc77ac708e98d02da7c422a6b9cbf9f565aa5
>>>
>>> So, do I rework and resubmit to them or can I re-create a patch for BR
>>> with what you've pointed me above?
I've missed one thing to ask you about ffmpeg:
Can I still use this hack:
https://git.ffmpeg.org/gitweb/ffmpeg.git/blobdiff/bc2301429e9c779237e43acf913331af018211f2..c50dc77ac708e98d02da7c422a6b9cbf9f565aa5:/configure

to obtain if -ldrm is used and then add it to Libs.private like this:
Libs.private: -ldrm

as you've pointed me.

Or there is something that makes it simpler and better?

Thanks in advance
Best regards
-- 
Giulio Benetti
CTO

MICRONOVA SRL
Sede: Via A. Niedda 3 - 35010 Vigonza (PD)
Tel. 049/8931563 - Fax 049/8931346
Cod.Fiscale - P.IVA 02663420285
Capitale Sociale ? 26.000 i.v.
Iscritta al Reg. Imprese di Padova N. 02663420285
Numero R.E.A. 258642

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

* [Buildroot] [PATCH] ffmpeg: fix static linking build failure when using libavutil
  2018-10-12 17:38         ` Giulio Benetti
@ 2018-10-12 19:50           ` Thomas Petazzoni
  2018-10-12 20:54             ` Giulio Benetti
  0 siblings, 1 reply; 15+ messages in thread
From: Thomas Petazzoni @ 2018-10-12 19:50 UTC (permalink / raw)
  To: buildroot

Hello,

On Fri, 12 Oct 2018 19:38:14 +0200, Giulio Benetti wrote:

> >>>> Indeed, when we're dynamic linking, there is no need to link consumers
> >>>> of libavutil with libdrm. It is only when we're statically linking that
> >>>> it should be done. And that's exactly what Libs vs. Libs.private is for.  
> >>>
> >>> You've explained me it very well, but by now FFmpeg upstreamed my patch:
> >>> https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/c50dc77ac708e98d02da7c422a6b9cbf9f565aa5
> >>>
> >>> So, do I rework and resubmit to them or can I re-create a patch for BR
> >>> with what you've pointed me above?  
> I've missed one thing to ask you about ffmpeg:
> Can I still use this hack:
> https://git.ffmpeg.org/gitweb/ffmpeg.git/blobdiff/bc2301429e9c779237e43acf913331af018211f2..c50dc77ac708e98d02da7c422a6b9cbf9f565aa5:/configure
> 
> to obtain if -ldrm is used and then add it to Libs.private like this:
> Libs.private: -ldrm
> 
> as you've pointed me.
> 
> Or there is something that makes it simpler and better?

I'm not sure what "hack" you're talking about here. My only point it is
only needed to link "indirect" libraries when static linking, and
therefore such "indirect" libraries should be listed in Libs.private
and not Libs in pkg-config files.

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

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

* [Buildroot] [PATCH] ffmpeg: fix static linking build failure when using libavutil
  2018-10-12 19:50           ` Thomas Petazzoni
@ 2018-10-12 20:54             ` Giulio Benetti
  2018-10-16 19:31               ` Giulio Benetti
  0 siblings, 1 reply; 15+ messages in thread
From: Giulio Benetti @ 2018-10-12 20:54 UTC (permalink / raw)
  To: buildroot

Hello,

Il 12/10/2018 21:50, Thomas Petazzoni ha scritto:
> Hello,
> 
> On Fri, 12 Oct 2018 19:38:14 +0200, Giulio Benetti wrote:
> 
>>>>>> Indeed, when we're dynamic linking, there is no need to link consumers
>>>>>> of libavutil with libdrm. It is only when we're statically linking that
>>>>>> it should be done. And that's exactly what Libs vs. Libs.private is for.
>>>>>
>>>>> You've explained me it very well, but by now FFmpeg upstreamed my patch:
>>>>> https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/c50dc77ac708e98d02da7c422a6b9cbf9f565aa5
>>>>>
>>>>> So, do I rework and resubmit to them or can I re-create a patch for BR
>>>>> with what you've pointed me above?
>> I've missed one thing to ask you about ffmpeg:
>> Can I still use this hack:
>> https://git.ffmpeg.org/gitweb/ffmpeg.git/blobdiff/bc2301429e9c779237e43acf913331af018211f2..c50dc77ac708e98d02da7c422a6b9cbf9f565aa5:/configure
>>
>> to obtain if -ldrm is used and then add it to Libs.private like this:
>> Libs.private: -ldrm
>>
>> as you've pointed me.
>>
>> Or there is something that makes it simpler and better?
> 
> I'm not sure what "hack" you're talking about here. My only point it is
> only needed to link "indirect" libraries when static linking, and
> therefore such "indirect" libraries should be listed in Libs.private
> and not Libs in pkg-config files.

Ok, sorry but I don't have much experience with Autotools and 
dynamic/static linking, I'm learning here "on the field".
I will try to submit a patch producing what you've described in the best 
way I can.

Best regards
-- 
Giulio Benetti
CTO

MICRONOVA SRL
Sede: Via A. Niedda 3 - 35010 Vigonza (PD)
Tel. 049/8931563 - Fax 049/8931346
Cod.Fiscale - P.IVA 02663420285
Capitale Sociale ? 26.000 i.v.
Iscritta al Reg. Imprese di Padova N. 02663420285
Numero R.E.A. 258642

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

* [Buildroot] [PATCH] ffmpeg: fix static linking build failure when using libavutil
  2018-10-12 20:54             ` Giulio Benetti
@ 2018-10-16 19:31               ` Giulio Benetti
  2018-10-17 10:36                 ` Giulio Benetti
  0 siblings, 1 reply; 15+ messages in thread
From: Giulio Benetti @ 2018-10-16 19:31 UTC (permalink / raw)
  To: buildroot

Hello Thomas,

Il 12/10/2018 22:54, Giulio Benetti ha scritto:
> Hello,
> 
> Il 12/10/2018 21:50, Thomas Petazzoni ha scritto:
>> Hello,
>>
>> On Fri, 12 Oct 2018 19:38:14 +0200, Giulio Benetti wrote:
>>
>>>>>>> Indeed, when we're dynamic linking, there is no need to link consumers
>>>>>>> of libavutil with libdrm. It is only when we're statically linking that
>>>>>>> it should be done. And that's exactly what Libs vs. Libs.private is for.
>>>>>>
>>>>>> You've explained me it very well, but by now FFmpeg upstreamed my patch:
>>>>>> https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/c50dc77ac708e98d02da7c422a6b9cbf9f565aa5
>>>>>>
>>>>>> So, do I rework and resubmit to them or can I re-create a patch for BR
>>>>>> with what you've pointed me above?
>>> I've missed one thing to ask you about ffmpeg:
>>> Can I still use this hack:
>>> https://git.ffmpeg.org/gitweb/ffmpeg.git/blobdiff/bc2301429e9c779237e43acf913331af018211f2..c50dc77ac708e98d02da7c422a6b9cbf9f565aa5:/configure
>>>
>>> to obtain if -ldrm is used and then add it to Libs.private like this:
>>> Libs.private: -ldrm
>>>
>>> as you've pointed me.
>>>
>>> Or there is something that makes it simpler and better?
>>
>> I'm not sure what "hack" you're talking about here. My only point it is
>> only needed to link "indirect" libraries when static linking, and
>> therefore such "indirect" libraries should be listed in Libs.private
>> and not Libs in pkg-config files.

I've worked this out, but I have a question:
Since FFMpeg upstreamed my previous wrong patch:
https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/c50dc77ac708e98d02da7c422a6b9cbf9f565aa5

now I would submit another patch to FFMpeg to correct Libs vs 
Libs.private problem.

Here is the new patch:
https://github.com/giuliobenetti/FFmpeg/commit/d682f418b7912b9d9e1818aefa61a51a2868fb20

So:
do I have to submit to Buildroot a patch containing both patches?
Or only one that merge both patches together even if it's not upstreamable?

Thanks in advance
Best regards
-- 
Giulio Benetti
CTO

MICRONOVA SRL
Sede: Via A. Niedda 3 - 35010 Vigonza (PD)
Tel. 049/8931563 - Fax 049/8931346
Cod.Fiscale - P.IVA 02663420285
Capitale Sociale ? 26.000 i.v.
Iscritta al Reg. Imprese di Padova N. 02663420285
Numero R.E.A. 258642

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

* [Buildroot] [PATCH] ffmpeg: fix static linking build failure when using libavutil
  2018-10-16 19:31               ` Giulio Benetti
@ 2018-10-17 10:36                 ` Giulio Benetti
  2018-10-17 12:37                   ` [Buildroot] [PATCH v2] " Giulio Benetti
  0 siblings, 1 reply; 15+ messages in thread
From: Giulio Benetti @ 2018-10-17 10:36 UTC (permalink / raw)
  To: buildroot

Hello,

Il 16/10/2018 21:31, Giulio Benetti ha scritto:
> Hello Thomas,
> 
> Il 12/10/2018 22:54, Giulio Benetti ha scritto:
>> Hello,
>>
>> Il 12/10/2018 21:50, Thomas Petazzoni ha scritto:
>>> Hello,
>>>
>>> On Fri, 12 Oct 2018 19:38:14 +0200, Giulio Benetti wrote:
>>>
>>>>>>>> Indeed, when we're dynamic linking, there is no need to link consumers
>>>>>>>> of libavutil with libdrm. It is only when we're statically linking that
>>>>>>>> it should be done. And that's exactly what Libs vs. Libs.private is for.
>>>>>>>
>>>>>>> You've explained me it very well, but by now FFmpeg upstreamed my patch:
>>>>>>> https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/c50dc77ac708e98d02da7c422a6b9cbf9f565aa5
>>>>>>>
>>>>>>> So, do I rework and resubmit to them or can I re-create a patch for BR
>>>>>>> with what you've pointed me above?
>>>> I've missed one thing to ask you about ffmpeg:
>>>> Can I still use this hack:
>>>> https://git.ffmpeg.org/gitweb/ffmpeg.git/blobdiff/bc2301429e9c779237e43acf913331af018211f2..c50dc77ac708e98d02da7c422a6b9cbf9f565aa5:/configure
>>>>
>>>> to obtain if -ldrm is used and then add it to Libs.private like this:
>>>> Libs.private: -ldrm
>>>>
>>>> as you've pointed me.
>>>>
>>>> Or there is something that makes it simpler and better?
>>>
>>> I'm not sure what "hack" you're talking about here. My only point it is
>>> only needed to link "indirect" libraries when static linking, and
>>> therefore such "indirect" libraries should be listed in Libs.private
>>> and not Libs in pkg-config files.
> 
> I've worked this out, but I have a question:
> Since FFMpeg upstreamed my previous wrong patch:
> https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/c50dc77ac708e98d02da7c422a6b9cbf9f565aa5
> 
> now I would submit another patch to FFMpeg to correct Libs vs
> Libs.private problem.
> 
> Here is the new patch:
> https://github.com/giuliobenetti/FFmpeg/commit/d682f418b7912b9d9e1818aefa61a51a2868fb20
> 
> So:
> do I have to submit to Buildroot a patch containing both patches?
> Or only one that merge both patches together even if it's not upstreamable?

I think I've answered myself, I need to:
- send patch to Revert "c50dc77ac708e98d02da7c422a6b9cbf9f565aa5"
- send new patch that is the squash of these 2 patches(1 already 
upstream and 1 that fixes the problem):
 
https://github.com/giuliobenetti/FFmpeg/commit/c50dc77ac708e98d02da7c422a6b9cbf9f565aa5
 
https://github.com/giuliobenetti/FFmpeg/commit/d682f418b7912b9d9e1818aefa61a51a2868fb20

-- 
Giulio Benetti
CTO

MICRONOVA SRL
Sede: Via A. Niedda 3 - 35010 Vigonza (PD)
Tel. 049/8931563 - Fax 049/8931346
Cod.Fiscale - P.IVA 02663420285
Capitale Sociale ? 26.000 i.v.
Iscritta al Reg. Imprese di Padova N. 02663420285
Numero R.E.A. 258642

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

* [Buildroot] [PATCH v2] ffmpeg: fix static linking build failure when using libavutil
  2018-10-17 10:36                 ` Giulio Benetti
@ 2018-10-17 12:37                   ` Giulio Benetti
  2018-10-17 12:39                     ` Giulio Benetti
  0 siblings, 1 reply; 15+ messages in thread
From: Giulio Benetti @ 2018-10-17 12:37 UTC (permalink / raw)
  To: buildroot

If a package tries to static link with libavutil it fails due to the
lack of libavutil private dependencies in libavutil.pc (-ldrm in this
case).

Add patch to:
- Check if libdrm is present.
- Add it to Libs.private: in libavutil.pc if present.

Fixes:
http://autobuild.buildroot.net/results/766/766de487f394490df8c712652ac364ebb4a3ab14/
http://autobuild.buildroot.net/results/041/041e29dfddb2da3309ac7d34a576c60c5a75fe4d/
http://autobuild.buildroot.net/results/780/78061b61cfe3f42554a475c048d54dacacfe11d5/
http://autobuild.buildroot.net/results/275/275e4e0030d26c029085b408cfb272d5633969c6/
http://autobuild.buildroot.net/results/515/5152dcca58944cf732d09fba6e6c9af8a9243c75/
http://autobuild.buildroot.net/results/395/395be1a9cab824b82ef34c2ebd84d54243029b33/

Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
---
 ...configure-add-LIBDRM-to-Libs.private.patch | 68 +++++++++++++++++++
 1 file changed, 68 insertions(+)
 create mode 100644 package/ffmpeg/0002-configure-add-LIBDRM-to-Libs.private.patch

diff --git a/package/ffmpeg/0002-configure-add-LIBDRM-to-Libs.private.patch b/package/ffmpeg/0002-configure-add-LIBDRM-to-Libs.private.patch
new file mode 100644
index 0000000000..5493473d0f
--- /dev/null
+++ b/package/ffmpeg/0002-configure-add-LIBDRM-to-Libs.private.patch
@@ -0,0 +1,68 @@
+From e1e11d404eec24c158ae1241d6573c263e57a7b9 Mon Sep 17 00:00:00 2001
+From: Giulio Benetti <giulio.benetti@micronovasrl.com>
+Date: Wed, 17 Oct 2018 13:13:10 +0200
+Subject: [PATCH] configure: add LIBDRM to Libs.private
+
+When static linking programs using ffmpeg libraries, if linking against
+libavutil, -ldrm is listed before -lavutil. This leads to linking
+failure due to undefined reference of drmGetVersion() and
+drmFreeVersion().
+This is why when pkg-config create libavutil.pc doesn't append -ldrm
+to Libs.private:.
+
+- Create LIBDRM=-ldrm in case libdrm is enabled.
+- Add privatelibs_avutil variable for explicit private libraries to be
+  appended to Libs.private:
+- Add $LIBDRM to privatelibs_avutil.
+
+Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
+---
+ configure                     | 3 ++-
+ ffbuild/pkgconfig_generate.sh | 3 ++-
+ 2 files changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/configure b/configure
+index 7377046d0a..0996d8a85d 100755
+--- a/configure
++++ b/configure
+@@ -5919,7 +5919,7 @@ enabled libcelt           && require libcelt celt/celt.h celt_decode -lcelt0 &&
+                                die "ERROR: libcelt must be installed and version must be >= 0.11.0."; }
+ enabled libcaca           && require_pkg_config libcaca caca caca.h caca_create_canvas
+ enabled libdc1394         && require_pkg_config libdc1394 libdc1394-2 dc1394/dc1394.h dc1394_new
+-enabled libdrm            && require_pkg_config libdrm libdrm xf86drm.h drmGetVersion
++enabled libdrm            && require_pkg_config libdrm libdrm xf86drm.h drmGetVersion && LIBDRM="-ldrm"
+ enabled libfdk_aac        && { use_pkg_config libfdk_aac fdk-aac "fdk-aac/aacenc_lib.h" aacEncOpen ||
+                                { require libfdk_aac fdk-aac/aacenc_lib.h aacEncOpen -lfdk-aac &&
+                                  warn "using libfdk without pkg-config"; } }
+@@ -7097,6 +7097,7 @@ LIBPREF=${LIBPREF}
+ LIBSUF=${LIBSUF}
+ 
+ extralibs_avutil="$LIBRT $LIBM"
++privatelibs_avutil="$LIBDRM"
+ extralibs_avcodec="$extralibs"
+ extralibs_avformat="$extralibs"
+ extralibs_avdevice="$extralibs"
+diff --git a/ffbuild/pkgconfig_generate.sh b/ffbuild/pkgconfig_generate.sh
+index e5de6716d2..b86486a107 100755
+--- a/ffbuild/pkgconfig_generate.sh
++++ b/ffbuild/pkgconfig_generate.sh
+@@ -13,6 +13,7 @@ name=lib${shortname}
+ fullname=${name}${build_suffix}
+ comment=$2
+ libs=$(eval echo \$extralibs_${shortname})
++privatelibs=$(eval echo \$privatelibs_${shortname})
+ deps=$(eval echo \$${shortname}_deps)
+ 
+ for dep in $deps; do
+@@ -39,7 +40,7 @@ Requires: $($shared || echo $requires)
+ Requires.private: $($shared && echo $requires)
+ Conflicts:
+ Libs: -L\${libdir} $rpath -l${fullname#lib} $($shared || echo $libs)
+-Libs.private: $($shared && echo $libs)
++Libs.private: $($shared && echo $libs) ${privatelibs}
+ Cflags: -I\${includedir}
+ EOF
+ 
+-- 
+2.17.1
+
-- 
2.17.1

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

* [Buildroot] [PATCH v2] ffmpeg: fix static linking build failure when using libavutil
  2018-10-17 12:37                   ` [Buildroot] [PATCH v2] " Giulio Benetti
@ 2018-10-17 12:39                     ` Giulio Benetti
  2018-10-17 12:49                       ` [Buildroot] [PATCH v3] " Giulio Benetti
  0 siblings, 1 reply; 15+ messages in thread
From: Giulio Benetti @ 2018-10-17 12:39 UTC (permalink / raw)
  To: buildroot

Il 17/10/2018 14:37, Giulio Benetti ha scritto:
> If a package tries to static link with libavutil it fails due to the
> lack of libavutil private dependencies in libavutil.pc (-ldrm in this
> case).
> 
> Add patch to:
> - Check if libdrm is present.
> - Add it to Libs.private: in libavutil.pc if present.
> 
> Fixes:
> http://autobuild.buildroot.net/results/766/766de487f394490df8c712652ac364ebb4a3ab14/
> http://autobuild.buildroot.net/results/041/041e29dfddb2da3309ac7d34a576c60c5a75fe4d/
> http://autobuild.buildroot.net/results/780/78061b61cfe3f42554a475c048d54dacacfe11d5/
> http://autobuild.buildroot.net/results/275/275e4e0030d26c029085b408cfb272d5633969c6/
> http://autobuild.buildroot.net/results/515/5152dcca58944cf732d09fba6e6c9af8a9243c75/
> http://autobuild.buildroot.net/results/395/395be1a9cab824b82ef34c2ebd84d54243029b33/
> 
> Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
> ---

Forgotten the Changes field.
Sorry, I resend.

-- 
Giulio Benetti
CTO

MICRONOVA SRL
Sede: Via A. Niedda 3 - 35010 Vigonza (PD)
Tel. 049/8931563 - Fax 049/8931346
Cod.Fiscale - P.IVA 02663420285
Capitale Sociale ? 26.000 i.v.
Iscritta al Reg. Imprese di Padova N. 02663420285
Numero R.E.A. 258642

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

* [Buildroot] [PATCH v3] ffmpeg: fix static linking build failure when using libavutil
  2018-10-17 12:39                     ` Giulio Benetti
@ 2018-10-17 12:49                       ` Giulio Benetti
  0 siblings, 0 replies; 15+ messages in thread
From: Giulio Benetti @ 2018-10-17 12:49 UTC (permalink / raw)
  To: buildroot

If a package tries to static link with libavutil it fails due to the
lack of libavutil private dependencies in libavutil.pc (-ldrm in this
case).

Add patch to:
- Check if libdrm is present.
- Add it to Libs.private: in libavutil.pc if present.

Fixes:
http://autobuild.buildroot.net/results/766/766de487f394490df8c712652ac364ebb4a3ab14/
http://autobuild.buildroot.net/results/041/041e29dfddb2da3309ac7d34a576c60c5a75fe4d/
http://autobuild.buildroot.net/results/780/78061b61cfe3f42554a475c048d54dacacfe11d5/
http://autobuild.buildroot.net/results/275/275e4e0030d26c029085b408cfb272d5633969c6/
http://autobuild.buildroot.net/results/515/5152dcca58944cf732d09fba6e6c9af8a9243c75/
http://autobuild.buildroot.net/results/395/395be1a9cab824b82ef34c2ebd84d54243029b33/

Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
---
Changes V1->V2:
* Modified ffmpeg patch to move -ldrm from "Libs:" to "Libs.private:" in libavutil.pc
* Rewritten commit log from scratch

Changes V2->V3:
* Added "Changes V1->V2" after commit log forgotten in v2 version

 ...configure-add-LIBDRM-to-Libs.private.patch | 68 +++++++++++++++++++
 1 file changed, 68 insertions(+)
 create mode 100644 package/ffmpeg/0002-configure-add-LIBDRM-to-Libs.private.patch

diff --git a/package/ffmpeg/0002-configure-add-LIBDRM-to-Libs.private.patch b/package/ffmpeg/0002-configure-add-LIBDRM-to-Libs.private.patch
new file mode 100644
index 0000000000..5493473d0f
--- /dev/null
+++ b/package/ffmpeg/0002-configure-add-LIBDRM-to-Libs.private.patch
@@ -0,0 +1,68 @@
+From e1e11d404eec24c158ae1241d6573c263e57a7b9 Mon Sep 17 00:00:00 2001
+From: Giulio Benetti <giulio.benetti@micronovasrl.com>
+Date: Wed, 17 Oct 2018 13:13:10 +0200
+Subject: [PATCH] configure: add LIBDRM to Libs.private
+
+When static linking programs using ffmpeg libraries, if linking against
+libavutil, -ldrm is listed before -lavutil. This leads to linking
+failure due to undefined reference of drmGetVersion() and
+drmFreeVersion().
+This is why when pkg-config create libavutil.pc doesn't append -ldrm
+to Libs.private:.
+
+- Create LIBDRM=-ldrm in case libdrm is enabled.
+- Add privatelibs_avutil variable for explicit private libraries to be
+  appended to Libs.private:
+- Add $LIBDRM to privatelibs_avutil.
+
+Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
+---
+ configure                     | 3 ++-
+ ffbuild/pkgconfig_generate.sh | 3 ++-
+ 2 files changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/configure b/configure
+index 7377046d0a..0996d8a85d 100755
+--- a/configure
++++ b/configure
+@@ -5919,7 +5919,7 @@ enabled libcelt           && require libcelt celt/celt.h celt_decode -lcelt0 &&
+                                die "ERROR: libcelt must be installed and version must be >= 0.11.0."; }
+ enabled libcaca           && require_pkg_config libcaca caca caca.h caca_create_canvas
+ enabled libdc1394         && require_pkg_config libdc1394 libdc1394-2 dc1394/dc1394.h dc1394_new
+-enabled libdrm            && require_pkg_config libdrm libdrm xf86drm.h drmGetVersion
++enabled libdrm            && require_pkg_config libdrm libdrm xf86drm.h drmGetVersion && LIBDRM="-ldrm"
+ enabled libfdk_aac        && { use_pkg_config libfdk_aac fdk-aac "fdk-aac/aacenc_lib.h" aacEncOpen ||
+                                { require libfdk_aac fdk-aac/aacenc_lib.h aacEncOpen -lfdk-aac &&
+                                  warn "using libfdk without pkg-config"; } }
+@@ -7097,6 +7097,7 @@ LIBPREF=${LIBPREF}
+ LIBSUF=${LIBSUF}
+ 
+ extralibs_avutil="$LIBRT $LIBM"
++privatelibs_avutil="$LIBDRM"
+ extralibs_avcodec="$extralibs"
+ extralibs_avformat="$extralibs"
+ extralibs_avdevice="$extralibs"
+diff --git a/ffbuild/pkgconfig_generate.sh b/ffbuild/pkgconfig_generate.sh
+index e5de6716d2..b86486a107 100755
+--- a/ffbuild/pkgconfig_generate.sh
++++ b/ffbuild/pkgconfig_generate.sh
+@@ -13,6 +13,7 @@ name=lib${shortname}
+ fullname=${name}${build_suffix}
+ comment=$2
+ libs=$(eval echo \$extralibs_${shortname})
++privatelibs=$(eval echo \$privatelibs_${shortname})
+ deps=$(eval echo \$${shortname}_deps)
+ 
+ for dep in $deps; do
+@@ -39,7 +40,7 @@ Requires: $($shared || echo $requires)
+ Requires.private: $($shared && echo $requires)
+ Conflicts:
+ Libs: -L\${libdir} $rpath -l${fullname#lib} $($shared || echo $libs)
+-Libs.private: $($shared && echo $libs)
++Libs.private: $($shared && echo $libs) ${privatelibs}
+ Cflags: -I\${includedir}
+ EOF
+ 
+-- 
+2.17.1
+
-- 
2.17.1

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

end of thread, other threads:[~2018-10-17 12:49 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-11 20:42 [Buildroot] [PATCH] ffmpeg: fix static linking build failure when using libavutil Giulio Benetti
2018-09-11 21:47 ` Giulio Benetti
2018-09-13  8:15   ` Giulio Benetti
2018-09-16 20:22 ` Thomas Petazzoni
2018-09-24 10:26   ` Giulio Benetti
2018-09-24 11:09     ` Thomas Petazzoni
2018-09-24 11:11       ` Giulio Benetti
2018-10-12 17:38         ` Giulio Benetti
2018-10-12 19:50           ` Thomas Petazzoni
2018-10-12 20:54             ` Giulio Benetti
2018-10-16 19:31               ` Giulio Benetti
2018-10-17 10:36                 ` Giulio Benetti
2018-10-17 12:37                   ` [Buildroot] [PATCH v2] " Giulio Benetti
2018-10-17 12:39                     ` Giulio Benetti
2018-10-17 12:49                       ` [Buildroot] [PATCH v3] " Giulio Benetti

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.