Hi all, attached patch + tarball contain enough magic to get a working clang for AMD64. I could like to get this into the tree to make it simpler to test and integrated the changes required for doing a (almost) full world build. Things like support for !x86 targets in clang etc can be provided incrementally as well. At the moment, I do not plan to import the upstream LLVM or clang sources. src/external/llvm/Makefile has a checkout target using svn to get the "proven" revision as specified in Makefile.inc. This avoids having to deal with regular imports and repo churn associated. Status is that with a bunch of other patches and some smaller hacks, the AMD64 release build finishes almost. The GCC libraries and bootxx are the primary issues. Joerg
Index: src/distrib/sets/lists/comp/mi
===================================================================
--- src/distrib/sets/lists/comp/mi
+++ src/distrib/sets/lists/comp/mi
@@ -11,10 +11,12 @@
./usr/bin/c++ comp-cxx-bin gcccmds
./usr/bin/c++filt comp-cxx-bin binutils
./usr/bin/c89 comp-c-bin
./usr/bin/c99 comp-c-bin
./usr/bin/cc comp-c-bin gcccmds
+./usr/bin/clang comp-c-bin
llvm
+./usr/bin/clang++ comp-c-bin llvm
./usr/bin/config comp-util-bin
./usr/bin/crunchgen comp-c-bin
./usr/bin/crunchide comp-c-bin
./usr/bin/ctfconvert comp-util-bin dtrace
./usr/bin/ctfdump comp-util-bin dtrace
@@ -44,10 +46,11 @@
./usr/bin/gprof comp-debug-bin
binutils
./usr/bin/lex comp-c-bin
./usr/bin/lint comp-c-bin
./usr/bin/lorder comp-util-bin
./usr/bin/luac comp-util-bin
+./usr/bin/llvm-tblgen comp-c-bin llvm
./usr/bin/menuc comp-c-bin
./usr/bin/mkstr comp-c-bin
./usr/bin/mkubootimage comp-util-bin
./usr/bin/msgattrib comp-c-bin
./usr/bin/msgc comp-c-bin
Index: src/distrib/sets/sets.subr
===================================================================
--- src/distrib/sets/sets.subr
+++ src/distrib/sets/sets.subr
@@ -219,10 +219,11 @@
# iscsi ${MKISCSI} != no
# kerberos ${MKKERBEROS} != no
# kmod ${MKKMOD} != no
# ldap ${MKLDAP} != no
# lint ${MKLINT} != no
+# llvm ${MKLLVM} != no
# lvm ${MKLVM} != no
# man ${MKMAN} != no
# manpages ${MKMANPAGES} != no
# manz ${MKMANZ} != no
# mdns ${MKMDNS} != no
Index: src/external/bsd/Makefile
===================================================================
--- src/external/bsd/Makefile
+++ src/external/bsd/Makefile
@@ -11,14 +11,17 @@
.if (${MKISCSI} != "no")
SUBDIR+= iscsi
.endif
.if (${MKLDAP} != "no")
SUBDIR+= openldap
+.endif
+.if (${MKLLVM} != "no")
+SUBDIR+= llvm
.endif
.if (${MKCRYPTO} != "no")
SUBDIR+= pkg_install ../../crypto/external/bsd
.endif
.if (${MKPCC} != "no")
SUBDIR+= pcc
.endif
.include <bsd.subdir.mk>
Index: src/share/mk/bsd.dep.mk
===================================================================
--- src/share/mk/bsd.dep.mk
+++ src/share/mk/bsd.dep.mk
@@ -55,12 +55,12 @@
.C.d .cc.d .cpp.d .cxx.d:
${_MKTARGET_CREATE}
${MKDEP} -f ${.TARGET} -- ${MKDEPFLAGS} \
${CXXFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \
- ${DESTDIR:D-nostdinc++ ${CPPFLAG_ISYSTEMXX} \
- ${DESTDIR}/usr/include/g++} \
+ ${HOSTLIB:U${DESTDIR:D-nostdinc++ ${CPPFLAG_ISYSTEMXX} \
+ ${DESTDIR}/usr/include/g++}} \
${CPPFLAGS} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
.endif # defined(SRCS) # }
##### Clean rules
Index: src/share/mk/bsd.lib.mk
===================================================================
--- src/share/mk/bsd.lib.mk
+++ src/share/mk/bsd.lib.mk
@@ -62,11 +62,12 @@
##### Build and install rules
MKDEP_SUFFIXES?= .o .po .pico .go .ln
# Use purely kernel private headers in rump builds
-.if !defined(RUMPKERNEL)
+# Skip NetBSD headers for the toolchain builds
+.if !defined(RUMPKERNEL) && !defined(HOSTLIB)
.if empty(CPPFLAGS:M-nostdinc)
CPPFLAGS+= ${DESTDIR:D-nostdinc ${CPPFLAG_ISYSTEM} ${DESTDIR}/usr/include}
.endif
.if empty(CXXFLAGS:M-nostdinc++)
CXXFLAGS+= ${DESTDIR:D-nostdinc++ ${CPPFLAG_ISYSTEMXX}
${DESTDIR}/usr/include/g++}
Index: src/share/mk/bsd.own.mk
===================================================================
--- src/share/mk/bsd.own.mk
+++ src/share/mk/bsd.own.mk
@@ -300,10 +300,11 @@
TOOL_SPARKCRC= ${TOOLDIR}/bin/${_TOOL_PREFIX}sparkcrc
TOOL_STAT= ${TOOLDIR}/bin/${_TOOL_PREFIX}stat
TOOL_STRFILE= ${TOOLDIR}/bin/${_TOOL_PREFIX}strfile
TOOL_SUNLABEL= ${TOOLDIR}/bin/${_TOOL_PREFIX}sunlabel
TOOL_TBL= ${TOOLDIR}/bin/${_TOOL_PREFIX}tbl
+TOOL_TBLGEN= ${TOOLDIR}/bin/${_TOOL_PREFIX}tblgen
TOOL_TIC= ${TOOLDIR}/bin/${_TOOL_PREFIX}tic
TOOL_UUDECODE= ${TOOLDIR}/bin/${_TOOL_PREFIX}uudecode
TOOL_VGRIND= ${TOOLDIR}/bin/${_TOOL_PREFIX}vgrind -f
TOOL_ZIC= ${TOOLDIR}/bin/${_TOOL_PREFIX}zic
@@ -378,10 +379,11 @@
TOOL_SPARKCRC= sparkcrc
TOOL_STAT= stat
TOOL_STRFILE= strfile
TOOL_SUNLABEL= sunlabel
TOOL_TBL= tbl
+TOOL_TBLGEN= llvm-tblgen
TOOL_TIC= tic
TOOL_UUDECODE= uudecode
TOOL_VGRIND= vgrind -f
TOOL_ZIC= zic
@@ -755,11 +757,11 @@
#
_MKVARS.no= \
MKBSDTAR MKCRYPTO_IDEA MKCRYPTO_MDC2 MKCRYPTO_RC5 MKDEBUG MKDEBUGLIB \
MKDTRACE MKEXTSRC \
MKMANDOC MKMANZ MKOBJDIRS \
- MKPCC MKPCCCMDS \
+ MKLLVM MKPCC MKPCCCMDS \
MKPIGZGZIP \
MKREPRO \
MKSOFTFLOAT MKSTRIPIDENT \
MKUNPRIVED MKUPDATE MKX11 MKZFS
.for var in ${_MKVARS.no}
Index: src/share/mk/bsd.prog.mk
===================================================================
--- src/share/mk/bsd.prog.mk
+++ src/share/mk/bsd.prog.mk
@@ -51,16 +51,19 @@
AFLAGS+= ${PIE_AFLAGS}
LDFLAGS+= ${PIE_LDFLAGS}
.endif
##### Default values
+.if !defined(HOSTLIB)
.if empty(CPPFLAGS:M-nostdinc)
CPPFLAGS+= ${DESTDIR:D-nostdinc ${CPPFLAG_ISYSTEM} ${DESTDIR}/usr/include}
.endif
.if empty(CXXFLAGS:M-nostdinc++)
CXXFLAGS+= ${DESTDIR:D-nostdinc++ ${CPPFLAG_ISYSTEMXX}
${DESTDIR}/usr/include/g++}
.endif
+.endif
+
CFLAGS+= ${COPTS}
OBJCFLAGS+= ${OBJCOPTS}
MKDEP_SUFFIXES?= .o .ln
# CTF preserve debug symbols
Index: src/tools/Makefile
===================================================================
--- src/tools/Makefile
+++ src/tools/Makefile
@@ -60,10 +60,20 @@
.WAIT disklabel \
.WAIT paxctl \
.WAIT fdisk \
.WAIT installboot \
pwd_mkdb stat strfile sunlabel zic
+
+.if ${MKLLVM} != "no"
+SUBDIR+= \
+ llvm .WAIT \
+ llvm-lib/libLLVMSupport .WAIT \
+ llvm-tblgen .WAIT \
+ llvm-include .WAIT \
+ llvm-lib .WAIT \
+ llvm-clang
+.endif
.if ${MKMAN} != "no" || ${MKDOC} != "no" || ${MKHTML} != "no"
. if ${MKGROFF} != "no"
SUBDIR+= groff
. endif
Attachment:
clang-base.tar.gz
Description: Binary data