This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: link time optimization issue


On 2014.05.13 at 13:02 +0200, Henrik Juul Pedersen wrote:
> Hi,
> 
> I've been experimenting with link time optimization with GCC, and have
> run into an issue with some existing code:
> 
> == Test scenario ==
> - foo.c:
> int foo ( void ) {
>     return 3;
> }
> 
> - bar.c:
> #include <stdio.h>
> 
> int foo( void );
> 
> int main ( void ) {
>     printf("Foo returns: %d\n", foo());
>     return 0;
> }
> 
> == Compilation ==
> gcc -flto -O2 -c foo.c
> ar rcs libfoo.a foo.o
> gcc -flto -O2 -L. bar.c -lfoo -o myprog
> /tmp/ccGcDjka.ltrans0.ltrans.o: In function `main':
> ccGcDjka.ltrans0.o:(.text+0x5): undefined reference to `foo'
> collect2: error: ld returned 1 exit status

See: https://gcc.gnu.org/wiki/LinkTimeOptimizationFAQ

-- 
Markus


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]