public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug lto/42690]  New: Undefined reference errors with -flto -fuse-linker-plugin
@ 2010-01-11 15:23 d dot g dot gorbachev at gmail dot com
  2010-01-11 15:25 ` [Bug lto/42690] " d dot g dot gorbachev at gmail dot com
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: d dot g dot gorbachev at gmail dot com @ 2010-01-11 15:23 UTC (permalink / raw)
  To: gcc-bugs




-- 
           Summary: Undefined reference errors with -flto -fuse-linker-
                    plugin
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: lto
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: d dot g dot gorbachev at gmail dot com
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42690


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

* [Bug lto/42690] Undefined reference errors with -flto -fuse-linker-plugin
  2010-01-11 15:23 [Bug lto/42690] New: Undefined reference errors with -flto -fuse-linker-plugin d dot g dot gorbachev at gmail dot com
@ 2010-01-11 15:25 ` d dot g dot gorbachev at gmail dot com
  2010-01-12 16:30 ` espindola at gcc dot gnu dot org
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: d dot g dot gorbachev at gmail dot com @ 2010-01-11 15:25 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from d dot g dot gorbachev at gmail dot com  2010-01-11 15:25 -------
Created an attachment (id=19541)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=19541&action=view)
testcase

GCC 4.5.0 20100107.

gcc -flto -fuse-linker-plugin pr42690.c -DBUG


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42690


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

* [Bug lto/42690] Undefined reference errors with -flto -fuse-linker-plugin
  2010-01-11 15:23 [Bug lto/42690] New: Undefined reference errors with -flto -fuse-linker-plugin d dot g dot gorbachev at gmail dot com
  2010-01-11 15:25 ` [Bug lto/42690] " d dot g dot gorbachev at gmail dot com
@ 2010-01-12 16:30 ` espindola at gcc dot gnu dot org
  2010-01-14 22:15 ` d dot g dot gorbachev at gmail dot com
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: espindola at gcc dot gnu dot org @ 2010-01-12 16:30 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from espindola at gcc dot gnu dot org  2010-01-12 16:29 -------
Is the undefined reference to libgcc? Is it being linked statically? When
linking libgcc statically the driver has to pass
-plugin-opt=-pass-through=/foo/bar/libgcc.a to ld. This is done in gcc.c:

    %{static|static-libgcc:-plugin-opt=-pass-through=%(lto_libgcc)}     \
    %{static:-plugin-opt=-pass-through=-lc}     \

So, is there a better way to detect that we are linking libgcc statically?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42690


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

* [Bug lto/42690] Undefined reference errors with -flto -fuse-linker-plugin
  2010-01-11 15:23 [Bug lto/42690] New: Undefined reference errors with -flto -fuse-linker-plugin d dot g dot gorbachev at gmail dot com
  2010-01-11 15:25 ` [Bug lto/42690] " d dot g dot gorbachev at gmail dot com
  2010-01-12 16:30 ` espindola at gcc dot gnu dot org
@ 2010-01-14 22:15 ` d dot g dot gorbachev at gmail dot com
  2010-01-15  3:41 ` hjl dot tools at gmail dot com
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: d dot g dot gorbachev at gmail dot com @ 2010-01-14 22:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from d dot g dot gorbachev at gmail dot com  2010-01-14 22:15 -------
> Is the undefined reference to libgcc? Is it being linked statically?

Yes. In both cases (with and without -DBUG), the ld command line is

