This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Builtins-vs-libcalls-vs-optimised-away-vs-still-emitting-an-undefined-symbol-reference
- From: Ian Lance Taylor <iant at google dot com>
- To: "Dave Korn" <dave dot korn at artimi dot com>
- Cc: <gcc at gcc dot gnu dot org>
- Date: 24 Apr 2007 07:33:35 -0700
- Subject: Re: Builtins-vs-libcalls-vs-optimised-away-vs-still-emitting-an-undefined-symbol-reference
- References: <00b201c78666$c463ced0$2e08a8c0@CAM.ARTIMI.COM>
"Dave Korn" <dave.korn@artimi.com> writes:
> Although I'm seeing this on 3.3.3, it appears to be determined by the
> backend, so I think it's still reasonable to ask:
>
> I have some code that calls __builtin_ffs, but entirely on compile-time
> constants. When I compile it (using an inhouse custom ELF-target backend)
> with -O2, it gets totally optimised away, but the compiler still emits an
> undefined symbol reference to the library ffs() function:
>
> ---------------------------------<snip!>---------------------------------
> /tmp $ ${libexecdir}/3.3.3/cc1.exe -O2 - -o -
>
> int foo ()
> {
> return __builtin_ffs (32);
> }
>
> .file "<stdin>"
> foo .global _ffs
Is this really a reference? It just looks like a declaration. A
typical ELF assembler will not generate an undefined symbol merely
because it sees a .global pseudo-op.
It looks like this comes from an inappropriate call to
assemble_external. You should find out what is calling that for _ffs.
Ian