[LLVMbugs] [Bug 2614] New: Redefined symbols with llvm-gcc with -std=c99 and -O1 ( or higher)

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Thu Jul 31 00:52:10 PDT 2008


           Summary: Redefined symbols with llvm-gcc with -std=c99 and -O1
                    (or higher)
           Product: tools
           Version: 2.3
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: llvm-gcc
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: llvm at assumetheposition.nl
                CC: llvmbugs at cs.uiuc.edu

Given two very simple .c files:

#include <stdlib.h>

main(int argc, char **argv)

#include <stdlib.h>

If I compile each of these with plain gcc using -std=c99 and -O1 followed by
linking them, all is well. But if I replace gcc with llvm-gcc I get multiply
defined symbols:

llvm-gcc -c -O1 -std=c99                 main.c
llvm-gcc -c -O1 -std=c99                 module.c
llvm-gcc -o main main.o module.o
module.o(.text+0x0): In function `strtod':
: multiple definition of `strtod'
main.o(.text+0x0): first defined here
module.o(.text+0x30): In function `strtoull':
: multiple definition of `strtoull'
main.o(.text+0x40): first defined here
module.o(.text+0x60): In function `strtoll':
: multiple definition of `strtoll'
main.o(.text+0x70): first defined here
module.o(.text+0x90): In function `strtold':
: multiple definition of `strtold'
main.o(.text+0xa0): first defined here
module.o(.text+0xc0): In function `strtof':

Looking at the assembly output it seems the string functions get pulled into
both modules and therefore clash. E.g. llvm-gcc -S -O1 -std=c99 module.c

    .align  16
    .globl  strtod
    .type   strtod, at function
    pushl   %ebp
    movl    %esp, %ebp
    subl    $16, %esp
    movl    12(%ebp), %ecx
    movl    %ecx, 4(%esp)
    movl    8(%ebp), %ecx
    movl    %ecx, (%esp)
    movl    $0, 8(%esp)
    call    __strtod_internal
    addl    $16, %esp
    popl    %ebp
    .size   strtod, .-strtod

    .align  16
    .globl  strtoull
    .type   strtoull, at function
    pushl   %ebp
    movl    %esp, %ebp
    subl    $16, %esp
    movl    16(%ebp), %ecx
    movl    %ecx, 8(%esp)
    movl    12(%ebp), %ecx
    movl    %ecx, 4(%esp)
    movl    8(%ebp), %ecx
    movl    %ecx, (%esp)
    movl    $0, 12(%esp)
    call    __strtoull_internal
    addl    $16, %esp
    popl    %ebp
    .size   strtoull, .-strtoull


while module.s also contains the exact same functions.

Running llvm-gcc -S -O1 -std=c99 module.c (i.e. without the c99 flag) produces

        .section        .note.GNU-stack,"", at progbits
        .ident  "GCC: (GNU) 4.2.1 (Based on Apple Inc. build 5555) (LLVM build

Using -std=c99 without any optimization (-O0) also produces the same output
(jus t the two lines).

This is on a Fedora Core 4 system (whose gcc version is 4.0.2), with LLVM 2.3
and the precompiled RHEL4 llvm-gcc-4.2 binaries.

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list