/usr/local/bin/ld -plugin
/usr/local/libexec/gcc/i686-pc-linux-gnu/4.5.0/liblto_plugin.so
-plugin-opt=/usr/local/libexec/gcc/i686-pc-linux-gnu/4.5.0/lto-wrapper
-plugin-opt=i686-pc-linux-gnu-gcc-4.5.0 -plugin-opt=-flto
-plugin-opt=-fuse-linker-plugin -plugin-opt=-mtune=generic --eh-frame-hdr -m
elf_i386 -dynamic-linker /lib/ld-linux.so.2 /usr/lib/crt1.o /usr/lib/crti.o
/usr/local/lib/gcc/i686-pc-linux-gnu/4.5.0/crtbegin.o
-L/usr/local/lib/gcc/i686-pc-linux-gnu/4.5.0
-L/usr/local/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../../i686-pc-linux-gnu/lib
-L/usr/local/lib/gcc/i686-pc-linux-gnu/4.5.0/../../.. /tmp/ccEIWEH2.o -lgcc -lc
-lgcc /usr/local/lib/gcc/i686-pc-linux-gnu/4.5.0/crtend.o /usr/lib/crtn.o

However, this error only happens with -DBUG.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42690


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

* [Bug lto/42690] Undefined reference errors with -flto -fuse-linker-plugin
  2010-01-11 15:23 [Bug lto/42690] New: Undefined reference errors with -flto -fuse-linker-plugin d dot g dot gorbachev at gmail dot com
                   ` (2 preceding siblings ...)
  2010-01-14 22:15 ` d dot g dot gorbachev at gmail dot com
@ 2010-01-15  3:41 ` hjl dot tools at gmail dot com
  2010-01-15  3:55 ` espindola at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: hjl dot tools at gmail dot com @ 2010-01-15  3:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from hjl dot tools at gmail dot com  2010-01-15 03:41 -------
Works for me:

[hjl@gnu-6 gold-2]$ vi pr42690.c
[hjl@gnu-6 gold-2]$ cat pr42690.c
int f(long long a, long long b)
{
#ifdef BUG
    return (int) (a / b);
#else
    return (int) __divdi3(a, b);
#endif
}

int main(void)
{
    return f(2718281828459045, 543656365691809);
}
[hjl@gnu-6 gold-2]$ /export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc -B./
-B/export/build/gnu/gcc/build-x86_64-linux/gcc/
-B/export/build/gnu/gcc/build-x86_64-linux/gcc/../lto-plugin/.libs/ -flto
-fuse-linker-plugin -DBUG pr42690.c
[hjl@gnu-6 gold-2]$ /export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc -v
Using built-in specs.
COLLECT_GCC=/export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc
Target: x86_64-unknown-linux-gnu
Configured with: /export/gnu/import/git/gcc/configure --enable-languages=c
--disable-bootstrap --prefix=/usr/gcc-4.5.0 --with-local-prefix=/usr/local
--with-plugin-ld=ld.gold --enable-gold
Thread model: posix
gcc version 4.5.0 20100114 (experimental) (GCC)
[hjl@gnu-6 gold-2]$


-- 

hjl dot tools at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |WORKSFORME


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42690


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

* [Bug lto/42690] Undefined reference errors with -flto -fuse-linker-plugin
  2010-01-11 15:23 [Bug lto/42690] New: Undefined reference errors with -flto -fuse-linker-plugin d dot g dot gorbachev at gmail dot com
                   ` (3 preceding siblings ...)
  2010-01-15  3:41 ` hjl dot tools at gmail dot com
@ 2010-01-15  3:55 ` espindola at gcc dot gnu dot org
  2010-01-15  4:26 ` hjl dot tools at gmail dot com
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: espindola at gcc dot gnu dot org @ 2010-01-15  3:55 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from espindola at gcc dot gnu dot org  2010-01-15 03:54 -------
Note that
-plugin-opt=-pass-through=/foo/bar/libgcc.a
is missing in the linker invocation.

That is the problem. When BUG is not defined, the undefined reference is
visible early on. You can check that with

GNUTARGET=plugin nm --prugin ..../libltoplugin.so foo.o

If BUG is defined the plugin will not see a call since it will only created by
codegen. That is why the driver asks the linker to take a second look at some
libraries by passing the pass-through option.

We have to figure out a better way to detected in gcc.c that libgcc (and/or
libc) will be linked statically.

H.J.Lu: You are probably linking with a shared libgcc, no?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42690


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

