Browse Source

add support for x86_64 toolchain with 32 bit abi

Waldemar Brodkorb 11 years ago
parent
commit
46af98aa43

+ 2 - 2
mk/build.mk

@@ -476,8 +476,8 @@ bulktoolchain:
 			mkdir -p ${TOPDIR}/firmware; \
 		    ( \
 			echo === building $$arch $$libc toolchain-$$arch on $$(date); \
-			tarch=$$(echo $$arch|sed -e "s#el##" -e "s#eb##" -e "s#mips64.*#mips#" -e "s#hf##"); \
-			carch=$$(echo $$arch|sed -e "s#sh#sh4#" -e "s#hf##" -e "s#mips64n.*#mips64#" -e "s#mips64el.*#mips64el#" ); \
+			tarch=$$(echo $$arch|sed -e "s#el##" -e "s#eb##" -e "s#mips64.*#mips#" -e "s#hf##" -e "s#x86_64.*#x86_64#" ); \
+			carch=$$(echo $$arch|sed -e "s#sh#sh4#" -e "s#hf##" -e "s#mips64n.*#mips64#" -e "s#mips64el.*#mips64el#" -e "s#x86_64.*#x86_64#" ); \
 			$(GMAKE) prereq && \
 				$(GMAKE) ARCH=$$tarch SYSTEM=toolchain-$$arch LIBC=$$libc defconfig; \
 				tabi=$$(grep ^ADK_TARGET_ABI= .config|cut -d \" -f 2);\

+ 2 - 0
mk/image.mk

@@ -51,6 +51,7 @@ image-prepare-post:
 	-rm -f ${TARGET_DIR}/bin/sh
 	ln -sf ${BINSH} ${TARGET_DIR}/bin/sh
 ifeq ($(ADK_LINUX_X86_64),y)
+ifeq ($(ADK_TARGET_ABI_32),)
 	# fixup lib dirs
 	mv ${TARGET_DIR}/lib/* ${TARGET_DIR}/${ADK_TARGET_LIBC_PATH}
 	rm -rf ${TARGET_DIR}/lib/
@@ -60,6 +61,7 @@ ifeq ($(ADK_LINUX_X86_64),y)
 	rm -rf ${TARGET_DIR}/usr/lib/
 	(cd ${TARGET_DIR}/usr ; ln -sf ${ADK_TARGET_LIBC_PATH} lib)
 endif
+endif
 ifeq ($(ADK_LINUX_PPC64),y)
 	# fixup lib dirs
 	mv ${TARGET_DIR}/lib/* ${TARGET_DIR}/${ADK_TARGET_LIBC_PATH}

+ 1 - 0
target/config/Config.in

@@ -175,6 +175,7 @@ endchoice
 
 config ADK_TARGET_LIBC_PATH
 	string
+	default "lib" if ADK_32
 	default "lib32" if ADK_n32
 	default "libx32" if ADK_x32
 	default "lib64" if ADK_n64 \

+ 2 - 0
target/tarch.lst

@@ -18,3 +18,5 @@ sparc
 sparc64
 x86
 x86_64
++x86_64_32
++x86_64_x32

+ 12 - 0
target/x86_64/sys-available/toolchain-x86_64_32

@@ -0,0 +1,12 @@
+config ADK_TARGET_SYSTEM_TOOLCHAIN_X86_64_32
+	bool "Toolchain only (32 ABI)"
+	select ADK_x86_64
+	select ADK_32
+	select ADK_toolchain_x86_64
+	select ADK_CPU_X86_64
+	select ADK_LINUX_64
+	select ADK_TOOLCHAIN
+	select ADK_TARGET_PACKAGE_TGZ
+	help
+	  Build a x86_64 toolchain.
+

+ 12 - 0
target/x86_64/sys-available/toolchain-x86_64_x32

@@ -0,0 +1,12 @@
+config ADK_TARGET_SYSTEM_TOOLCHAIN_X86_64_X32
+	bool "Toolchain only (x32 ABI)"
+	select ADK_x86_64
+	select ADK_x32
+	select ADK_toolchain_x86_64
+	select ADK_CPU_X86_64
+	select ADK_LINUX_64
+	select ADK_TOOLCHAIN
+	select ADK_TARGET_PACKAGE_TGZ
+	help
+	  Build a x86_64 toolchain.
+

+ 1 - 1
toolchain/binutils/Makefile

@@ -16,7 +16,7 @@ ifeq ($(ADK_TARGET_SYSTEM_RASPBERRY_PI),y)
 CONFOPTS+=          	--with-arch=armv6
 endif
 
-ifneq ($(strip $(ADK_LINUX_64)$(ADK_TARGET_KERNEL64)),)
+ifneq ($(ADK_LINUX_64),)
 CONFOPTS+=		--enable-64-bit-bfd
 endif
 

+ 2 - 2
toolchain/gcc/Makefile

@@ -45,10 +45,10 @@ endif
 
 ifeq ($(ADK_LINUX_X86_64),y)
 ifeq ($(ADK_x32),y)
-GCC_FINAL_CONFOPTS+=	--enable-multilib --with-multilib-list=mx32
+GCC_FINAL_CONFOPTS+=	--with-abi=x32
 endif
 ifeq ($(ADK_32),y)
-GCC_FINAL_CONFOPTS+=	--enable-multilib --with-multilib-list=m32
+GCC_FINAL_CONFOPTS+=	--with-abi=32
 endif
 ifeq ($(ADK_64),y)
 GCC_FINAL_CONFOPTS+=	--disable-biarch --disable-multilib

+ 54 - 0
toolchain/gcc/patches/4.8.2/abi32.patch

@@ -0,0 +1,54 @@
+diff -Nur gcc-4.8.2.orig/gcc/config/i386/biarch32.h gcc-4.8.2/gcc/config/i386/biarch32.h
+--- gcc-4.8.2.orig/gcc/config/i386/biarch32.h	1970-01-01 01:00:00.000000000 +0100
++++ gcc-4.8.2/gcc/config/i386/biarch32.h	2014-03-23 20:33:52.000000000 +0100
+@@ -0,0 +1,27 @@
++/* Make configure files to produce biarch compiler defaulting to 32bit mode.
++   This file must be included very first, while the OS specific file later
++   to overwrite otherwise wrong defaults. 
++   Copyright (C) 2001-2014 Free Software Foundation, Inc.
++
++This file is part of GCC.
++
++GCC is free software; you can redistribute it and/or modify
++it under the terms of the GNU General Public License as published by
++the Free Software Foundation; either version 3, or (at your option)
++any later version.
++
++GCC is distributed in the hope that it will be useful,
++but WITHOUT ANY WARRANTY; without even the implied warranty of
++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++GNU General Public License for more details.
++
++Under Section 7 of GPL version 3, you are granted additional
++permissions described in the GCC Runtime Library Exception, version
++3.1, as published by the Free Software Foundation.
++
++You should have received a copy of the GNU General Public License and
++a copy of the GCC Runtime Library Exception along with this program;
++see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
++<http://www.gnu.org/licenses/>.  */
++
++#define TARGET_64BIT_DEFAULT 0
+diff -Nur gcc-4.8.2.orig/gcc/config.gcc gcc-4.8.2/gcc/config.gcc
+--- gcc-4.8.2.orig/gcc/config.gcc	2013-10-03 02:47:24.000000000 +0200
++++ gcc-4.8.2/gcc/config.gcc	2014-03-22 13:15:18.000000000 +0100
+@@ -522,6 +522,9 @@
+ 	64 | m64)
+ 		tm_file="i386/biarch64.h ${tm_file}"
+ 		;;
++	32 | m32)
++		tm_file="i386/biarch32.h ${tm_file}"
++		;;
+ 	x32 | mx32)
+ 		tm_file="i386/biarchx32.h ${tm_file}"
+ 		;;
+@@ -1343,6 +1346,9 @@
+ 		x32 | mx32)
+ 			x86_multilibs="mx32"
+ 			;;
++		32 | m32)
++			x86_multilibs="m32"
++			;;
+ 		*)
+ 			x86_multilibs="m64,m32"
+ 			;;

+ 1 - 1
toolchain/glibc/Makefile.inc

@@ -6,7 +6,7 @@ PKG_VERSION:=		2.19
 PKG_RELEASE:=		1
 PKG_MD5SUM:=		5374d29864b583622b62bfc6b8429418
 PKG_SITES:=		${MASTER_SITE_GNU:=glibc/}
-ifeq ($(ADK_TARGET_ABI_32),y)
+ifeq ($(ADK_32),y)
 GLIBC_TARGET_NAME:=	i686-openadk-linux-gnu
 else
 GLIBC_TARGET_NAME:=	$(GNU_TARGET_NAME)