[LLVMdev] "multiple definition of .. " in clang 2.8

1,224 views
Skip to first unread message

Xinfinity

unread,
Oct 29, 2010, 8:13:46 AM10/29/10
to llv...@cs.uiuc.edu

Hi,
I tried to run the SPEC benchmark suite SPECCPU 2006 with llvm and clang
2.8. When building the perlbench sources I get these errors (see below) for
all the source files. I used a config file (
http://old.nabble.com/file/p30085184/llvm.cfg llvm.cfg ) where I specify
clang as the compiler. I verified the same sources with llvm-gcc and it
works fine. Also, I verified the sjeng benchmark from the same suite and it
builds and executes correctly with both front-ends.
I have run these SPEC benches with llvm 2.7 using clang without any
problems, but in 2.8 I get these errors. I have tested it both with the llvm
2.8 release version and with the svn version, all of them compiled from
sources. I tried recompiling clang and llvm to make sure they were not
mis-compiled, but it is all the same.

I have a copy of llvm 2.7 on my machine, but I specify the path to the 2.8
executables in my scripts and config files.
Are there any conflicts between different versions, or is it possible to be
a bug in clang?

Thank you,
Alexandra


And here is the error:

Hostname.o: In function `gnu_dev_major':
Hostname.c:(.text+0x0): multiple definition of `gnu_dev_major'
av.o:av.c:(.text+0x0): first defined here
Hostname.o: In function `gnu_dev_minor':
Hostname.c:(.text+0x20): multiple definition of `gnu_dev_minor'
av.o:av.c:(.text+0x20): first defined here
Hostname.o: In function `gnu_dev_makedev':
Hostname.c:(.text+0x40): multiple definition of `gnu_dev_makedev'
av.o:av.c:(.text+0x40): first defined here
Hostname.o: In function `tolower':
Hostname.c:(.text+0x80): multiple definition of `tolower'
av.o:av.c:(.text+0x80): first defined here
Hostname.o: In function `toupper':
Hostname.c:(.text+0xb0): multiple definition of `toupper'
av.o:av.c:(.text+0xb0): first defined here
Hostname.o: In function `atof':
Hostname.c:(.text+0xe0): multiple definition of `atof'
av.o:av.c:(.text+0xe0): first defined here
Hostname.o: In function `atoi':
Hostname.c:(.text+0xf0): multiple definition of `atoi'
av.o:av.c:(.text+0xf0): first defined here
Hostname.o: In function `atol':
Hostname.c:(.text+0x110): multiple definition of `atol'
av.o:av.c:(.text+0x110): first defined here
Hostname.o: In function `atoll':
Hostname.c:(.text+0x130): multiple definition of `atoll'
av.o:av.c:(.text+0x130): first defined here
Hostname.o: In function `__strcspn_c1':
Hostname.c:(.text+0x150): multiple definition of `__strcspn_c1'
av.o:av.c:(.text+0x150): first defined here
Hostname.o: In function `__strcspn_c2':
Hostname.c:(.text+0x180): multiple definition of `__strcspn_c2'
av.o:av.c:(.text+0x180): first defined here
Hostname.o: In function `__strcspn_c3':
Hostname.c:(.text+0x1b0): multiple definition of `__strcspn_c3'
av.o:av.c:(.text+0x1b0): first defined here
Hostname.o: In function `__strspn_c1':
Hostname.c:(.text+0x1e0): multiple definition of `__strspn_c1'
av.o:av.c:(.text+0x1e0): first defined here
Hostname.o: In function `__strspn_c2':
Hostname.c:(.text+0x200): multiple definition of `__strspn_c2'
av.o:av.c:(.text+0x200): first defined here
Hostname.o: In function `__strspn_c3':
Hostname.c:(.text+0x230): multiple definition of `__strspn_c3'
av.o:av.c:(.text+0x230): first defined here
Hostname.o: In function `__strpbrk_c2':
Hostname.c:(.text+0x260): multiple definition of `__strpbrk_c2'
av.o:av.c:(.text+0x260): first defined here
Hostname.o: In function `__strpbrk_c3':
Hostname.c:(.text+0x290): multiple definition of `__strpbrk_c3'
av.o:av.c:(.text+0x290): first defined here
Hostname.o: In function `__strtok_r_1c':
Hostname.c:(.text+0x2d0): multiple definition of `__strtok_r_1c'
av.o:av.c:(.text+0x2d0): first defined here
Hostname.o: In function `__strsep_1c':
Hostname.c:(.text+0x320): multiple definition of `__strsep_1c'
av.o:av.c:(.text+0x320): first defined here
Hostname.o: In function `__strsep_2c':
Hostname.c:(.text+0x360): multiple definition of `__strsep_2c'
av.o:av.c:(.text+0x360): first defined here
Hostname.o: In function `__strsep_3c':
Hostname.c:(.text+0x3b0): multiple definition of `__strsep_3c'
av.o:av.c:(.text+0x3b0): first defined here
Hostname.o: In function `__cmsg_nxthdr':
Hostname.c:(.text+0x400): multiple definition of `__cmsg_nxthdr'
av.o:av.c:(.text+0x400): first defined here
Hostname.o: In function `stat':
Hostname.c:(.text+0x450): multiple definition of `stat'
av.o:av.c:(.text+0x450): first defined here
Hostname.o: In function `lstat':
Hostname.c:(.text+0x470): multiple definition of `lstat'
av.o:av.c:(.text+0x470): first defined here
Hostname.o: In function `fstat':
Hostname.c:(.text+0x490): multiple definition of `fstat'
av.o:av.c:(.text+0x490): first defined here
Hostname.o: In function `fstatat':
Hostname.c:(.text+0x4b0): multiple definition of `fstatat'
av.o:av.c:(.text+0x4b0): first defined here
Hostname.o: In function `mknod':
Hostname.c:(.text+0x4d0): multiple definition of `mknod'
av.o:av.c:(.text+0x4d0): first defined here
Hostname.o: In function `mknodat':
Hostname.c:(.text+0x500): multiple definition of `mknodat'
av.o:av.c:(.text+0x500): first defined here
Hostname.o: In function `strtoimax':
Hostname.c:(.text+0x530): multiple definition of `strtoimax'
av.o:av.c:(.text+0x530): first defined here
Hostname.o: In function `strtoumax':
Hostname.c:(.text+0x540): multiple definition of `strtoumax'
av.o:av.c:(.text+0x540): first defined here
Hostname.o: In function `wcstoimax':
Hostname.c:(.text+0x550): multiple definition of `wcstoimax'
av.o:av.c:(.text+0x550): first defined here
Hostname.o: In function `wcstoumax':
Hostname.c:(.text+0x560): multiple definition of `wcstoumax'
av.o:av.c:(.text+0x560): first defined here
Hostname.o: In function `vprintf':
Hostname.c:(.text+0x570): multiple definition of `vprintf'
av.o:av.c:(.text+0x570): first defined here
Hostname.o: In function `getchar':
Hostname.c:(.text+0x590): multiple definition of `getchar'
av.o:av.c:(.text+0x590): first defined here
Hostname.o: In function `fgetc_unlocked':
Hostname.c:(.text+0x5b0): multiple definition of `fgetc_unlocked'
av.o:av.c:(.text+0x5b0): first defined here
Hostname.o: In function `getc_unlocked':
Hostname.c:(.text+0x5e0): multiple definition of `getc_unlocked'
av.o:av.c:(.text+0x5e0): first defined here
Hostname.o: In function `getchar_unlocked':
Hostname.c:(.text+0x610): multiple definition of `getchar_unlocked'
av.o:av.c:(.text+0x610): first defined here
Hostname.o: In function `putchar':
Hostname.c:(.text+0x640): multiple definition of `putchar'
av.o:av.c:(.text+0x640): first defined here
Hostname.o: In function `fputc_unlocked':
Hostname.c:(.text+0x660): multiple definition of `fputc_unlocked'
av.o:av.c:(.text+0x660): first defined here
Hostname.o: In function `putc_unlocked':
Hostname.c:(.text+0x690): multiple definition of `putc_unlocked'
av.o:av.c:(.text+0x690): first defined here
Hostname.o: In function `putchar_unlocked':
Hostname.c:(.text+0x6c0): multiple definition of `putchar_unlocked'
av.o:av.c:(.text+0x6c0): first defined here
Hostname.o: In function `feof_unlocked':
Hostname.c:(.text+0x700): multiple definition of `feof_unlocked'
av.o:av.c:(.text+0x700): first defined here
Hostname.o: In function `ferror_unlocked':
Hostname.c:(.text+0x710): multiple definition of `ferror_unlocked'
av.o:av.c:(.text+0x710): first defined here
Hostname.o: In function `__signbitf':
Hostname.c:(.text+0x720): multiple definition of `__signbitf'
av.o:av.c:(.text+0x720): first defined here
Hostname.o: In function `__signbit':
Hostname.c:(.text+0x730): multiple definition of `__signbit'
av.o:av.c:(.text+0x730): first defined here
Hostname.o: In function `__signbitl':
Hostname.c:(.text+0x740): multiple definition of `__signbitl'
av.o:av.c:(.text+0x740): first defined here

--
View this message in context: http://old.nabble.com/%22multiple-definition-of-..-%22--in-clang-2.8-tp30085184p30085184.html
Sent from the LLVM - Dev mailing list archive at Nabble.com.

_______________________________________________
LLVM Developers mailing list
LLV...@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

Xinfinity

unread,
Nov 2, 2010, 12:56:52 PM11/2/10
to llv...@cs.uiuc.edu

It seems that the problem occurs from the optimization level. In the 2.7
version I was using -O0 and in 2.8 I tested the same benchmarks with -O3.

clang -O0 works fine, while clang -O3 makes redefinitions (probably it is
related to inlining) of the functions from stdlib.h, math.h and some other
libraries. To give one example, function atoi is defined in the generated
*.ll file:

define i32 @atoi(i8* %__nptr) nounwind inlinehint {
entry:
%call = tail call i64 @strtol(i8* nocapture %__nptr, i8** null, i32 10)
nounwind readonly
%conv = trunc i64 %call to i32
ret i32 %conv
}

although it is not defined in the original C file.

And clang redefines it in all the *.ll files it generates, from each C file
in the perlbench (SPEC CPU 2006).

Similarly for all the other functions, which appear in the end to be
redefined and give errors.

Am I on the right track with this errors? I need to use the -O3 optimization
level in my tests, so how can I avoid this problem?

Alexandra
--
View this message in context: http://old.nabble.com/%22multiple-definition-of-..-%22--in-clang-2.8-tp30085184p30115556.html

John McCall

unread,
Nov 2, 2010, 1:22:02 PM11/2/10
to Xinfinity, clang-dev Developers, llvmdev@cs.uiuc.edu Mailing List
On Nov 2, 2010, at 9:56 AM, Xinfinity wrote:
> It seems that the problem occurs from the optimization level. In the 2.7
> version I was using -O0 and in 2.8 I tested the same benchmarks with -O3.

For the record, this post is more appropriate for cfe-dev.

> clang -O0 works fine, while clang -O3 makes redefinitions (probably it is
> related to inlining) of the functions from stdlib.h, math.h and some other
> libraries. To give one example, function atoi is defined in the generated
> *.ll file:

Please file a bug (http://llvm.org/bugs) with some preprocessed source. It
looks like your standard headers are doing something very strange. Can
you tell us something about your system (architecture, OS, distribution)?

John.

Dale Johannesen

unread,
Nov 3, 2010, 4:13:46 PM11/3/10
to Xinfinity, llvmdev Mailing List
It appears you filed PR 8538 about this, but didn't cc yourself.  You should look at it; I don't think this is a clang problem.
It seems that the problem occurs from the optimization level. In the 2.7
version I was using -O0 and in 2.8 I tested the same benchmarks with -O3.

clang -O0 works fine, while clang -O3 makes redefinitions (probably it is
related to inlining) of the functions from stdlib.h, math.h and some other
libraries. To give one example, function atoi is defined in the generated
*.ll file: 

define i32 @atoi(i8* %__nptr) nounwind inlinehint {
entry:
  %call = tail call i64 @strtol(i8* nocapture %__nptr, i8** null, i32 10)
nounwind readonly
  %conv = trunc i64 %call to i32
  ret i32 %conv
}

although it is not defined in the original C file.

And clang redefines it in all the *.ll files it generates, from each C file
in the perlbench (SPEC CPU 2006).

Similarly for all the other functions, which appear in the end to be
redefined and give errors.

Am I on the right track with this errors? I need to use the -O3 optimization
level in my tests, so how can I avoid this problem?

Alexandra
-- 

Xinfinity

unread,
Nov 4, 2010, 6:59:26 AM11/4/10
to llv...@cs.uiuc.edu

Thanks, I receive the comments and I've seen it.
I tested it and you are right, it works with std=gnu89. I have checked it
before with std=c89 and it didn't work, but it looks like gnu89 is the
solution.

Alexandra

> _______________________________________________
> LLVM Developers mailing list
> LLV...@cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>

--
View this message in context: http://old.nabble.com/%22multiple-definition-of-..-%22--in-clang-2.8-tp30126502p30130852.html


Sent from the LLVM - Dev mailing list archive at Nabble.com.

_______________________________________________

Reply all
Reply to author
Forward
0 new messages