* [Bug lto/42690] Undefined reference errors with -flto -fuse-linker-plugin
  2010-01-11 15:23 [Bug lto/42690] New: Undefined reference errors with -flto -fuse-linker-plugin d dot g dot gorbachev at gmail dot com
                   ` (4 preceding siblings ...)
  2010-01-15  3:55 ` espindola at gcc dot gnu dot org
@ 2010-01-15  4:26 ` hjl dot tools at gmail dot com
  2010-01-15 11:02 ` d dot g dot gorbachev at gmail dot com
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: hjl dot tools at gmail dot com @ 2010-01-15  4:26 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from hjl dot tools at gmail dot com  2010-01-15 04:26 -------
I got

[hjl@gnu-6 gold-2]$ /export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc -B./
-B/export/build/gnu/gcc/build-x86_64-linux/gcc/
-B/export/build/gnu/gcc/build-x86_64-linux/gcc/../lto-plugin/.libs/ -flto
-fuse-linker-plugin -DBUG pr42690.c -v
Reading specs from /export/build/gnu/gcc/build-x86_64-linux/gcc/specs
COLLECT_GCC=/export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc
COLLECT_LTO_WRAPPER=/export/build/gnu/gcc/build-x86_64-linux/gcc/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /export/gnu/import/git/gcc/configure --enable-languages=c
--disable-bootstrap --prefix=/usr/gcc-4.5.0 --with-local-prefix=/usr/local
--with-plugin-ld=ld.gold --enable-gold
Thread model: posix
gcc version 4.5.0 20100114 (experimental) (GCC)
COLLECT_GCC_OPTIONS='-B./' '-B/export/build/gnu/gcc/build-x86_64-linux/gcc/'
'-B/export/build/gnu/gcc/build-x86_64-linux/gcc/../lto-plugin/.libs/' '-flto'
'-fuse-linker-plugin' '-DBUG' '-v' '-mtune=generic'
 /export/build/gnu/gcc/build-x86_64-linux/gcc/cc1 -quiet -v -iprefix
/export/build/gnu/gcc/build-x86_64-linux/gcc/../lib/gcc/x86_64-unknown-linux-gnu/4.5.0/
-isystem /export/build/gnu/gcc/build-x86_64-linux/gcc/include -isystem
/export/build/gnu/gcc/build-x86_64-linux/gcc/include-fixed -DBUG pr42690.c
-quiet -dumpbase pr42690.c -mtune=generic -auxbase pr42690 -version -flto
-fuse-linker-plugin -o /tmp/ccgwrI0o.s
GNU C (GCC) version 4.5.0 20100114 (experimental) (x86_64-unknown-linux-gnu)
        compiled by GNU C version 4.4.2 20091222 (Red Hat 4.4.2-20), GMP
version 4.3.1, MPFR version 2.4.2, MPC version 0.8
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
ignoring nonexistent directory
"/export/build/gnu/gcc/build-x86_64-linux/gcc/../lib/gcc/x86_64-unknown-linux-gnu/4.5.0/include"
ignoring nonexistent directory
"/export/build/gnu/gcc/build-x86_64-linux/gcc/../lib/gcc/x86_64-unknown-linux-gnu/4.5.0/include-fixed"
ignoring nonexistent directory
"/export/build/gnu/gcc/build-x86_64-linux/gcc/../lib/gcc/x86_64-unknown-linux-gnu/4.5.0/../../../../x86_64-unknown-linux-gnu/include"
ignoring nonexistent directory
"/export/build/gnu/gcc/build-x86_64-linux/gcc/../lib/gcc/../../include"
ignoring nonexistent directory
"/export/build/gnu/gcc/build-x86_64-linux/gcc/../lib/gcc/../../lib/gcc/x86_64-unknown-linux-gnu/4.5.0/include"
ignoring nonexistent directory
"/export/build/gnu/gcc/build-x86_64-linux/gcc/../lib/gcc/../../lib/gcc/x86_64-unknown-linux-gnu/4.5.0/include-fixed"
ignoring nonexistent directory
"/export/build/gnu/gcc/build-x86_64-linux/gcc/../lib/gcc/../../lib/gcc/x86_64-unknown-linux-gnu/4.5.0/../../../../x86_64-unknown-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /export/build/gnu/gcc/build-x86_64-linux/gcc/include
 /export/build/gnu/gcc/build-x86_64-linux/gcc/include-fixed
 /usr/local/include
 /usr/include
End of search list.
GNU C (GCC) version 4.5.0 20100114 (experimental) (x86_64-unknown-linux-gnu)
        compiled by GNU C version 4.4.2 20091222 (Red Hat 4.4.2-20), GMP
version 4.3.1, MPFR version 2.4.2, MPC version 0.8
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: f1a6981d8022db97daab7f58c757004b
COLLECT_GCC_OPTIONS='-B./' '-B/export/build/gnu/gcc/build-x86_64-linux/gcc/'
'-B/export/build/gnu/gcc/build-x86_64-linux/gcc/../lto-plugin/.libs/' '-flto'
'-fuse-linker-plugin' '-DBUG' '-v' '-mtune=generic'
 /export/build/gnu/gcc/build-x86_64-linux/gcc/as -V -Qy -o /tmp/cckKXRh8.o
/tmp/ccgwrI0o.s
GNU assembler version 2.20.51.0.5 (x86_64-unknown-linux-gnu) using BFD version
(Linux/GNU Binutils) 2.20.51.0.5.20100115
COMPILER_PATH=./:/export/build/gnu/gcc/build-x86_64-linux/gcc/:/export/build/gnu/gcc/build-x86_64-linux/gcc/../lto-plugin/.libs/
LIBRARY_PATH=./:/export/build/gnu/gcc/build-x86_64-linux/gcc/:/export/build/gnu/gcc/build-x86_64-linux/gcc/../lto-plugin/.libs/:/lib/../lib64/:/usr/lib/../lib64/:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-B./' '-B/export/build/gnu/gcc/build-x86_64-linux/gcc/'
'-B/export/build/gnu/gcc/build-x86_64-linux/gcc/../lto-plugin/.libs/' '-flto'
'-fuse-linker-plugin' '-DBUG' '-v' '-mtune=generic'
 /export/build/gnu/gcc/build-x86_64-linux/gcc/collect2 -plugin
/export/build/gnu/gcc/build-x86_64-linux/gcc/../lto-plugin/.libs/liblto_plugin.so
-plugin-opt=/export/build/gnu/gcc/build-x86_64-linux/gcc/lto-wrapper
-plugin-opt=/export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc -plugin-opt=-flto
-plugin-opt=-fuse-linker-plugin -plugin-opt=-mtune=generic -plugin-opt=-v -flto
--eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2
/usr/lib/../lib64/crt1.o /usr/lib/../lib64/crti.o
/export/build/gnu/gcc/build-x86_64-linux/gcc/crtbegin.o -L.
-L/export/build/gnu/gcc/build-x86_64-linux/gcc
-L/export/build/gnu/gcc/build-x86_64-linux/gcc/../lto-plugin/.libs
-L/lib/../lib64 -L/usr/lib/../lib64 /tmp/cckKXRh8.o -lgcc --as-needed -lgcc_s
--no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed
/export/build/gnu/gcc/build-x86_64-linux/gcc/crtend.o /usr/lib/../lib64/crtn.o
collect2 version 4.5.0 20100114 (experimental) (x86-64 Linux/ELF)
/export/build/gnu/gcc/build-x86_64-linux/gcc/collect-ld -plugin
/export/build/gnu/gcc/build-x86_64-linux/gcc/../lto-plugin/.libs/liblto_plugin.so
-plugin-opt=/export/build/gnu/gcc/build-x86_64-linux/gcc/lto-wrapper
-plugin-opt=/export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc -plugin-opt=-flto
-plugin-opt=-fuse-linker-plugin -plugin-opt=-mtune=generic -plugin-opt=-v
--eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2
/usr/lib/../lib64/crt1.o /usr/lib/../lib64/crti.o
/export/build/gnu/gcc/build-x86_64-linux/gcc/crtbegin.o -L.
-L/export/build/gnu/gcc/build-x86_64-linux/gcc
-L/export/build/gnu/gcc/build-x86_64-linux/gcc/../lto-plugin/.libs
-L/lib/../lib64 -L/usr/lib/../lib64 /tmp/cckKXRh8.o -lgcc --as-needed -lgcc_s
--no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed
/export/build/gnu/gcc/build-x86_64-linux/gcc/crtend.o /usr/lib/../lib64/crtn.o
/export/build/gnu/gcc/build-x86_64-linux/gcc/lto-wrapper
/export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc -flto -fuse-linker-plugin
-mtune=generic -v -fresolution /tmp/cc2aKmVt /tmp/cckKXRh8.o
Reading specs from /export/build/gnu/gcc/build-x86_64-linux/gcc/specs
COLLECT_GCC=/export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc
COLLECT_LTO_WRAPPER=/export/build/gnu/gcc/build-x86_64-linux/gcc/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /export/gnu/import/git/gcc/configure --enable-languages=c
--disable-bootstrap --prefix=/usr/gcc-4.5.0 --with-local-prefix=/usr/local
--with-plugin-ld=ld.gold --enable-gold
Thread model: posix
gcc version 4.5.0 20100114 (experimental) (GCC)
COLLECT_GCC_OPTIONS='-combine' '-c' '-o' '/tmp/cc8GpHku.lto.o'
'-fuse-linker-plugin' '-mtune=generic' '-v' '-fresolution'
 /export/build/gnu/gcc/build-x86_64-linux/gcc/lto1 -quiet -dumpbase cc2aKmVt
-mtune=generic -auxbase-strip /tmp/cc8GpHku.lto.o -version -fuse-linker-plugin
-fresolution @/tmp/ccgaL3ou -o /tmp/ccAe5LKd.s
GNU GIMPLE (GCC) version 4.5.0 20100114 (experimental)
(x86_64-unknown-linux-gnu)
        compiled by GNU C version 4.4.2 20091222 (Red Hat 4.4.2-20), GMP
version 4.3.1, MPFR version 2.4.2, MPC version 0.8
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
GNU GIMPLE (GCC) version 4.5.0 20100114 (experimental)
(x86_64-unknown-linux-gnu)
        compiled by GNU C version 4.4.2 20091222 (Red Hat 4.4.2-20), GMP
version 4.3.1, MPFR version 2.4.2, MPC version 0.8
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
COLLECT_GCC_OPTIONS='-combine' '-c' '-o' '/tmp/cc8GpHku.lto.o'
'-fuse-linker-plugin' '-mtune=generic' '-v' '-fresolution'
 /export/build/gnu/gcc/build-x86_64-linux/gcc/as -V -Qy -o /tmp/cc8GpHku.lto.o
/tmp/ccAe5LKd.s
GNU assembler version 2.20.51.0.5 (x86_64-unknown-linux-gnu) using BFD version
(Linux/GNU Binutils) 2.20.51.0.5.20100115
COMPILER_PATH=./:/export/build/gnu/gcc/build-x86_64-linux/gcc/:/export/build/gnu/gcc/build-x86_64-linux/gcc/../lto-plugin/.libs/
LIBRARY_PATH=/lib/../lib64/../lib64/:/usr/lib/../lib64/../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/lib/../lib64/:/usr/lib/../lib64/:./:/export/build/gnu/gcc/build-x86_64-linux/gcc/:/export/build/gnu/gcc/build-x86_64-linux/gcc/../lto-plugin/.libs/:/lib/../lib64/:/usr/lib/../lib64/:/lib/:/usr/lib/:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-combine' '-c' '-o' '/tmp/cc8GpHku.lto.o'
'-fuse-linker-plugin' '-mtune=generic' '-v' '-fresolution'
[hjl@gnu-6 gold-2]$


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42690


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

* [Bug lto/42690] Undefined reference errors with -flto -fuse-linker-plugin
  2010-01-11 15:23 [Bug lto/42690] New: Undefined reference errors with -flto -fuse-linker-plugin d dot g dot gorbachev at gmail dot com
                   ` (6 preceding siblings ...)
  2010-01-15 11:02 ` d dot g dot gorbachev at gmail dot com
@ 2010-01-15 11:02 ` d dot g dot gorbachev at gmail dot com
  2010-01-15 11:02 ` d dot g dot gorbachev at gmail dot com
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: d dot g dot gorbachev at gmail dot com @ 2010-01-15 11:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from d dot g dot gorbachev at gmail dot com  2010-01-15 11:02 -------
Created an attachment (id=19611)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=19611&action=view)
2. Configured w/o --disable-shared, linking with a static libgcc (with
-static).


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42690


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

* [Bug lto/42690] Undefined reference errors with -flto -fuse-linker-plugin
  2010-01-11 15:23 [Bug lto/42690] New: Undefined reference errors with -flto -fuse-linker-plugin d dot g dot gorbachev at gmail dot com
                   ` (7 preceding siblings ...)
  2010-01-15 11:02 ` d dot g dot gorbachev at gmail dot com
@ 2010-01-15 11:02 ` d dot g dot gorbachev at gmail dot com
  2010-01-15 11:03 ` d dot g dot gorbachev at gmail dot com
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: d dot g dot gorbachev at gmail dot com @ 2010-01-15 11:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from d dot g dot gorbachev at gmail dot com  2010-01-15 11:01 -------
Created an attachment (id=19610)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=19610&action=view)
1. Configured w/o --disable-shared, linking with a shared libgcc.

Output of gcc -v


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42690


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

* [Bug lto/42690] Undefined reference errors with -flto -fuse-linker-plugin
  2010-01-11 15:23 [Bug lto/42690] New: Undefined reference errors with -flto -fuse-linker-plugin d dot g dot gorbachev at gmail dot com
                   ` (5 preceding siblings ...)
  2010-01-15  4:26 ` hjl dot tools at gmail dot com
@ 2010-01-15 11:02 ` d dot g dot gorbachev at gmail dot com
  2010-01-15 11:02 ` d dot g dot gorbachev at gmail dot com
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: d dot g dot gorbachev at gmail dot com @ 2010-01-15 11:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from d dot g dot gorbachev at gmail dot com  2010-01-15 11:02 -------
Created an attachment (id=19612)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=19612&action=view)
3. Configured with --disable-shared, linking with a static libgcc.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42690


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

* [Bug lto/42690] Undefined reference errors with -flto -fuse-linker-plugin
  2010-01-11 15:23 [Bug lto/42690] New: Undefined reference errors with -flto -fuse-linker-plugin d dot g dot gorbachev at gmail dot com
                   ` (8 preceding siblings ...)
  2010-01-15 11:02 ` d dot g dot gorbachev at gmail dot com
@ 2010-01-15 11:03 ` d dot g dot gorbachev at gmail dot com
  2010-01-15 11:04 ` [Bug driver/42690] " d dot g dot gorbachev at gmail dot com
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: d dot g dot gorbachev at gmail dot com @ 2010-01-15 11:03 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from d dot g dot gorbachev at gmail dot com  2010-01-15 11:02 -------
Created an attachment (id=19613)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=19613&action=view)
4. Configured with --disable-shared, linking with a static libgcc (with
-static).


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42690


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

