Re: [libav-devel] [PATCH] configure: add --enable-lto option

2012-10-03 Thread Luca Barbato
On 10/03/2012 10:00 PM, Måns Rullgård wrote:
> Luca Barbato  writes:
> 
>> On 10/03/2012 08:46 PM, Mans Rullgard wrote:
>>> This works with gcc.  Other compilers might need to have a flag
>>> mapping added.
>>
>> The other I know about (clang, path64) have some more exotic ways (clang
>> requires to pass around --plugin theirplugin.so to everything currently)
> 
> clang -flto automatically passes the proper linker flags for gold.  I'd
> rather not install gold just for this, so I haven't tested if it
> actually works.
> 

Ok then

lu
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] configure: add --enable-lto option

2012-10-03 Thread Måns Rullgård
Luca Barbato  writes:

> On 10/03/2012 08:46 PM, Mans Rullgard wrote:
>> This works with gcc.  Other compilers might need to have a flag
>> mapping added.
>
> The other I know about (clang, path64) have some more exotic ways (clang
> requires to pass around --plugin theirplugin.so to everything currently)

clang -flto automatically passes the proper linker flags for gold.  I'd
rather not install gold just for this, so I haven't tested if it
actually works.

-- 
Måns Rullgård
m...@mansr.com
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] configure: add --enable-lto option

2012-10-03 Thread Luca Barbato
On 10/03/2012 08:46 PM, Mans Rullgard wrote:
> This works with gcc.  Other compilers might need to have a flag
> mapping added.

The other I know about (clang, path64) have some more exotic ways (clang
requires to pass around --plugin theirplugin.so to everything currently)

lu

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] configure: add --enable-lto option

2012-10-03 Thread Måns Rullgård
Luca Barbato  writes:

> On 10/03/2012 08:46 PM, Mans Rullgard wrote:
>> -check_cflags -fno-tree-vectorize
>> +check_optflags -fno-tree-vectorize
>
> uhm?

That is necessary to disable the vectoriser during linking.

-- 
Måns Rullgård
m...@mansr.com
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] configure: add --enable-lto option

2012-10-03 Thread Måns Rullgård
Luca Barbato  writes:

> On 10/03/2012 08:46 PM, Mans Rullgard wrote:
>> This works with gcc.  Other compilers might need to have a flag
>> mapping added.
>> 
> which version you tested with lto? 4.7.2 can work?

Some 4.7 seemed to work.  4.8 failed to link.

-- 
Måns Rullgård
m...@mansr.com
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] configure: add --enable-lto option

2012-10-03 Thread Luca Barbato
On 10/03/2012 08:56 PM, Luca Barbato wrote:
> On 10/03/2012 08:46 PM, Mans Rullgard wrote:
>> -check_cflags -fno-tree-vectorize
>> +check_optflags -fno-tree-vectorize
> 
> uhm?

Ignore, I misread =P

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] configure: add --enable-lto option

2012-10-03 Thread Luca Barbato
On 10/03/2012 08:46 PM, Mans Rullgard wrote:
> -check_cflags -fno-tree-vectorize
> +check_optflags -fno-tree-vectorize

uhm?
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] configure: add --enable-lto option

2012-10-03 Thread Luca Barbato
On 10/03/2012 08:46 PM, Mans Rullgard wrote:
> This works with gcc.  Other compilers might need to have a flag
> mapping added.
> 
which version you tested with lto? 4.7.2 can work?

lu

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] configure: add --enable-lto option

2012-10-03 Thread Mans Rullgard
This works with gcc.  Other compilers might need to have a flag
mapping added.

Signed-off-by: Mans Rullgard 
---
 configure | 38 +++---
 1 file changed, 27 insertions(+), 11 deletions(-)

diff --git a/configure b/configure
index 6d68424..12f9872 100755
--- a/configure
+++ b/configure
@@ -240,6 +240,7 @@ Advanced options (experts only):
disable buffer boundary checking in bitreaders
(faster, but may crash)
   --enable-memalign-hack   emulate memalign, interferes with memory debuggers
+  --enable-lto use link-time optimization
 
 Optimization options (experts only):
   --disable-asmdisable all assembler optimizations
@@ -1287,6 +1288,7 @@ CMDLINE_SELECT="
 extra_warnings
 inline_asm
 logging
+lto
 optimizations
 symver
 yasm
@@ -3443,17 +3445,31 @@ void ff_foo(void) {}
 EOF
 fi
 
-if [ -n "$optflags" ]; then
-add_cflags $optflags
-elif enabled small; then
-add_cflags $cflags_size
-elif enabled optimizations; then
-add_cflags $cflags_speed
-else
-add_cflags $cflags_noopt
+if [ -z "$optflags" ]; then
+if enabled small; then
+optflags=$cflags_size
+elif enabled optimizations; then
+optflags=$cflags_speed
+else
+optflags=$cflags_noopt
+fi
 fi
-check_cflags -fno-math-errno
-check_cflags -fno-signed-zeros
+
+check_optflags(){
+check_cflags "$@"
+enabled lto && check_ldflags "$@"
+}
+
+
+if enabled lto; then
+test "$cc_type" != "$ld_type" && die "LTO requires same compiler and 
linker"
+check_cflags  -flto
+check_ldflags -flto $cpuflags
+fi
+
+check_optflags $optflags
+check_optflags -fno-math-errno
+check_optflags -fno-signed-zeros
 
 if enabled icc; then
 # Just warnings, no remarks
@@ -3488,7 +3504,7 @@ elif enabled ccc; then
 add_cflags -msg_disable ptrmismatch1
 add_cflags -msg_disable unreachcode
 elif enabled gcc; then
-check_cflags -fno-tree-vectorize
+check_optflags -fno-tree-vectorize
 check_cflags -Werror=implicit-function-declaration
 check_cflags -Werror=missing-prototypes
 check_cflags -Werror=declaration-after-statement
-- 
1.7.12

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel