Submitted By: Robert Connolly <robert at linuxfromscratch dot org> (ashes)
Date: 2004-11-14
Initial Package Version: 3.4.3
Upstream Status: Not submitted - Hack
ORIGIN: http://www.uclibc.org/cgi-bin/cvsweb/buildroot/toolchain/\
        gcc/3.4.2/100-uclibc-conf.patch
Description: This adds --target=*-*-linux-uclibc* needed for building a
uClibc toolchain. All specs hunks and non-i386 hunks were removed from
the original patch. Use this with the gcc-specs_conf patch.

Also see:
http://www.linuxfromscratch.org/hlfs/
http://www.uclibc.org/

diff -urN gcc-3.4.1-dist/gcc/config/t-linux-uclibc gcc-3.4.1/gcc/config/t-linux-uclibc
--- gcc-3.4.1-dist/gcc/config/t-linux-uclibc	1969-12-31 18:00:00.000000000 -0600
+++ gcc-3.4.1/gcc/config/t-linux-uclibc	2004-08-12 15:54:43.000000000 -0500
@@ -0,0 +1,15 @@
+T_CFLAGS = -DUSE_UCLIBC
+
+# Compile crtbeginS.o and crtendS.o with pic.
+CRTSTUFF_T_CFLAGS_S = $(CRTSTUFF_T_CFLAGS) -fPIC
+# Compile libgcc2.a with pic.
+TARGET_LIBGCC2_CFLAGS = -fPIC
+
+# Override t-slibgcc-elf-ver to export some libgcc symbols with
+# the symbol versions that glibc used.
+#SHLIB_MAPFILES += $(srcdir)/config/libgcc-glibc.ver
+
+# Use unwind-dw2-fde
+LIB2ADDEH = $(srcdir)/unwind-dw2.c $(srcdir)/unwind-dw2-fde.c \
+  $(srcdir)/unwind-sjlj.c $(srcdir)/gthr-gnat.c $(srcdir)/unwind-c.c
+LIB2ADDEHDEP = unwind.inc unwind-dw2-fde.h
diff -urN gcc-3.4.1-dist/gcc/config.gcc gcc-3.4.1/gcc/config.gcc
--- gcc-3.4.1-dist/gcc/config.gcc	2004-04-21 10:12:35.000000000 -0500
+++ gcc-3.4.1/gcc/config.gcc	2004-08-12 15:59:46.000000000 -0500
@@ -988,6 +998,11 @@
 		thread_file='single'
 	fi
 	;;
+i[34567]86-*-linux*uclibc*)	# Intel 80386's running GNU/Linux
+				# with ELF format using uClibc
+	tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h svr4.h linux.h i386/linux.h"
+	tmake_file="t-slibgcc-elf-ver t-linux-uclibc i386/t-crtstuff"
+	;;
 i[34567]86-*-linux*)	# Intel 80386's running GNU/Linux
 			# with ELF format using glibc 2
 			# aka GNU/Linux C library 6
diff -urN gcc-3.4.1-dist/libtool.m4 gcc-3.4.1/libtool.m4
--- gcc-3.4.1-dist/libtool.m4	2004-05-18 04:08:37.000000000 -0500
+++ gcc-3.4.1/libtool.m4	2004-08-12 15:54:43.000000000 -0500
@@ -689,6 +689,11 @@
   lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
   ;;
 
+linux-uclibc*)
+  lt_cv_deplibs_check_method=pass_all
+  lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
+  ;;
+
 netbsd*)
   if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
     [lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$']
diff -urN gcc-3.4.1-dist/ltconfig gcc-3.4.1/ltconfig
--- gcc-3.4.1-dist/ltconfig	2004-03-05 15:05:41.000000000 -0600
+++ gcc-3.4.1/ltconfig	2004-08-12 15:55:48.000000000 -0500
@@ -602,6 +602,7 @@
 
 # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
 case $host_os in
+linux-uclibc*) ;;
 linux-gnu*) ;;
 linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
 esac
@@ -1262,6 +1263,24 @@
   dynamic_linker='GNU/Linux ld.so'
   ;;
 
+linux-uclibc*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+  soname_spec='${libname}${release}.so$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  # Note: copied from linux-gnu, and may not be appropriate.
+  hardcode_into_libs=yes
+  # Assume using the uClibc dynamic linker.
+  dynamic_linker="uClibc ld.so"
+  ;;
+
 netbsd*)
   need_lib_prefix=no
   need_version=no
