[adtools] Re: libstdc++-v3 Multilib Support

  • From: Trevor Scroggins <trevor.scroggins@xxxxxxxxx>
  • To: adtools@xxxxxxxxxxxxx
  • Date: Wed, 14 Jul 2010 09:00:53 -0700

Hi,

On Tue, Jul 13, 2010 at 11:34 AM, Sebastian Bauer
<mail@xxxxxxxxxxxxxxxxxxx> wrote:
> I don't know. But I suppose that if neigther newlib nor clib2 provide
> soft-float support we can omit building these flavors. One thing less to
> care about ;)

I was testing clib2/soft-float/libstdc++ statically, but it's no
longer an issue if we're dropping soft-float. :-)

I put together a small set of experimental patches that turns clib2
into a new target, e.g. ppc-amigaos-clib2. Building for that target
makes clib2 the default multilib; otherwise, newlib is the default
multilib. The infrastructure is in place to support ixemul and libnix
as well if they ever come out of the shadows.

The full set of supported multilibs is newlib, clib2, and clib2-ts. My
target makefile fragment multilib detection is a hack. The m68k
fragments include an extensible bit of awk magic that could work in
this instance.

One downside to this method is needing ppc-amigaos-clib2 binutils. At
the very least, we need additional symlinks in $prefix/bin. Some
32/64-bit binutils do this already, e.g. sparc and sparc64, so it
might be a simple thing. In the meantime, the symlinks can be created
by hand or GCC can be told where to find as, ld, and the rest of the
build tools.

The patch also enables a multilib libgcc and removes the hard-coded
references to clib2/lib and newlib/lib in
$prefix/gcc/ppc-amigaos/<version>/. The built-in multilib search
methods are used instead. I haven't tested how this impacts mbaserel
and msdata.

To configure newlib as the default:

../../gcc/configure --with-bugurl='http://www.sf.net/projects/adtools'
--with-pkgversion='adtools build newlib' --target=ppc-amigaos
--prefix=/c/gcc/ppc-amigaos --enable-languages=c,c++ --enable-haifa
--enable-sjlj-exceptions --disable-libstdcxx-pch --disable-tls
--enable-version-specific-runtime-libs

To configure clib2 as the default, assuming
ppc-amigaos-clib-[binutils] are available:

../../gcc/configure --with-bugurl='http://www.sf.net/projects/adtools'
--with-pkgversion='adtools build clib2' --target=ppc-amigaos-clib2
--prefix=/c/gcc/ppc-amigaos --enable-languages=c,c++ --enable-haifa
--enable-sjlj-exceptions --disable-libstdcxx-pch --disable-tls
--enable-version-specific-runtime-libs

Have a look. I'd still like to fix the -lstdc++ -lgcc_eh specs issue as well.

Trev


Index: config.sub
===================================================================
--- config.sub  (revision 356)
+++ config.sub  (working copy)
@@ -122,7 +122,8 @@
 case $maybe_os in
   nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
   uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* |
netbsd*-gnu* | \
-  storm-chaos* | os2-emx* | rtmk-nova*)
+  storm-chaos* | os2-emx* | rtmk-nova* | \
+  amigaos-clib2* | amigaos-ixemul* | amigaos-libnix*)
     os=-$maybe_os
     basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
     ;;
Index: gcc/config.gcc
===================================================================
--- gcc/config.gcc      (revision 356)
+++ gcc/config.gcc      (working copy)
@@ -1688,12 +1688,27 @@
        use_fixproto=yes
        ;;
 powerpc-*-amigaos*)
+       tm_defines="${tm_defines} LIBC_NEWLIB=1 LIBC_CLIB2=2 LIBC_IXEMUL=3
LIBC_LIBNIX=4"
        tm_file="${tm_file} dbxelf.h elfos.h svr4.h rs6000/sysv4.h 
rs6000/amigaos.h"
        tm_p_file="${tm_p_file} rs6000/amigaos-protos.h"
        extra_options="${extra_options} rs6000/sysv4.opt rs6000/amigaos.opt"
        tmake_file="rs6000/t-amigaos"
        extra_objs=amigaos.o
        use_collect2=no
+       case ${target} in
+       *-*-*libnix*)
+               tm_defines="${tm_defines} DEFAULT_LIBC=LIBC_LIBNIX"
+               ;;
+       *-*-*ixemul*)
+               tm_defines="${tm_defines} DEFAULT_LIBC=LIBC_IXEMUL"
+               ;;
+       *-*-*clib2*)
+               tm_defines="${tm_defines} DEFAULT_LIBC=LIBC_CLIB2"
+               ;;
+       *)
+               tm_defines="${tm_defines} DEFAULT_LIBC=LIBC_NEWLIB"
+               ;;
+       esac
        ;;
 # port not yet contributed
 #powerpc-*-openbsd*)
Index: gcc/config/rs6000/amigaos.h
===================================================================
--- gcc/config/rs6000/amigaos.h (revision 356)
+++ gcc/config/rs6000/amigaos.h (working copy)
@@ -140,10 +140,10 @@
 #undef LOCAL_INCLUDE_DIR

 #ifndef CROSS_COMPILE
-#define BASE_GCC_SPEC "/GCC/"
+/* #define BASE_GCC_SPEC "/GCC/" */
 #define BASE_SDK_SPEC "/SDK/"
 #else
-#define BASE_GCC_SPEC EXEC_PREFIX
+/* #define BASE_GCC_SPEC EXEC_PREFIX */
 #define BASE_SDK_SPEC EXEC_PREFIX "ppc-amigaos/SDK/"
 #endif

@@ -157,19 +157,21 @@
 %{static|static-libgcc: %{!use-dynld: -lgcc -lgcc_eh} %{use-dynld:
-lgcc} }%{!static:%{!static-libgcc:%{!shared:%{!shared-libgcc:
%{!use-dynld: -lgcc -lgcc_eh} %{use-dynld:
-lgcc}}%{shared-libgcc:-lgcc}}%{shared:%{shared-libgcc:-lgcc}%{!shared-libgcc:-lgcc}}}}"


+#if DEFAULT_LIBC == LIBC_NEWLIB
 /* make newlib the default */
-#if 1
 #define CPP_AMIGA_DEFAULT_SPEC "%{mcrt=default|!mcrt=*:%<mcrt=default
-mcrt=newlib} %(cpp_newlib)"
 #define LINK_AMIGA_DEFAULT_SPEC "%(link_newlib)"
 #define STARTFILE_AMIGA_DEFAULT_SPEC "%(startfile_newlib)"
 #define ENDFILE_AMIGA_DEFAULT_SPEC "%(endfile_newlib)"
-#else
+#elif DEFAULT_LIBC == LIBC_CLIB2
 /* make clib2 the default */
 #define CPP_AMIGA_DEFAULT_SPEC "%{mcrt=default|!mcrt=*:%<mcrt=default
-mcrt=clib2} %(cpp_clib2)"
 #define LINK_AMIGA_DEFAULT_SPEC "%(link_clib2)"
 #define STARTFILE_AMIGA_DEFAULT_SPEC "%(startfile_clib2)"
 #define ENDFILE_AMIGA_DEFAULT_SPEC "%(endfile_clib2)"
-#endif
+#else
+#error "Unsupported DEFAULT_LIBC"
+#endif /* DEFAULT_LIBC */

 /* clib2 */

@@ -178,10 +180,15 @@

 #define LIB_SUBDIR_CLIB2_SPEC "%{mcrt=clib2-ts:lib.threadsafe;
:lib}%(lib_subdir_type)"

+/*
 #define LINK_CLIB2_SPEC "\
 -L%(base_sdk)clib2/%(lib_subdir_clib2) \
 -L%(base_gcc)lib/gcc/ppc-amigaos/%(version)/%{mcrt=clib2-ts:clib2-ts;
:clib2}/lib%(lib_subdir_type) \
 -L%(base_sdk)local/clib2/%(lib_subdir_clib2)"
+*/
+#define LINK_CLIB2_SPEC "\
+-L%(base_sdk)clib2/%(lib_subdir_clib2) \
+-L%(base_sdk)local/clib2/%(lib_subdir_clib2)"

 #define STARTFILE_CLIB2_SPEC "\
 %(base_sdk)clib2/%{mcrt=clib2-ts:lib.threadsafe; :lib}" \
@@ -200,10 +207,15 @@

 #define LIB_SUBDIR_IXEMUL_SPEC "lib%(lib_subdir_type)"

