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



             Bug #: 55937

           Summary: lto hides possible link issues

    Classification: Unclassified

           Product: gcc

           Version: 4.7.2

            Status: UNCONFIRMED

          Severity: minor

          Priority: P3

         Component: lto

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: bo...@fau.re





When compiling the following on linux where gethrtime is not defined, it links

with -O1 but not with -O0:



char gethrtime ();

char (*f) () = gethrtime;

int main () {

    return f != gethrtime;

}



'gcc-4.7.2 -O1 -flto -o conftest conftest.c' works, while 'gcc-4.7.2 -O0 -flto

-o conftest conftest.c' outputs:

/tmp/ccT5O10r.ltrans0.ltrans.o: In function `main':

ccT5O10r.ltrans0.o:(.text+0xd): undefined reference to `gethrtime'

/tmp/ccT5O10r.ltrans0.ltrans.o:(.data+0x0): undefined reference to `gethrtime'

collect2: error: ld returned 1 exit status



Compiling with -fwhole-program, it would fail as expected:

'gcc-4.7.2 -O1 -fwhole-program -o conftest conftest.c' outputs:

/tmp/ccaHfhb0.o:(.rodata+0x0): undefined reference to `gethrtime'

collect2: error: ld returned 1 exit status



That code is actually produced by the following autoconf macro while

configuring erlang-R15B02:

AC_CHECK_FUNC(gethrtime)

The macro would include <limits.h> but since it's not defined, the same

behaviour is shown without that include.

Reply via email to