From 8f01cb10fde198166450eebe9e842553a363d2f9 Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Fri, 4 Feb 2005 23:37:16 +0000 Subject: [PATCH] - switched some compile-time dependencies to target dependencies, such that cross-compiling with BeOS target works. - tweaked build-procedure to allow for proper generation of a i586-pc-beos cross-compiler on LINUX. - added documentation for creation of cross-compiler. git-svn-id: file:///srv/svn/repos/haiku/trunk/buildtools@11255 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- INSTALL-as-cross-compiler-on-LINUX | 74 ++++++++++++++++++++++++++++++ binutils/bfd/config.bfd | 1 + binutils/bfd/elflink.c | 2 +- gcc/gcc/config/i386/t-beos | 2 +- gcc/gcc/cp/method.c | 2 +- gcc/gcc/cross-make | 4 +- gcc/gcc/fixinc/fixlib.h | 2 - 7 files changed, 81 insertions(+), 6 deletions(-) create mode 100644 INSTALL-as-cross-compiler-on-LINUX diff --git a/INSTALL-as-cross-compiler-on-LINUX b/INSTALL-as-cross-compiler-on-LINUX new file mode 100644 index 0000000000..f483e46569 --- /dev/null +++ b/INSTALL-as-cross-compiler-on-LINUX @@ -0,0 +1,74 @@ +How to build gcc-2.95.3 for BeOS under Linux (a cross-compiler), which +will allow you to compile BeOS projects under Linux, i.e. the apps +that this compilers produces can only be executed on BeOS (not on Linux). + +*** the major work of creating the cross-compiler and describing the +*** process how to build it has been done by Eric Petit , +*** so if you think this cross-compiler is great, please tell him. + +----------------------------------------------------------------------- +On your Linux-box, open a shell... + +0 - Preparations +---------------- +...and fetch the 'buildtools' module from the haiku CVS. You should then +have a 'buildtools' folder that contains folders named 'binutils' and +'gcc' (and this file, too!). + + cd buildtools + +Now decide where you want to install the cross-compiler. The install +folder will be referred to as $PREFIX. I suggest to install to +/opt/cross-tools, but you can basically put it anywhere you like. + + export PREFIX=/opt/cross-tools + +and add it the path: + + export PATH=$PATH:$PREFIX/bin + +Create two folders for the headers and libraries, say $BEINC and +$BELIB: + + mkdir beinc + export BEINC=$(pwd)/beinc + mkdir belib + export BELIB=$(pwd)/belib + +Copy all contents from /boot/develop/lib/x86/ on your BeOS install to +$BELIBS on your Linux box (make sure symbolic links are followed). You +should have $BELIBS/libbe.so, etc. + +Copy all contents from /boot/develop/headers/ on your BeOS install to +$BEINCS on your Linux box. You should have $BEINCS/be/AppKit.h, etc. + + +1 - Building binutils +--------------------- + mkdir binutils-obj + cd binutils-obj + CFLAGS="-O2" CXXFLAGS="-O2" ../binutils/configure --prefix=$PREFIX \ + --target=i586-pc-beos --disable-nls --enable-shared=yes + make && make install + cd .. + +2 - Building gcc/g++ +-------------------- + mkdir -p $PREFIX/lib/gcc-lib/i586-pc-beos/2.95.3-beos-041202 + mkdir gcc-obj + cd gcc-obj + CFLAGS="-O2" CXXFLAGS="-O2" ../gcc/configure --prefix=$PREFIX \ + --target=i586-pc-beos --disable-nls --enable-shared=yes \ + --enable-languages=c,c++ --with-headers=$BEINC --with-libs=$BELIB + make cross && make install + cd .. + +Ok, now everything is compiled and installed, waiting to be used: + + i586-pc-beos-gcc test.c + +would compile the file test.c with the fresh cross-compiler. + +So have fun! + +Please send questions & bug-reports to: Oliver Tappe diff --git a/binutils/bfd/config.bfd b/binutils/bfd/config.bfd index 1428831c15..96fe27bc8d 100755 --- a/binutils/bfd/config.bfd +++ b/binutils/bfd/config.bfd @@ -543,6 +543,7 @@ case "${targ}" in i[3-7]86-*-beoself* | i[3-7]86-*-beos*) targ_defvec=bfd_elf32_i386_vec targ_selvecs="i386pe_vec i386pei_vec" + targ_cflags=-DDT_RELCOUNT_IS_UNKNOWN_ON_TARGET ;; i[3-7]86-*-interix*) targ_defvec=i386pei_vec diff --git a/binutils/bfd/elflink.c b/binutils/bfd/elflink.c index 2cd2f7a13e..8bf0ed8761 100644 --- a/binutils/bfd/elflink.c +++ b/binutils/bfd/elflink.c @@ -7814,7 +7814,7 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info) default: continue; /* BeOS (R5) doesn't know about DT_RELCOUNT, so we avoid using it */ -#ifndef __BEOS__ +#ifndef DT_RELCOUNT_IS_UNKNOWN_ON_TARGET case DT_NULL: if (relativecount > 0 && dyncon + bed->s->sizeof_dyn < dynconend) { diff --git a/gcc/gcc/config/i386/t-beos b/gcc/gcc/config/i386/t-beos index bf5db9115e..fcae8f2d49 100644 --- a/gcc/gcc/config/i386/t-beos +++ b/gcc/gcc/config/i386/t-beos @@ -19,4 +19,4 @@ EXTRA_PARTS += fix_bdirectwin_typeinfo.o # function as provided by the Be-libs (which crashes GLTeapot). # fix_bdirectwin_typeinfo.o: $(srcdir)/beos-specific/fix_bdirectwin_typeinfo.cpp - gcc -c -O0 $(srcdir)/beos-specific/fix_bdirectwin_typeinfo.cpp + $(GCC_FOR_TARGET) -c -O0 $(srcdir)/beos-specific/fix_bdirectwin_typeinfo.cpp diff --git a/gcc/gcc/cp/method.c b/gcc/gcc/cp/method.c index 3e7224ec70..093367deac 100644 --- a/gcc/gcc/cp/method.c +++ b/gcc/gcc/cp/method.c @@ -350,7 +350,7 @@ flush_repeats (nrepeats, type) return 0; } -#ifdef __BEOS__ +#ifdef USE_EGCS_MANGLED_NAMES if (TREE_CODE(type) == POINTER_TYPE && TREE_CODE(TREE_TYPE(type)) == ARRAY_TYPE) { diff --git a/gcc/gcc/cross-make b/gcc/gcc/cross-make index 84be67fd60..aec2041ed3 100644 --- a/gcc/gcc/cross-make +++ b/gcc/gcc/cross-make @@ -5,7 +5,9 @@ LIBGCC1 = $(CROSS_LIBGCC1) # Dir to search for system headers. Normally /usr/include. # Use CROSS_INCLUDE_DIR not TOOL_INCLUDE_DIR for other vendor's headers. -SYSTEM_HEADER_DIR = $(tooldir)/sys-include +# SYSTEM_HEADER_DIR = $(tooldir)/sys-include +# [zooey]: gcc looks for limits.h and float.h which under BeOS live in posix subfolder: +SYSTEM_HEADER_DIR = $(tooldir)/sys-include/posix # Don't try to compile the things we can't compile. ALL = all.cross diff --git a/gcc/gcc/fixinc/fixlib.h b/gcc/gcc/fixinc/fixlib.h index 2879b3d649..e1dbd75aee 100644 --- a/gcc/gcc/fixinc/fixlib.h +++ b/gcc/gcc/fixinc/fixlib.h @@ -31,14 +31,12 @@ Boston, MA 02111-1307, USA. */ #include "tm.h" #include -#ifdef __BEOS__ #include "gnu-regex.h" #define xregcomp regcomp #define xregexec regexec #define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0])) #define TOUPPER(c) toupper((c)) #define ISIDNUM(c) (isalnum((c))||(c)=='_') -#endif #include "machname.h" #include "libiberty.h"