Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 468958 - x11-libs/gtkglext-1.2.0-r1 fails to compile with gcc -flto / LTO enabled - (some) configure tests are not LTO save and deliver wrong results
Summary: x11-libs/gtkglext-1.2.0-r1 fails to compile with gcc -flto / LTO enabled - (s...
Status: RESOLVED DUPLICATE of bug 324107
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] GNOME (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Linux Gnome Desktop Team
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2013-05-07 23:03 UTC by cmuelle8
Modified: 2013-12-24 12:50 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
gtkglext-1.2.0-r1.ebuild.patch (gtkglext-1.2.0-r1.ebuild.patch,724 bytes, patch)
2013-05-07 23:07 UTC, cmuelle8
Details | Diff
build log -flto on stock ebuild 1367883332-install-x11-libs_gtkglext-1.2.0-r1:0::gentoo.out (1367883332-install-x11-libs_gtkglext-1.2.0-r1:0::gentoo.out,46.21 KB, text/plain)
2013-05-07 23:18 UTC, cmuelle8
Details

Note You need to log in before you can comment on or make changes to this bug.
Description cmuelle8 2013-05-07 23:03:15 UTC
SYMPTOM)
# grep -B 3 Error 1367883332-install-x11-libs_gtkglext-1.2.0-r1:0::gentoo.out 

/usr/bin/nm -B  .libs/gdkglversion.o .libs/gdkglinit.o .libs/gdkglquery.o .libs/gdkglconfig.o .libs/gdkglcontext.o .libs/gdkgldrawable.o .libs/gdkglpixmap.o .libs/gdkglwindow.o .libs/gdkglshapes.o .libs/gdkglglext.o .libs/gdkglenumtypes.o  x11/.libs/libgdkglext-x11.a |  | /bin/sed 's/.* //' | sort | uniq > .libs/libgdkglext-x11-1.0.exp
../libtool: eval: line 4394: syntax error near unexpected token `|'
../libtool: eval: line 4394: `/usr/bin/nm -B  .libs/gdkglversion.o .libs/gdkglinit.o .libs/gdkglquery.o .libs/gdkglconfig.o .libs/gdkglcontext.o .libs/gdkgldrawable.o .libs/gdkglpixmap.o .libs/gdkglwindow.o .libs/gdkglshapes.o .libs/gdkglglext.o .libs/gdkglenumtypes.o  x11/.libs/libgdkglext-x11.a |  | /bin/sed 's/.* //' | sort | uniq > .libs/libgdkglext-x11-1.0.exp'
make[4]: *** [libgdkglext-x11-1.0.la] Error 2



ANALYSIS)
- there is an empty pipe command between two consecutive pipe operators
- .. caused by configure-generated ./libtool
# grep -r global_symbol_pipe /var/tmp/paludis/x11-libs-gtkglext-1.2.0-r1/work/gtkglext-1.2.0/libtool 
[...]
global_symbol_pipe=""
export_symbols_cmds="\$NM \$libobjs \$convenience | \$global_symbol_pipe | \$SED 's/.* //' | sort | uniq > \$export_symbols"

- .... caused by a failed test in configure
1.2.0/config.log
configure:5912: checking command to parse /usr/bin/nm -B output from x86_64-pc-linux-gnu-gcc object
configure:6017: x86_64-pc-linux-gnu-gcc -c -march=native -pipe -O2 -mfpmath=sse -flto=4 -floop-block -floop-interchange -floop-strip-mine -fuse-linker-plugin  conftest.c >&5
configure:6020: $? = 0
configure:6024: /usr/bin/nm -B conftest.o \| sed -n -e 's/^.*[ 	]\([ABCDGIRSTW][ABCDGIRSTW]*\)[ 	][ 	]*\([_A-Za-z][_A-Za-z0-9]*\)$/\1 \2 \2/p' \> conftest.nm
configure:6027: $? = 0
configure:6079: x86_64-pc-linux-gnu-gcc -o conftest -march=native -pipe -O2 -mfpmath=sse -flto=4 -floop-block -floop-interchange -floop-strip-mine -fuse-linker-plugin  -march=native -pipe -O2 -mfpmath=sse -flto=4 -floop-block -floop-interchange -floop-strip-mine -fuse-linker-plugin -Wl,--as-needed -Wl,-O1 -Wl,--hash-style=gnu -Wl,--sort-common conftest.c conftstm.o >&5
In file included from :0:0:
conftest.c:7:12: error: function 'nm_test_func' redeclared as variable
In file included from conftest.c:24:0,
                 from :0:
conftest.c:5:6: note: previously declared here
In file included from :0:0:
conftest.c:6:12: warning: type of 'nm_test_var' does not match original declaration [enabled by default]
In file included from conftest.c:24:0,
                 from :0:
conftest.c:4:6: note: previously declared here
lto1: fatal error: errors during merging of translation units
compilation terminated.
lto-wrapper: /usr/x86_64-pc-linux-gnu/gcc-bin/4.7.2/x86_64-pc-linux-gnu-gcc returned 1 exit status
/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.2/../../../../x86_64-pc-linux-gnu/bin/ld: fatal error: lto-wrapper failed
collect2: error: ld returned 1 exit status
configure:6082: $? = 1
configure:6017: x86_64-pc-linux-gnu-gcc -c -march=native -pipe -O2 -mfpmath=sse -flto=4 -floop-block -floop-interchange -floop-strip-mine -fuse-linker-plugin  conftest.c >&5
configure:6020: $? = 0
configure:6024: /usr/bin/nm -B conftest.o \| sed -n -e 's/^.*[ 	]\([ABCDGIRSTW][ABCDGIRSTW]*\)[ 	][ 	]*_\([_A-Za-z][_A-Za-z0-9]*\)$/\1 _\2 \2/p' \> conftest.nm
configure:6027: $? = 0
cannot find nm_test_var in conftest.nm
configure:6117: result: failed

- ...... caused by the different type gcc links the compilation units conftest.c conftstm.o when LTO is used
conftest.c:7:12: error: function 'nm_test_func' redeclared as variable



CURE)
The test program will succeed/survive LTO compilation, if 'nm_test_func' is not redeclared as a variable, but as a function.

There is architecture specific code in configure that already does exactly this, we can reuse it.

The following changes are sed'd using the ebuild patch attached.  The patch listed here is to demonstrate what is done.  Note that configure is ONLY patched, IF flto is detected within at least one of {C,CXX,LD}FLAGS.

--- configure	2006-02-05 04:17:47.000000000 +0100
+++ /dev/fd/63	2013-05-08 00:52:11.964616992 +0200
@@ -5948,9 +5948,10 @@
 linux*)
   if test "$host_cpu" = ia64; then
     symcode='[ABCDGIRSTW]'
+  fi
+
     lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
     lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/  {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/  {\"\2\", (lt_ptr) \&\2},/p'"
-  fi
   ;;
 irix* | nonstopux*)
   symcode='[BCDEGRST]'



Have fun closing this as invalid.  However, if you decide to give early adopters of lto a chance by applying the patch, note that sed will only effect configure IF flto is detected within at least one of {C,CXX,LD}FLAGS.  This way, gentooers not using flto will compile vanilla code.  Imho this should be safe enough to start supporting it.

Reproducible: Always
Comment 1 cmuelle8 2013-05-07 23:07:38 UTC
Created attachment 347664 [details, diff]
gtkglext-1.2.0-r1.ebuild.patch

See first comment to see the diff between vanilla and sed'd configure produced by the updated ebuild attached.
Comment 2 cmuelle8 2013-05-07 23:18:54 UTC
Created attachment 347666 [details]
build log -flto on stock ebuild 1367883332-install-x11-libs_gtkglext-1.2.0-r1:0::gentoo.out
Comment 3 Pacho Ramos gentoo-dev 2013-09-29 11:23:03 UTC
(In reply to cmuelle8 from comment #1)
> Created attachment 347664 [details, diff] [details, diff]
> gtkglext-1.2.0-r1.ebuild.patch
> 
> See first comment to see the diff between vanilla and sed'd configure
> produced by the updated ebuild attached.

Not sure if this is the right fix for LTO issues :/
Comment 4 Pacho Ramos gentoo-dev 2013-12-24 12:48:27 UTC
Also, the patches need to change configure.ac/in, not final configure
Comment 5 Pacho Ramos gentoo-dev 2013-12-24 12:50:01 UTC
As seen in pertinent bug report, this needs to be solved in libtool side, not for every package with wrongly generated files due libtool bug

*** This bug has been marked as a duplicate of bug 324107 ***