[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#706490: kfreebsd-9: building with clang-3.2

Package: src:kfreebsd-9
Version: 9.0-10
Severity: wishlist
Tags: patch
User: debian-bsd@lists.debian.org
Usertags: kfreebsd
X-Debbugs-Cc: pkg-llvm-team@lists.alioth.debian.org


For future reference, attached is a patch that allows kfreebsd-9 (9.0)
to build with clang-3.2.  This might be useful as we currently have to
use gcc-4.6, that may not be available for long post-wheezy, and gcc-4.7
reportedly produced non-working kernel images.

I don't even know yet if the kernel image produced by clang-3.2 works,
but upstream are using clang as their default compiler now.

This patch addresses two build issues:

> ../../../amd64/acpica/acpi_wakecode.S:55:2: error: unexpected directive .code16

clang's built-in assembler does not support that feature yet, but we can
work around it with "-no-integrated-as" in CFLAGS (Clang-specific
option, not portable).

> clang -D__va_list=__builtin_va_list -isystem /usr/include/bsd -DLIBBSD_OVERLAY   -lbsd  -I. -I/home/steven/clang/kfreebsd-9-9.0/config -std=gnu99   -o config config.o main.o lang.o mkmakefile.o mkheaders.o mkoptions.o kernconf.o -ll -lsbuf
> main.o: In function `kernconfdump':
> main.c:(.text+0x95d): undefined reference to `___isoc99_sscanf'

This is very odd.  It didn't occur during the clang.debian.net test
build done on linux-amd64, so it may really be a kfreebsd headers bug.

It should be __isoc99_sscanf (two underscores only), but the extra
underscore is being prepended from the setting of __USER_LABEL_PREFIX__
(not sure where that is set...).

Adding "-D__USER_LABEL_PREFIX__= " to CFLAGS works around that issue.

Steven Chamberlain
Index: debian/control.in
--- debian/control.in	(revision 4393)
+++ debian/control.in	(working copy)
@@ -7,7 +7,7 @@
 Vcs-Svn: svn://svn.debian.org/glibc-bsd/trunk/kfreebsd-@major@/
 Build-Depends: debhelper (>= 5.0.0), bzip2, sharutils, flex-old | flex,
  freebsd-buildutils (>= 9),
- gcc-@gcc_version@, libdb-dev,
+ clang-@clang_version@, libdb-dev,
  libbsd-dev (>= 0.3.0), pkg-config,
  libsbuf-dev, libsbuf-dev (>= 8.2-2) | kfreebsd-kernel-headers (<< 0.56),
  freebsd-buildutils (>= 8.2-4) [any-mipsel],
Index: debian/rules
--- debian/rules	(revision 4393)
+++ debian/rules	(working copy)
@@ -22,7 +22,7 @@
 configfile	:= DEBCUSTOM
 abiname		:= 2
 ld_target	:= $(shell ld --help | sed -ne "s/[^ :]*: supported targets: \([^ ]*\) .*/\1/p")
-gcc_version	:= 4.6
+clang_version	:= 3.2
 ifeq ($(cpu), mipsel)
 kfreebsd_cpu	:= mips
@@ -43,7 +43,7 @@
 FLAVOR_DIR	:= flavor-$(version)-$(abiname)
 ORIG_DIR	:= kfreebsd-$(major)-$(tar_version)
 ORIG_TAR	:= kfreebsd-$(major)_$(tar_version).orig.tar.gz
-MAKE		:= make MACHINE_ARCH=$(kfreebsd_cpu) CC=gcc-$(gcc_version) WERROR=
+MAKE		:= make MACHINE_ARCH=$(kfreebsd_cpu) CC=clang-$(clang_version) WERROR=
 PATH		:= $(CURDIR)/config:/usr/lib/freebsd:$(PATH)
 # Disable install of *.ko.symbols files (their presence would trigger an
@@ -72,7 +72,7 @@
 		fi ; \
 		echo ; \
-	sed -e "s/@major@/$(major)/g" -e "s/@version@/$(version)/g" -e "s/@abiname@/$(abiname)/g" -e "s/@flavor@/$$flavor/g" -e "s/@gcc_version@/$(gcc_version)/g" \
+	sed -e "s/@major@/$(major)/g" -e "s/@version@/$(version)/g" -e "s/@abiname@/$(abiname)/g" -e "s/@flavor@/$$flavor/g" -e "s/@clang_version@/$(clang_version)/g" \
 		$(CURDIR)/debian/control.in > $(CURDIR)/debian/control
 	echo >> $(CURDIR)/debian/control
 	for arch in `ls $(CURDIR)/debian/arch/` ; do \
@@ -149,7 +147,7 @@
 config-stamp: src
 	rm -rf config
 	cp -af src/usr.sbin/config config
-	CFLAGS="-D__va_list=__builtin_va_list $(shell pkg-config --cflags libbsd-overlay) -lbsd" $(MAKE) -C config
+	CFLAGS="-D__va_list=__builtin_va_list $(shell pkg-config --cflags libbsd-overlay) -lbsd -no-integrated-as -D__USER_LABEL_PREFIX__= " $(MAKE) -C config
 	touch $@
 build-arch: $(foreach flavor,$(flavours),build-flavor-$(flavor)-stamp)

Reply to: