diff mbox

[FFmpeg-devel] configure: call flatten_extralibs in a subshell

Message ID 20171114135012.30562-1-timo@rothenpieler.org
State New
Headers show

Commit Message

Timo Rothenpieler Nov. 14, 2017, 1:50 p.m. UTC
By putting the call in a subshell, the problem of it spilling
cleanup-decision from a previous library to other libraries is avoided.

For example, it could have already cleaned up cuda_extralibs in a
previous library that depended on cuda. Then when it gets to avutil, it
will never pick up the dependency of avutil to cuda, which depends on
libdl, which in turn results in a missing -ldl extralib, resulting in
link failures in certain configurations.
---
 configure | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

Comments

Timo Rothenpieler Nov. 14, 2017, 2:35 p.m. UTC | #1
Am 14.11.2017 um 14:50 schrieb Timo Rothenpieler:
> By putting the call in a subshell, the problem of it spilling
> cleanup-decision from a previous library to other libraries is avoided.
> 
> For example, it could have already cleaned up cuda_extralibs in a
> previous library that depended on cuda. Then when it gets to avutil, it
> will never pick up the dependency of avutil to cuda, which depends on
> libdl, which in turn results in a missing -ldl extralib, resulting in
> link failures in certain configurations.
> ---
>   configure | 15 +++++++++++----
>   1 file changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/configure b/configure
> index 3788f26956..1fc6821fe7 100755
> --- a/configure
> +++ b/configure
> @@ -6501,6 +6501,16 @@ flatten_extralibs(){
>       fi
>   }
>   
> +flatten_extralibs_wrapper(){
> +    list_name=$1
> +    flatten_extralibs $list_name
> +    unique $list_name
> +    resolve $list_name
> +    unique $list_name

Scratch that second unique.
While it does get rid of a bunch of duplicates like double -lX11 or 
-lvpx, it breaks MacOS builds, due to it getting rid of all but one 
-framework invocations.

> +    eval $list_name=\$\(\$ldflags_filter \$$list_name\)
> +    eval printf \''%s'\' \""\$$list_name"\"
> +}
> +
>   for linkunit in $LIBRARY_LIST; do
>       unset current_extralibs
>       eval components=\$$(toupper ${linkunit})_COMPONENTS_LIST
> @@ -6513,10 +6523,7 @@ for linkunit in $LIBRARY_LIST; do
>   done
>   
>   for linkunit in $LIBRARY_LIST $PROGRAM_LIST $EXTRALIBS_LIST; do
> -    flatten_extralibs ${linkunit}_extralibs
> -    unique  ${linkunit}_extralibs
> -    resolve ${linkunit}_extralibs
> -    eval ${linkunit}_extralibs=\$\(\$ldflags_filter \$${linkunit}_extralibs\)
> +    eval ${linkunit}_extralibs=\$\(flatten_extralibs_wrapper ${linkunit}_extralibs\)
>   done
>   
>   map 'enabled $v && intrinsics=${v#intrinsics_}' $INTRINSICS_LIST
>
James Almer Nov. 14, 2017, 7:09 p.m. UTC | #2
On 11/14/2017 11:35 AM, Timo Rothenpieler wrote:
> Am 14.11.2017 um 14:50 schrieb Timo Rothenpieler:
>> By putting the call in a subshell, the problem of it spilling
>> cleanup-decision from a previous library to other libraries is avoided.
>>
>> For example, it could have already cleaned up cuda_extralibs in a
>> previous library that depended on cuda. Then when it gets to avutil, it
>> will never pick up the dependency of avutil to cuda, which depends on
>> libdl, which in turn results in a missing -ldl extralib, resulting in
>> link failures in certain configurations.
>> ---
>>   configure | 15 +++++++++++----
>>   1 file changed, 11 insertions(+), 4 deletions(-)
>>
>> diff --git a/configure b/configure
>> index 3788f26956..1fc6821fe7 100755
>> --- a/configure
>> +++ b/configure
>> @@ -6501,6 +6501,16 @@ flatten_extralibs(){
>>       fi
>>   }
>>   +flatten_extralibs_wrapper(){
>> +    list_name=$1
>> +    flatten_extralibs $list_name
>> +    unique $list_name
>> +    resolve $list_name
>> +    unique $list_name
> 
> Scratch that second unique.
> While it does get rid of a bunch of duplicates like double -lX11 or
> -lvpx, it breaks MacOS builds, due to it getting rid of all but one
> -framework invocations.

Seems to work after removing the second unique. Thanks a lot!

> 
>> +    eval $list_name=\$\(\$ldflags_filter \$$list_name\)
>> +    eval printf \''%s'\' \""\$$list_name"\"
>> +}
>> +
>>   for linkunit in $LIBRARY_LIST; do
>>       unset current_extralibs
>>       eval components=\$$(toupper ${linkunit})_COMPONENTS_LIST
>> @@ -6513,10 +6523,7 @@ for linkunit in $LIBRARY_LIST; do
>>   done
>>     for linkunit in $LIBRARY_LIST $PROGRAM_LIST $EXTRALIBS_LIST; do
>> -    flatten_extralibs ${linkunit}_extralibs
>> -    unique  ${linkunit}_extralibs
>> -    resolve ${linkunit}_extralibs
>> -    eval ${linkunit}_extralibs=\$\(\$ldflags_filter
>> \$${linkunit}_extralibs\)
>> +    eval ${linkunit}_extralibs=\$\(flatten_extralibs_wrapper
>> ${linkunit}_extralibs\)
>>   done
>>     map 'enabled $v && intrinsics=${v#intrinsics_}' $INTRINSICS_LIST
>>
> 
> 
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
Timo Rothenpieler Nov. 16, 2017, 10:53 a.m. UTC | #3
will push soon if nobody objects
Timo Rothenpieler Nov. 16, 2017, 5:17 p.m. UTC | #4
applied
diff mbox

Patch

diff --git a/configure b/configure
index 3788f26956..1fc6821fe7 100755
--- a/configure
+++ b/configure
@@ -6501,6 +6501,16 @@  flatten_extralibs(){
     fi
 }
 
+flatten_extralibs_wrapper(){
+    list_name=$1
+    flatten_extralibs $list_name
+    unique $list_name
+    resolve $list_name
+    unique $list_name
+    eval $list_name=\$\(\$ldflags_filter \$$list_name\)
+    eval printf \''%s'\' \""\$$list_name"\"
+}
+
 for linkunit in $LIBRARY_LIST; do
     unset current_extralibs
     eval components=\$$(toupper ${linkunit})_COMPONENTS_LIST
@@ -6513,10 +6523,7 @@  for linkunit in $LIBRARY_LIST; do
 done
 
 for linkunit in $LIBRARY_LIST $PROGRAM_LIST $EXTRALIBS_LIST; do
-    flatten_extralibs ${linkunit}_extralibs
-    unique  ${linkunit}_extralibs
-    resolve ${linkunit}_extralibs
-    eval ${linkunit}_extralibs=\$\(\$ldflags_filter \$${linkunit}_extralibs\)
+    eval ${linkunit}_extralibs=\$\(flatten_extralibs_wrapper ${linkunit}_extralibs\)
 done
 
 map 'enabled $v && intrinsics=${v#intrinsics_}' $INTRINSICS_LIST