* [Bug driver/42690] Undefined reference errors with -flto -fuse-linker-plugin
  2010-01-11 15:23 [Bug lto/42690] New: Undefined reference errors with -flto -fuse-linker-plugin d dot g dot gorbachev at gmail dot com
                   ` (9 preceding siblings ...)
  2010-01-15 11:03 ` d dot g dot gorbachev at gmail dot com
@ 2010-01-15 11:04 ` d dot g dot gorbachev at gmail dot com
  2010-01-15 15:29 ` espindola at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: d dot g dot gorbachev at gmail dot com @ 2010-01-15 11:04 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from d dot g dot gorbachev at gmail dot com  2010-01-15 11:03 -------
GCC was configured with --disable-shared option. It seems that the driver does
not understand that --disable-shared implies static libgcc


-- 

d dot g dot gorbachev at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
          Component|lto                         |driver
         Resolution|WORKSFORME                  |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42690


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

* [Bug driver/42690] Undefined reference errors with -flto -fuse-linker-plugin
  2010-01-11 15:23 [Bug lto/42690] New: Undefined reference errors with -flto -fuse-linker-plugin d dot g dot gorbachev at gmail dot com
                   ` (10 preceding siblings ...)
  2010-01-15 11:04 ` [Bug driver/42690] " d dot g dot gorbachev at gmail dot com
@ 2010-01-15 15:29 ` espindola at gcc dot gnu dot org
  2010-01-16 16:56 ` d dot g dot gorbachev at gmail dot com
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: espindola at gcc dot gnu dot org @ 2010-01-15 15:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from espindola at gcc dot gnu dot org  2010-01-15 15:28 -------
(In reply to comment #11)
> GCC was configured with --disable-shared option. It seems that the driver does
> not understand that --disable-shared implies static libgcc
> 
That is correct. Currently we have

   %{static|static-libgcc:-plugin-opt=-pass-through=%(lto_libgcc)}     \
    %{static:-plugin-opt=-pass-through=-lc}     \

That is, --pass-through is only used for libgcc if -static or -static-libgcc is
given. For libgcc we could probably find out if we are using a static one or
not in a more accurate way.

For libc it is harder. The driver doesn't know that libc is static. It just
passes -lc to ld.

It might be possible to change what we test for. I think it would be OK to
always ask the plugin to pass libgcc and libc to the linker a second time *if
they are being used at all*. My understanding is that an unnecessary static
library will be ignored and a shared library will have no effect since it was
already used anyway. 

To implement this we should always pass -plugin-opt=-pass-through=%(lto_libgcc)
and -plugin-opt=-pass-through=-lc to the linker unless something like -nostdlib
is used.

What options other than -nostdlib prevent gcc from linking libgcc and libc in
the produced binary?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42690


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

* [Bug driver/42690] Undefined reference errors with -flto -fuse-linker-plugin
  2010-01-11 15:23 [Bug lto/42690] New: Undefined reference errors with -flto -fuse-linker-plugin d dot g dot gorbachev at gmail dot com
                   ` (11 preceding siblings ...)
  2010-01-15 15:29 ` espindola at gcc dot gnu dot org
@ 2010-01-16 16:56 ` d dot g dot gorbachev at gmail dot com
  2010-01-17  5:47 ` espindola at gcc dot gnu dot org
  2010-01-18 18:48 ` d dot g dot gorbachev at gmail dot com
  14 siblings, 0 replies; 16+ messages in thread
From: d dot g dot gorbachev at gmail dot com @ 2010-01-16 16:56 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #13 from d dot g dot gorbachev at gmail dot com  2010-01-16 16:55 -------
(In reply to comment #12)

> What options other than -nostdlib prevent gcc from linking libgcc and
> libc in the produced binary?

I know of -nodefaultlibs.

> To implement this we should always pass -plugin-opt=-pass-through=
> %(lto_libgcc) and -plugin-opt=-pass-through=-lc to the linker unless
> something like -nostdlib is used.

Wouldn't it be better to add %{fuse-linker-plugin:
-plugin-opt=-pass-through=...} to LIBGCC_SPEC and to LIB_SPEC?

However, the driver does not really know, whether we link with libgcc and/or
libc. Someone can use -nodefaultlibs together with -lc -lgcc and the linker
will still fail.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42690


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

* [Bug driver/42690] Undefined reference errors with -flto -fuse-linker-plugin
  2010-01-11 15:23 [Bug lto/42690] New: Undefined reference errors with -flto -fuse-linker-plugin d dot g dot gorbachev at gmail dot com
                   ` (12 preceding siblings ...)
  2010-01-16 16:56 ` d dot g dot gorbachev at gmail dot com
@ 2010-01-17  5:47 ` espindola at gcc dot gnu dot org
  2010-01-18 18:48 ` d dot g dot gorbachev at gmail dot com
  14 siblings, 0 replies; 16+ messages in thread
From: espindola at gcc dot gnu dot org @ 2010-01-17  5:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #14 from espindola at gcc dot gnu dot org  2010-01-17 05:47 -------
I don't think that in general we can support things like -nodefaultlibs -lc
-lgcc. Doing that with static libraries and lto is such an uncommon case that
it is probably OK to ask the user to also pass -Wl,-pass-through...

I am not familiar with the driver code, but if we already have SPEC stings that
are used only when linking libgcc or libc, that is the perfect place to add
%{fuse-linker-plugin: -plugin-opt=-pass-through=...}


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42690


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

* [Bug driver/42690] Undefined reference errors with -flto -fuse-linker-plugin
  2010-01-11 15:23 [Bug lto/42690] New: Undefined reference errors with -flto -fuse-linker-plugin d dot g dot gorbachev at gmail dot com
                   ` (13 preceding siblings ...)
  2010-01-17  5:47 ` espindola at gcc dot gnu dot org
@ 2010-01-18 18:48 ` d dot g dot gorbachev at gmail dot com
  14 siblings, 0 replies; 16+ messages in thread
From: d dot g dot gorbachev at gmail dot com @ 2010-01-18 18:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #15 from d dot g dot gorbachev at gmail dot com  2010-01-18 18:48 -------
Created an attachment (id=19649)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=19649&action=view)
Simple patch

It leaves -plugin-opt in LINK_COMMAND_SPEC, but I think it is not quite right,
as LIBGCC_SPEC and LIB_SPEC are redefined by many targets (and, for example,
choose libc or libc_p depending on -p / -pg / -profile).

GCC r155915 bootstrapped with this patch on i686-pc-linux-gnu with and without
--disable-shared option. It seems to work.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42690


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

end of thread, other threads:[~2010-01-18 18:48 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-11 15:23 [Bug lto/42690] New: Undefined reference errors with -flto -fuse-linker-plugin d dot g dot gorbachev at gmail dot com
2010-01-11 15:25 ` [Bug lto/42690] " d dot g dot gorbachev at gmail dot com
2010-01-12 16:30 ` espindola at gcc dot gnu dot org
2010-01-14 22:15 ` d dot g dot gorbachev at gmail dot com
2010-01-15  3:41 ` hjl dot tools at gmail dot com
2010-01-15  3:55 ` espindola at gcc dot gnu dot org
2010-01-15  4:26 ` hjl dot tools at gmail dot com
2010-01-15 11:02 ` d dot g dot gorbachev at gmail dot com
2010-01-15 11:02 ` d dot g dot gorbachev at gmail dot com
2010-01-15 11:02 ` d dot g dot gorbachev at gmail dot com
2010-01-15 11:03 ` d dot g dot gorbachev at gmail dot com
2010-01-15 11:04 ` [Bug driver/42690] " d dot g dot gorbachev at gmail dot com
2010-01-15 15:29 ` espindola at gcc dot gnu dot org
2010-01-16 16:56 ` d dot g dot gorbachev at gmail dot com
2010-01-17  5:47 ` espindola at gcc dot gnu dot org
2010-01-18 18:48 ` d dot g dot gorbachev at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).