# Can not compile VirtualBox-OSE with clang



## miracle20003 (Jul 2, 2012)

[CMD=""] uname -an [/CMD]

```
FreeBSD Setp-By-Setp 9.0-STABLE FreeBSD 9.0-STABLE #0 r237949M: Mon Jul  2 16:07:13 CST 2012
root@Setp-By-Setp:/usr/obj/usr/src_9/sys/XXIXX  i38
```

Here is *m*y /etc/make.conf:

```
.if ${.CURDIR:M/usr/src} || ${.CURDIR:M/usr/src/*} || ${.CURDIR:M/usr/obj} || ${.CURDIR:M/usr/obj/*} || ${.CURDIR:M/sys} || ${.CURDIR:M/sys/*}
CFLAGS+= -D_FORTIFY_SOURCE=2
.if !defined(CPP) || ${CPP} == "cpp"
CPP=clang-cpp
.endif
.endif

.if !defined(CC) || ${CC} == "cc"
CC=clang
.endif
.if !defined(CXX) || ${CXX} == "c++"
CXX=clang++
.endif
WITH_CLANG=YES
WITH_CLANG_EXTRAS=YES 
#CC=clang
#CXX=clang++
#CPP=clang-cpp
WITH_BIND_LIBS=YES
WITH_BIND_SIGCHASE=YES
WITH_BIND_LARGE_FILE=YES 
WITH_IDEA=YES
WITH_HESIOD=YES 
NO_WERROR=
WERROR=
WITH_LIBCPLUSPLUS=yes
NO_FSCHG=

CPUTYPE?=athlon64
#KERNCONF=Kernel
#CPUTYPE?=
MAKE_JOBS_NUMBER=4
```
error.log:

```
In file included from /work/ports/emulators/virtualbox-ose/work/VirtualBox-4.1.16/src/VBox/VMM/VMMR3/SSM.cpp:150:
/work/ports/emulators/virtualbox-ose/work/VirtualBox-4.1.16/src/VBox/VMM/include/SSMInternal.h:251:1: warning: using extended field designator is an extension [-pedantic,-Wextended-offsetof]
AssertCompile2MemberOffsets(SSMUNIT, u.Common.pvKey,       u.External.pvUser);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/work/ports/emulators/virtualbox-ose/work/VirtualBox-4.1.16/include/iprt/assert.h:396:19: note: expanded from macro 'AssertCompile2MemberOffsets'
    AssertCompile(__builtin_offsetof(type, member1) == __builtin_offsetof(type, member2))
                  ^
/work/ports/emulators/virtualbox-ose/work/VirtualBox-4.1.16/include/iprt/assert.h:312:49: note: expanded from macro 'AssertCompile'
# define AssertCompile(expr)    AssertCompileNS(expr)
                                                ^
/work/ports/emulators/virtualbox-ose/work/VirtualBox-4.1.16/include/iprt/assert.h:299:97: note: expanded from macro 'AssertCompileNS'
# define AssertCompileNS(expr)  extern int RTASSERTVAR[1] __attribute__((unused)), RTASSERTVAR[(expr) ? 1 : 0] __attribute__((unused))
                                                                                                ^~~~
In file included from /work/ports/emulators/virtualbox-ose/work/VirtualBox-4.1.16/src/VBox/VMM/VMMR3/SSM.cpp:150:
/work/ports/emulators/virtualbox-ose/work/VirtualBox-4.1.16/src/VBox/VMM/include/SSMInternal.h:251:1: warning: using extended field designator is an extension [-pedantic,-Wextended-offsetof]
AssertCompile2MemberOffsets(SSMUNIT, u.Common.pvKey,       u.External.pvUser);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/work/ports/emulators/virtualbox-ose/work/VirtualBox-4.1.16/include/iprt/assert.h:396:56: note: expanded from macro 'AssertCompile2MemberOffsets'
    AssertCompile(__builtin_offsetof(type, member1) == __builtin_offsetof(type, member2))
                                                       ^
/work/ports/emulators/virtualbox-ose/work/VirtualBox-4.1.16/include/iprt/assert.h:312:49: note: expanded from macro 'AssertCompile'
# define AssertCompile(expr)    AssertCompileNS(expr)
                                                ^
/work/ports/emulators/virtualbox-ose/work/VirtualBox-4.1.16/include/iprt/assert.h:299:97: note: expanded from macro 'AssertCompileNS'
# define AssertCompileNS(expr)  extern int RTASSERTVAR[1] __attribute__((unused)), RTASSERTVAR[(expr) ? 1 : 0] __attribute__((unused))
                                                                                                ^~~~
78 warnings generated.
kBuild: Compiling NetBiosBin - /work/ports/emulators/virtualbox-ose/work/VirtualBox-4.1.16/src/VBox/Devices/PC/Etherboot-src/arch/i386/prefix/romprefix.S
clang: warning: argument unused during compilation: '-fstrength-reduce'
/work/ports/emulators/virtualbox-ose/work/VirtualBox-4.1.16/src/VBox/Devices/PC/Etherboot-src/arch/i386/prefix/romprefix.S:46:9: error: .code16 not supported yet
 .code16
        ^
/work/ports/emulators/virtualbox-ose/work/VirtualBox-4.1.16/src/VBox/Devices/PC/Etherboot-src/arch/i386/prefix/romprefix.S:47:2: warning: ignoring directive for now
 .arch i386
 ^
kmk: *** [/work/ports/emulators/virtualbox-ose/work/VirtualBox-4.1.16/out/freebsd.x86/release/obj/pciprefix.o] Error 1
kmk: *** Waiting for unfinished jobs....
61 warnings generated.
kmk: *** Exiting with status 2
*** [do-build] Error code 2

Stop in /work/ports/emulators/virtualbox-ose.
*** [install] Error code 1

Stop in /work/ports/emulators/virtualbox-ose.
```

How to fix it? Thanks.


----------



## kpa (Jul 2, 2012)

Please see http://wiki.freebsd.org/PortsAndClang, especially the part "If you're interested in helping". Clang is not yet in a state where it can fully replace the old gcc(1) so if you're not interested in figuring out how to fix this type of problems yourself you should compile the problem ports with the base system gcc(1).


----------

