This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: link time optimization issue
- From: Markus Trippelsdorf <markus at trippelsdorf dot de>
- To: Henrik Juul Pedersen <hjp at liab dot dk>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Tue, 13 May 2014 14:37:11 +0200
- Subject: Re: link time optimization issue
- Authentication-results: sourceware.org; auth=none
- References: <CABQZ+_T7sNns4FQ-=_+HWNJUOqActENJyM__WWixOt8QMxSCHg at mail dot gmail dot com>
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