Patchwork [x32] PATCH: Add --enable-x32

login
register
mail settings
Submitter H.J. Lu
Date Feb. 13, 2011, 11:13 p.m.
Message ID <20110213231346.GA23368@intel.com>
Download mbox | patch
Permalink /patch/83020/
State New
Headers show

Comments

H.J. Lu - Feb. 13, 2011, 11:13 p.m.
Hi,

I checked this patch into x32 branch so that we can build x32 libraries.

H.J.
----
From d67b431e781beec86e2ea153ffd9c57de61be9ae Mon Sep 17 00:00:00 2001
From: H.J. Lu <hjl.tools@gmail.com>
Date: Sun, 13 Feb 2011 08:24:30 -0800
Subject: [PATCH 1/3] Add --enable-x32.

---
 gcc/ChangeLog.x32          |    9 +++++++++
 gcc/config.gcc             |   13 +++++++++++--
 gcc/config/i386/t-linuxx32 |   17 +++++++++++++++++
 gcc/configure              |   15 +++++++++++++--
 gcc/configure.ac           |    5 +++++
 5 files changed, 55 insertions(+), 4 deletions(-)
 create mode 100644 gcc/config/i386/t-linuxx32

Patch

diff --git a/gcc/ChangeLog.x32 b/gcc/ChangeLog.x32
index 4160ca9..7aeeba5 100644
--- a/gcc/ChangeLog.x32
+++ b/gcc/ChangeLog.x32
@@ -1,3 +1,12 @@ 
+2011-02-13  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* config.gcc: Support --enable-x32 for x86 Linux targets.
+
+	* configure.ac: Support --enable-x32.
+	* configure: Regenerated.
+
+	* config/i386/t-linuxx32: New.
+
 2011-02-12  H.J. Lu  <hongjiu.lu@intel.com>
 
 	PR target/47715
diff --git a/gcc/config.gcc b/gcc/config.gcc
index 54b822e..44c33df 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -1256,7 +1256,11 @@  i[34567]86-*-linux* | i[34567]86-*-kfreebsd*-gnu | i[34567]86-*-knetbsd*-gnu | i
 		if test x$enable_targets = xall; then
 			tm_file="${tm_file} i386/x86-64.h i386/linux64.h"
 			tm_defines="${tm_defines} TARGET_BI_ARCH=1"
-			tmake_file="${tmake_file} i386/t-linux64"
+			if test x$enable_x32 = xyes; then
+				tmake_file="${tmake_file} i386/t-linuxx32"
+			else
+				tmake_file="${tmake_file} i386/t-linux64"
+			fi
 			need_64bit_hwint=yes
 			need_64bit_isa=yes
 			case X"${with_cpu}" in
@@ -1293,7 +1297,12 @@  x86_64-*-linux* | x86_64-*-kfreebsd*-gnu | x86_64-*-knetbsd*-gnu)
 	x86_64-*-kfreebsd*-gnu) tm_file="${tm_file} kfreebsd-gnu.h" ;;
 	x86_64-*-knetbsd*-gnu) tm_file="${tm_file} knetbsd-gnu.h" ;;
 	esac
-	tmake_file="${tmake_file} i386/t-linux64 i386/t-crtstuff i386/t-crtpc i386/t-crtfm t-dfprules"
+	if test x$enable_x32 = xyes; then
+		tmake_file="${tmake_file} i386/t-linuxx32"
+	else
+		tmake_file="${tmake_file} i386/t-linux64"
+	fi
+	tmake_file="${tmake_file} i386/t-crtstuff i386/t-crtpc i386/t-crtfm t-dfprules"
 	;;
 i[34567]86-pc-msdosdjgpp*)
 	xm_file=i386/xm-djgpp.h
diff --git a/gcc/config/i386/t-linuxx32 b/gcc/config/i386/t-linuxx32
new file mode 100644
index 0000000..a4741e1
--- /dev/null
+++ b/gcc/config/i386/t-linuxx32
@@ -0,0 +1,17 @@ 
+# To support i386, x86-64 and x32 libraries, the directory structrue
+# should be:
+#
+# 	/lib has i386 libraries.
+# 	/lib64 has x86-64 libraries.
+# 	/lib32 has x32 libraries.
+
+MULTILIB_OPTIONS = m64/m32/mx32
+MULTILIB_DIRNAMES = 64 32 x32
+MULTILIB_OSDIRNAMES = ../lib64 ../lib ../lib32
+
+LIBGCC = stmp-multilib
+INSTALL_LIBGCC = install-multilib
+
+EXTRA_MULTILIB_PARTS=crtbegin.o crtend.o crtbeginS.o crtendS.o \
+		     crtbeginT.o crtprec32.o crtprec64.o crtprec80.o \
+		     crtfastmath.o
diff --git a/gcc/configure b/gcc/configure
index 91fad33..d678648 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -871,6 +871,7 @@  enable_gather_detailed_mem_stats
 enable_build_with_cxx
 with_stabs
 enable_multilib
+enable_x32
 enable___cxa_atexit
 enable_decimal_float
 enable_fixed_point
@@ -1572,6 +1573,7 @@  Optional Features:
   --enable-gather-detailed-mem-stats         enable detailed memory allocation stats gathering
   --enable-build-with-cxx build with C++ compiler instead of C compiler
   --enable-multilib       enable library support for multiple ABIs
+  --enable-x32            enable x32 library support for multiple ABIs
   --enable-__cxa_atexit   enable __cxa_atexit for C++
   --enable-decimal-float={no,yes,bid,dpd}
 			enable decimal float extension to C.  Selecting 'bid'
@@ -6874,6 +6876,15 @@  fi
 
 
 
+# With x32 support
+# Check whether --enable-x32 was given.
+if test "${enable_x32+set}" = set; then :
+  enableval=$enable_x32;
+else
+  enable_x32=no
+fi
+
+
 # Enable __cxa_atexit for C++.
 # Check whether --enable-__cxa_atexit was given.
 if test "${enable___cxa_atexit+set}" = set; then :
@@ -17505,7 +17516,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 17508 "configure"
+#line 17519 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -17611,7 +17622,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 17614 "configure"
+#line 17625 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 0c065e0..74fe079 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -606,6 +606,11 @@  AC_ARG_ENABLE(multilib,
 [], [enable_multilib=yes])
 AC_SUBST(enable_multilib)
 
+# With x32 support
+AC_ARG_ENABLE(x32,
+[  --enable-x32            enable x32 library support for multiple ABIs],
+[], [enable_x32=no])
+
 # Enable __cxa_atexit for C++.
 AC_ARG_ENABLE(__cxa_atexit,
 [  --enable-__cxa_atexit   enable __cxa_atexit for C++],