How can I build Google V8 on FreeBSD with clang?

2

1

I'm trying to build Google's V8 on FreeBSD 9.1 using clang and running into the following error:

/usr/bin/ld: final link failed: Nonrepresentable section on output
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[1]: *** [/root/v8/out/x64.release/cctest] Error 1
gmake[1]: Leaving directory `/root/v8/out'
gmake: *** [x64.release] Error 2

I needed to use gmake rather than make, and I added the following to use clang:

setenv CC /usr/bin/clang
setenv CXX /usr/bin/clang++
setenv GYP_DEFINES "clang=1"

Some version info:

# clang -v
FreeBSD clang version 3.1 (branches/release_31 156863) 20120523
Target: x86_64-unknown-freebsd9.0
Thread model: posix
# gmake -v
GNU Make 3.82
Built for amd64-portbld-freebsd9.1

command used to checkout v8 code:

# svn checkout http://v8.googlecode.com/svn/trunk/ v8
# uname -a
FreeBSD thug 9.1-RC3 FreeBSD 9.1-RC3 #0 r242324: Tue Oct 30 00:58:57 UTC 2012     root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  amd64

What is causing this linking error?

Utkonos

Posted 2012-12-10T19:04:16.900

Reputation: 23

Answers

1

FreeBSD has version 3.18.5 available in the ports system.

If that isn't new enough for you, at least look at /usr/ports/lang/v8/Makefile. It seems v8 needs some special options, see the following excerpt from the port Makefile:

ALL_TARGET=     native
MAKE_ARGS=      library=shared

.include <bsd.port.pre.mk>
.if ${CC:T:Mclang} == "clang" || ${CXX:T:Mclang++} == "clang++" || ${OSVERSION} >= 1000024
_CLANG!=        clang --version | ${HEAD} -1 | ${SED} -e 's/.*clang version \([0-9]\)\.\([0-9]\).*/\1\2/'
MAKE_ENV+=      LINK=clang++
CFLAGS+=        -Wno-unused-private-field
.if ${_CLANG} >= 33
CFLAGS+=        -Wno-nested-anon-types -Wno-unused-function
.endif
.else
MAKE_ARGS+=     strictaliasing=off
USE_GCC=        any
.endif

For your version of clang, it seems you need to add -Wno-unused-private-field to CFLAGS. And you'll need to specify a couple of extra arguments to make; library=shared and strictaliasing=off

Roland Smith

Posted 2012-12-10T19:04:16.900

Reputation: 1 712