Building FreeBSD 8.0 with Clang on amd64 problem

I try to build FreeBSD with Clang and get following error

Code:
#make buildworld
.....
/usr/local/bin/clang -fpic -DPIC -O2 -pipe  -Wtypedef-redefinition -DMAXPAGESIZES=3 
-I/src/include -fPIC -I/src/r217821/lib/libc/include -I/src/r217821/lib/libc/../../include
-I/src/r217821/lib/libc/amd64 -DNLS  -D__DBINTERFACE_PRIVATE 
-I/src/r217821/lib/libc/../../contrib/gdtoa -DINET6 -I/usr/obj/src/r217821/lib/libc 
-I/src/r217821/lib/libc/resolv -D_ACL_PRIVATE -DPOSIX_MISTAKE 
-I/src/r217821/lib/libc/../../contrib/tzcode/stdtime -I/src/r217821/lib/libc/stdtime 
-I/src/r217821/lib/libc/locale -DBROKEN_DES -DPORTMAP -DDES_BUILTIN 
-I/src/r217821/lib/libc/rpc -DYP -DNS_CACHING -DSYMBOL_VERSIONING -std=gnu99 
-fstack-protector -Wsystem-headers -Wall -Wno-format-y2k -Wno-uninitialized 
-Wno-pointer-sign -c /src/r217821/lib/libc/string/wmemset.c -o wmemset.So
clang: warning: argument unused during compilation: '-fpic'
building shared library libc.so.7
/usr/obj/src/r217821/tmp/usr/bin/ld: pselect.So: relocation R_X86_64_32S can not be used when making a shared object; recompile with -fPIC
pselect.So: could not read symbols: Bad value
clang: error: linker command failed with exit code 1 (use -v to see invocation)
*** Error code 1

Stop in /src/r217821/lib/libc.
*** Error code 1

src.conf:
Code:
.if !defined(CC) || ${CC} == "cc"
CC=/usr/local/bin/clang
.endif
.if !defined(CXX) || ${CXX} == "c++"
CXX=/usr/local/bin/clang++
.endif
CFLAGS+=-Wtypedef-redefinition -DMAXPAGESIZES=3 -I/src/include -fPIC
CXXFLAGS+=-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -I/src/include -fPIC
NO_WERROR=
WERROR=
NO_FSCHG=

system and clang version:
Code:
# uname -a
FreeBSD mrt210 8.0-RELEASE FreeBSD 8.0-RELEASE #0: Sat Nov 21 15:02:08 UTC 2009     
root@mason.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  amd64

# clang -v
clang version 2.8 (branches/release_28)
Target: x86_64-unknown-freebsd8.0
Thread model: posix

So i think -fPIC option has no effect on Clang.
Has anyone any ideas how to fix this problem?
 
pselect.S compiles with following options:
Code:
/usr/local/bin/clang -O2 -pipe  -Wtypedef-redefinition -DMAXPAGESIZES=3 -I/src/include -fPIC 
-I/src/r217821/lib/libc/include -I/src/r217821/lib/libc/../../include -I/src/r217821/lib/libc/amd64 
-DNLS  -D__DBINTERFACE_PRIVATE -I/src/r217821/lib/libc/../../contrib/gdtoa -DINET6 
-I/usr/obj/src/r217821/lib/libc -I/src/r217821/lib/libc/resolv -D_ACL_PRIVATE -DPOSIX_MISTAKE 
-I/src/r217821/lib/libc/../../contrib/tzcode/stdtime -I/src/r217821/lib/libc/stdtime 
-I/src/r217821/lib/libc/locale -DBROKEN_DES -DPORTMAP -DDES_BUILTIN -I/src/r217821/lib/libc/rpc -DYP 
-DNS_CACHING -DSYMBOL_VERSIONING -std=gnu99 -fstack-protector -Wsystem-headers -Wall -Wno-format-y2k 
-Wno-uninitialized -Wno-pointer-sign  -c pselect.S
/usr/local/bin/clang -fpic -DPIC -O2 -pipe  -Wtypedef-redefinition -DMAXPAGESIZES=3 -I/src/include -fPIC
-I/src/r217821/lib/libc/include -I/src/r217821/lib/libc/../../include -I/src/r217821/lib/libc/amd64 
-DNLS  -D__DBINTERFACE_PRIVATE -I/src/r217821/lib/libc/../../contrib/gdtoa -DINET6 
-I/usr/obj/src/r217821/lib/libc -I/src/r217821/lib/libc/resolv -D_ACL_PRIVATE -DPOSIX_MISTAKE 
-I/src/r217821/lib/libc/../../contrib/tzcode/stdtime -I/src/r217821/lib/libc/stdtime 
-I/src/r217821/lib/libc/locale -DBROKEN_DES -DPORTMAP -DDES_BUILTIN -I/src/r217821/lib/libc/rpc 
-DYP -DNS_CACHING -DSYMBOL_VERSIONING -std=gnu99 -fstack-protector -Wsystem-headers -Wall 
-Wno-format-y2k -Wno-uninitialized -Wno-pointer-sign  -c pselect.S -o pselect.So
/usr/obj/src/r217821/tmp/usr/bin/ld: pselect.So: relocation R_X86_64_32S can not be used 
when making a shared object; recompile with -fPIC
pselect.So: could not read symbols: Bad value
 
If you're asking questions like this you are probably better off sticking with a -RELEASE or -STABLE.
 
Agree. If the terminology confuses you on that basic level, experimenting with compilers may be too early.

Moreover: clang is highly experimental on FreeBSD 9-CURRENT and not even remotely backported (or planned to be backported) to FreeBSD 8-STABLE.
 
Oh, ok, so I need to have FreeBSD 9.0 installed to build it with Clang.
I didn't noticed this:
Verify that "/usr/bin/clang -v" produces:
Code:
FreeBSD clang version 2.8 (branches/release_28 114020) 20100917
Target: i386-undermydesk-freebsd9.0
Thread model: posix

or, if you are on an amd64 system:
Code:
FreeBSD clang version 2.8 (branches/release_28 114020) 20100917
Target: x86_64-undermydesk-freebsd9.0
Thread model: posix
Thanks a lot!
I will try to do it on 9.0 version.
 
Keep in mind that -CURRENT might not even build at times. It may also be quite unstable.

That said, if you want to learn a lot then by all means, go for it.
 
Although not officially supported yet, clang can already be used to compile a working FreeBSD-8-STABLE kernel, and for most of the userland. It fails on compiling the system gcc over here.

The relocation of fPIC symbols looks weird to me, i never had that issue with clang or pcc. Are you getting the build directory cleaned before make is run?
 
xibo said:
The relocation of fPIC symbols looks weird to me, i never had that issue with clang or pcc. Are you getting the build directory cleaned before make is run?
Yes.
I run
rm -rf /usr/obj/*
and
make clean
before each new make buildworld
 
Back
Top