+/*
 #define LINK_IXEMUL_SPEC "\
 -L%(base_sdk)ixemul/%(lib_subdir_ixemul) \
 -L%(base_gcc)lib/gcc/ppc-amigaos/%(version)/ixemul/%(lib_subdir_ixemul) \
 -L%(base_sdk)local/ixemul/%(lib_subdir_ixemul)"
+*/
+#define LINK_IXEMUL_SPEC "\
+-L%(base_sdk)ixemul/%(lib_subdir_ixemul) \
+-L%(base_sdk)local/ixemul/%(lib_subdir_ixemul)"

 /* ixemul startfile should work for all library flavours */
 #define STARTFILE_IXEMUL_SPEC
"%(base_sdk)ixemul/%(lib_subdir_ixemul)/crtbegin.o"
@@ -216,10 +228,15 @@

 #define LIB_SUBDIR_LIBNIX_SPEC "lib%(lib_subdir_type)"

+/*
 #define LINK_LIBNIX_SPEC "\
 -L%(base_sdk)libnix/%(lib_subdir_libnix) \
 -L%(base_gcc)lib/gcc/ppc-amigaos/%(version)/libnix/%(lib_subdir_libnix) \
 -L%(base_sdk)local/libnix/%(lib_subdir_libnix)"
+*/
+#define LINK_LIBNIX_SPEC "\
+-L%(base_sdk)libnix/%(lib_subdir_libnix) \
+-L%(base_sdk)local/libnix/%(lib_subdir_libnix)"

 #define STARTFILE_LIBNIX_SPEC
"%(base_sdk)libnix/%(lib_subdir_libnix)/crtbegin.o"
 #define ENDFILE_LIBNIX_SPEC "%(base_sdk)libnix/%(lib_subdir_libnix)/crtend.o"
@@ -231,10 +248,15 @@

 #define LIB_SUBDIR_NEWLIB_SPEC "lib%(lib_subdir_type)"

+/*
 #define LINK_NEWLIB_SPEC "\
 -L%(base_sdk)newlib/%(lib_subdir_newlib) \
 -L%(base_gcc)lib/gcc/ppc-amigaos/%(version)/newlib/%(lib_subdir_newlib) \
 -L%(base_sdk)local/newlib/%(lib_subdir_newlib)"
+*/
+#define LINK_NEWLIB_SPEC "\
+-L%(base_sdk)newlib/%(lib_subdir_newlib) \
+-L%(base_sdk)local/newlib/%(lib_subdir_newlib)"

 /* newlib startfile should work for all library flavours */
 #define STARTFILE_NEWLIB_SPEC "\
@@ -318,7 +340,7 @@

 #undef SUBTARGET_EXTRA_SPECS
 #define SUBTARGET_EXTRA_SPECS \
-  {"base_gcc", BASE_GCC_SPEC}, \
+  /* {"base_gcc", BASE_GCC_SPEC}, */ \
   {"base_sdk", BASE_SDK_SPEC}, \
   {"cpp_os_default", CPP_OS_DEFAULT_SPEC}, \
   {"lib_subdir_type", LIB_SUBDIR_TYPE_SPEC}, \
Index: gcc/config/rs6000/t-amigaos
===================================================================
--- gcc/config/rs6000/t-amigaos (revision 356)
+++ gcc/config/rs6000/t-amigaos (working copy)
@@ -26,9 +26,16 @@

 # Build the libraries for both hard and soft floating point

-MULTILIB_OPTIONS = msoft-float
-MULTILIB_DIRNAMES = soft-float
+MULTILIB_OPTIONS = `case "$(target)" in \
+       *-*-*clib2*) echo mcrt=clib2-ts/mcrt=newlib ;; \
+       *) echo mcrt=clib2/mcrt=clib2-ts ;; esac`
+MULTILIB_DIRNAMES = `case "$(target)" in \
+       *-*-*clib2*) echo clib2-ts newlib ;; \
+       *) echo clib2 clib2-ts ;; esac`

+LIBGCC = stmp-multilib
+INSTALL_LIBGCC = install-multilib
+
 # Build a shared libgcc library.
 LIBGCC2_CFLAGS += -fPIC
 SHLIB_DIR = @multilib_dir@
-- 
______________________________________________________________________________
Amiga Development tools ML - //www.freelists.org/list/adtools
Homepage...................: http://www.sourceforge.net/projects/adtools
Listserver help............: mailto:adtools-request@xxxxxxxxxxxxx?Subject=HELP

Other related posts: