changeset 764:fc7a2268d9a6

core/grub: fix build with llvm, but still requires binutils
author David Demelier <markand@malikania.fr>
date Thu, 08 Aug 2019 20:55:00 +0200
parents 9d28984d1345
children 859f76ffb512
files core/grub/grub.sh core/grub/patch-clang.patch
diffstat 2 files changed, 49 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/core/grub/grub.sh	Thu Aug 08 20:50:00 2019 +0200
+++ b/core/grub/grub.sh	Thu Aug 08 20:55:00 2019 +0200
@@ -21,15 +21,15 @@
 PKGLICENSE="GPLv3+"
 PKGSUMMARY="GNU boot loader"
 PKGDOWNLOAD="ftp://ftp.gnu.org/gnu/$PKGNAME/$PKGNAME-$PKGVERSION.tar.xz"
-PKGDEPENDS="core/lvm2 dev/bison dev/flex lib/linux-headers"
+PKGDEPENDS="core/lvm2 dev/binutils:build dev/bison dev/flex lib/linux-headers"
 PKGOPTIONS="LZMA NLS"
 
 : ${CHOST:=$(uname -m)-linux-musl}
 : ${CBUILD:=$(uname -m)-linux-musl}
 : ${CTARGET:=$(uname -m)-linux-musl}
-: ${CC:=gcc}
+: ${CC:=clang}
 : ${CFLAGS:=-O2}
-: ${CXX:=g++}
+: ${CXX:=clang++}
 : ${CXXFLAGS:=-O2}
 : ${LDFLAGS:=}
 : ${LIBS:=}
@@ -59,11 +59,30 @@
 build_grub()
 {
 	mkdir build && cd build
-
+	BUILD_CC="$CC" \
+	BUILD_CFLAGS="$CFLAGS" \
+	BUILD_CXX="$CXX" \
+	BUILD_CXXFLAGS="$CXXFLAGS" \
+	BUILD_NM=/libexec/bin/binutils-nm \
+	BUILD_OBJCOPY=/libexec/bin/binutils-objcopy \
+	BUILD_RANLIB=/libexec/bin/binutils-ranlib \
+	BUILD_STRIP=/libexec/bin/binutils-strip \
 	CC="$CC" \
 	CFLAGS="$CFLAGS" \
 	CXX="$CXX" \
 	CXXFLAGS="$CXXFLAGS" \
+	NM=/libexec/bin/binutils-nm \
+	OBJCOPY=/libexec/bin/binutils-objcopy \
+	RANLIB=/libexec/bin/binutils-ranlib \
+	STRIP=/libexec/bin/binutils-strip \
+	TARGET_CC="$CC" \
+	TARGET_CFLAGS="$CFLAGS" \
+	TARGET_CXX="$CXX" \
+	TARGET_CXXFLAGS="$CXXFLAGS" \
+	TARGET_NM=/libexec/bin/binutils-nm \
+	TARGET_OBJCOPY=/libexec/bin/binutils-objcopy \
+	TARGET_RANLIB=/libexec/bin/binutils-ranlib \
+	TARGET_STRIP=/libexec/bin/binutils-strip \
 	LDFLAGS="$LDFLAGS" \
 	LIBS="$LIBS" \
 	../configure \
@@ -72,12 +91,10 @@
 		--target=$CTARGET \
 		--prefix= \
 		--sbindir=/bin \
-		--disable-libzfs \
-		--disable-efiemu \
 		--disable-werror \
-		--with-platform="$1" \
 		$with_lzma \
-		$with_nls
+		$with_nls \
+		"$@"
 	make
 	make install DESTDIR=$DESTDIR
 
@@ -91,8 +108,19 @@
 	tar xvf $PKGNAME-$PKGVERSION.tar.xz
 	cd $PKGNAME-$PKGVERSION
 
+	if [ "$CC" = "clang" ]; then
+		patch -p0 < ../patch-clang.patch
+	fi
+
 	for p in $platforms; do
-		build_grub $p
+		case $p in
+		efi)
+			build_grub --with-platform=$p --disable-efiemu
+			;;
+		*)
+			build_grub --with-platform=$p
+			;;
+		esac
 	done
 
 	cd ..
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/grub/patch-clang.patch	Thu Aug 08 20:55:00 2019 +0200
@@ -0,0 +1,12 @@
+--- grub-core/boot/i386/pc/startup_raw.S.orig	2019-08-08 07:18:39.284272833 +0000
++++ grub-core/boot/i386/pc/startup_raw.S	2019-08-08 07:18:56.876273374 +0000
+@@ -118,7 +118,9 @@
+ 
+ #include "../../../kern/i386/realmode.S"
+ 
++#define addrsig text
+ #include <rs_decoder.h>
++#undef addrsig
+ 
+ 	.text
+