public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* building a crosscompiler drives me mad
@ 2006-04-15 15:47 sp4rc
  2006-04-16  6:43 ` Niklaus
  0 siblings, 1 reply; 3+ messages in thread
From: sp4rc @ 2006-04-15 15:47 UTC (permalink / raw)
  To: gcc-help

Dear list-members and gcc-gurus,

I am trying to build a crosscompiler on a NetBSD 3.0 (i386) system for a
Gentoo Linux (i386) system. These are the steps I have performed. 

[+] The versions I am using:
binutils-2.15
gcc-3.4.5
glibc-2.3.5
linux-2.6.8

[+] The machine I am trying to compile gcc on
# uname -va 
NetBSD hydra.pentacon.gov 3.0 NetBSD 3.0 (MYKERNEL.MP) #1: Sat Mar  4
17:20:08 CET 2006
root@hydra.pentacon.gov:/usr/src/sys/arch/i386/compile/MYKERNEL.MP i386

[+] Building the binutils:
# ./configure --prefix=/home/sammy/crossdev --target=i686-pc-linux-gnu 
# make install

[+][+] Copying the libs and headers to there proper place.

[+] from glibc
# cp -Ri include /home/sammy/crossdev/i686-pc-linux-gnu/

[+] from the linux kernel src
# cp -Ri linux/include/linux \
/home/sammy/crossdev/i686-pc-linux-gnu/include/linux

# cp -Ri linux/include/asm-i386 \
/home/sammy/crossdev/i686-pc-linux-gnu/include/asm

[+] copy the libraries 
# cp -Ri lib/* /home/sammy/crossdev/i686-pc-linux-gnu/lib
# cp -Ri usr/lib/* /home/sammy/crossdev/i686-pc-linux-gnu/lib

[+] The actual gcc build
# ./configure \
--prefix=/home/sammy/crossdev \
--target=i686-pc-linux-gnu \
--with-gnu-ld \
--with-ld=/home/sammy/crossdev/i686-pc-linux-gnu-ld \
--with-gnu-as \
--with-as=/home/sammy/crossdev/i686-pc-linux-gnu-as

# make -j6 (tried it although without the -j option)

[...]

/home/sammy/crossdev/i686-pc-linux-gnu/include/signal.h:5:28:
signal/signal.h: No such file or directory
In file included from ../../gcc/config/i386/linux.h:217,
                 from ./tm.h:11,
                 from ../../gcc/libgcc2.c:43:
/home/sammy/crossdev/i686-pc-linux-gnu/include/signal.h:8: error: syntax
error before "libc_hidden_proto"
/home/sammy/crossdev/i686-pc-linux-gnu/include/signal.h:9: error: syntax
error before "libc_hidden_proto"
/home/sammy/crossdev/i686-pc-linux-gnu/include/signal.h:10: error:
syntax error before "libc_hidden_proto"


[...]

/home/sammy/crossdev/i686-pc-linux-gnu/include/signal.h:27: error:
storage class specified for parameter `__sigsuspe
nd'
/home/sammy/crossdev/i686-pc-linux-gnu/include/signal.h:39: error:
storage class specified for parameter `__sigvec'
/home/sammy/crossdev/i686-pc-linux-gnu/include/signal.h:40: error:
storage class specified for parameter `__sigretur
n'
/home/sammy/crossdev/i686-pc-linux-gnu/include/signal.h:42: error:
storage class specified for parameter `__sigaltst
ack'
/home/sammy/crossdev/i686-pc-linux-gnu/include/signal.h:44: error:
storage class specified for parameter `__libc_sig
action'
/home/sammy/crossdev/i686-pc-linux-gnu/include/signal.h:45: error:
syntax error before "libc_hidden_proto"
/home/sammy/crossdev/i686-pc-linux-gnu/include/signal.h:48: error:
storage class specified for parameter `__default_
sigpause'
/home/sammy/crossdev/i686-pc-linux-gnu/include/signal.h:49: error:
storage class specified for parameter `__xpg_sigp
ause'
/home/sammy/crossdev/i686-pc-linux-gnu/include/signal.h:57: error:
storage class specified for parameter `__libc_all
ocate_rtsig'
In file included from ./tm.h:11,
                 from ../../gcc/libgcc2.c:43:
../../gcc/config/i386/linux.h:218:26: sys/ucontext.h: No such file or
directory
In file included from ../../gcc/libgcc2.c:56:
../../gcc/libgcc2.h:33: error: storage class specified for parameter
`__gcc_bcmp'
../../gcc/libgcc2.h:34: error: storage class specified for parameter
`__clear_cache'
../../gcc/libgcc2.h:36: error: storage class specified for parameter
`__eprintf'
../../gcc/libgcc2.h:38: warning: empty declaration
../../gcc/libgcc2.h:39: error: storage class specified for parameter
`__get_eh_table_language'
../../gcc/libgcc2.h:40: error: storage class specified for parameter
`__get_eh_table_version'
../../gcc/libgcc2.h:67: error: storage class specified for parameter
`QItype'
../../gcc/libgcc2.h:68: error: storage class specified for parameter
`UQItype'
../../gcc/libgcc2.h:69: error: storage class specified for parameter
`HItype'


[...]


../../gcc/libgcc2.h:302: error: storage class specified for parameter
`DItype'
../../gcc/libgcc2.h:302: error: redefinition of parameter 'DItype'
../../gcc/libgcc2.h:297: error: previous definition of 'DItype' was here
../../gcc/libgcc2.h:302: error: syntax error before "__fixunsdfdi"
../../gcc/libgcc2.h:303: warning: type defaults to `int' in declaration
of `DItype'
../../gcc/libgcc2.h:303: error: storage class specified for parameter
`DItype'
../../gcc/libgcc2.h:303: error: redefinition of parameter 'DItype'
../../gcc/libgcc2.h:302: error: previous definition of 'DItype' was here
../../gcc/libgcc2.h:303: error: syntax error before "__fixunssfdi"
../../gcc/libgcc2.h:306: warning: type defaults to `int' in declaration
of `DItype'
../../gcc/libgcc2.h:306: error: storage class specified for parameter
`DItype'
../../gcc/libgcc2.h:306: error: redefinition of parameter 'DItype'
../../gcc/libgcc2.h:303: error: previous definition of 'DItype' was here
../../gcc/libgcc2.h:306: error: syntax error before "__fixxfdi"
../../gcc/libgcc2.h:307: warning: type defaults to `int' in declaration
of `DItype'
../../gcc/libgcc2.h:307: error: storage class specified for parameter
`DItype'
../../gcc/libgcc2.h:307: error: redefinition of parameter 'DItype'
../../gcc/libgcc2.h:306: error: previous definition of 'DItype' was here
../../gcc/libgcc2.h:307: error: syntax error before "__fixunsxfdi"
../../gcc/libgcc2.h:308: warning: type defaults to `int' in declaration
of `XFtype'
../../gcc/libgcc2.h:308: error: storage class specified for parameter
`XFtype'
../../gcc/libgcc2.h:308: error: conflicting types for 'XFtype'
../../gcc/libgcc2.h:93: error: previous definition of 'XFtype' was here
../../gcc/libgcc2.h:308: error: syntax error before "__floatdixf"
../../gcc/libgcc2.h:309: warning: type defaults to `int' in declaration
of `USItype'
../../gcc/libgcc2.h:309: error: storage class specified for parameter
`USItype'
../../gcc/libgcc2.h:309: error: redefinition of parameter 'USItype'
../../gcc/libgcc2.h:301: error: previous definition of 'USItype' was
here
../../gcc/libgcc2.h:309: error: syntax error before "__fixunsxfsi"
../../gcc/libgcc2.h:325: error: syntax error before "SItype"
../../gcc/libgcc2.h:325: warning: no semicolon at end of struct or union
../../gcc/libgcc2.h:334: error: field `s' has incomplete type
../../gcc/libgcc2.h:335: error: syntax error before "DItype"
../../gcc/libgcc2.h:335: warning: no semicolon at end of struct or union
../../gcc/libgcc2.c:1137: warning: type defaults to `int' in declaration
of `DWunion'
../../gcc/libgcc2.c:1137: error: syntax error before "bu"

Which libs am I missing? Is there anything else I have missed?
I would be very pleased if someone could help me with this. Please 
let me know if you need any other information.

-- 

/sp4rc

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: building a crosscompiler drives me mad
  2006-04-15 15:47 building a crosscompiler drives me mad sp4rc
@ 2006-04-16  6:43 ` Niklaus
  2006-04-17 23:00   ` Kai Ruottu
  0 siblings, 1 reply; 3+ messages in thread
From: Niklaus @ 2006-04-16  6:43 UTC (permalink / raw)
  To: sp4rc; +Cc: gcc-help

On 4/15/06, sp4rc <sammyshome@gmx.net> wrote:
> Dear list-members and gcc-gurus,
>
> I am trying to build a crosscompiler on a NetBSD 3.0 (i386) system for a
> Gentoo Linux (i386) system. These are the steps I have performed.
>
> [+] The versions I am using:
> binutils-2.15
> gcc-3.4.5
> glibc-2.3.5
> linux-2.6.8

Binutils should build without a problem.
1) Binutils
2) Copy linux headers  after you do make config. This is important
because certain files are generated i think. Also you have to copy
asm-i386, asm-generic , linux inside include .
I assume that you know the proper directory . It is $prefix/$target/include/

then you have to do make install-headers for glibc. that is copying
the proper headers from glibc.

then build the  gcc stage1.
then build glibc with gcc-stage1.
Then build gcc-stage2.

I find you not copying asm-generic. Also you want to look at
crosstool.sh of Dan kegel's crosstool. It is all automated in it.

I suggest you download crosstool and build you required thing. if not
the below script can give you some idea. I haven't done the error
checks properly.  You should run it with sh script.sh mips.

Also the .config file is the one generated by doing a make ARCH=mips
menuconfig. So you will have to do it for your kernel and copy the
.config. The second file Makeconfig has -lgcc_eh commented . If you
get to that stage of glibc you have to comment -lgcc_egh in Makeconfig
of glibc.

Happy cross compiling.


#!/bin/sh
echo $1
if [ "$1" = "" ]
then
	echo "run the file as sh script.sh mips when target is mips"
	exit
fi

targ=$1
PRE=`pwd`
echo $PRE
mkdir cross build
FPRE=$PRE/cross/
HEAD=$PRE/cross/${targ}-deb-linux/include
mkdir -p $HEAD

mkdir -p $PRE/downloads
cd downloads
wget -c ftp://ftp.gnu.org/pub/gnu/glibc/glibc-2.3.4.tar.bz2
wget -c ftp://ftp.gnu.org/pub/gnu/glibc/glibc-linuxthreads-2.3.4.tar.bz2
tar xvjf glibc-2.3.4.tar.bz2
tar xvjf glibc-linuxthreads-2.3.4.tar.bz2 -C glibc-2.3.4
mv glibc-2.3.4 glibc
wget -c ftp://ftp.gnu.org/pub/gnu/binutils/binutils-2.16.tar.bz2
wget -c ftp://ftp.gnu.org/pub/gnu/gcc/gcc-3.4.6/gcc-3.4.6.tar.bz2
tar xvjf binutils-2.16.tar.bz2
mv binutils-2.16 binu
tar xvjf gcc-3.4.6.tar.bz2
mv gcc-3.4.6 gcc
wget -c http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.16.1.tar.bz2
tar xvjf linux-2.6.16.1.tar.bz2
mv linux-2.6.16.1 linux

cd linux
cp $PRE/.config .
make ARCH=$1 oldconfig
make ARCH=$1 include/asm include/linux/version.h


cp -r include/asm-generic $HEAD/asm-generic
cp -r include/linux $HEAD
cp -r include/asm-${targ} $HEAD/asm


FRES=$PRE/downloads
FTARG=${targ}-deb-linux
SYSR=$FPRE/$FTARG/
cd $PRE
cp $PRE/Makeconfig  $FRES/glibc
cd build
mkdir binbuild gcc-core glibc-headers gcc-comp glibc-comp

cd binbuild
$FRES/binu/configure --target=$FTARG --prefix=$FPRE --disable-nls
--with-sysroot=$SYSR

make all
if [ $? -ne 0 ]
then
	echo "Something went wrong in Make all of binutils. Please check"
	echo "exiting .... "
	exit
fi

make install
if [ $? -ne 0 ]
then
	echo "Something went wrong in make install of binutils. Please check"
	echo "exiting .... "
	exit
fi

cd ..

echo "now building gcc-core boot strap compiler"
OLDPATH=$PATH
export PATH=$FPRE/bin:$PATH
cd gcc-core
$FRES/gcc/configure --target=$FTARG --prefix=$FPRE
--with-local-prefix=$SYSR --disable-multilib \
--with-newlib --disable-nls --without-headers --disable-nls
--enable-threads=no --enable-symvers=gnu \
--enable-__cxa_atexit --enable-languages=c --disable-shared

make all-gcc
if [ $? -ne 0 ]
then
	echo "Something went wrong in Make all of core-gcc. Please check"
	echo "exiting .... "
	exit
fi

make install-gcc
if [ $? -ne 0 ]
then
	echo "Something went wrong in Make install of core-gcc. Please check"
	echo "exiting .... "
	exit
fi

cd ..

cd glibc-headers
libc_cv_ppc_machine=yes \
CC="${targ}-deb-linux-gcc " \
$FRES/glibc/configure --prefix=/usr \
--host=$FTARG --without-cvs --disable-sanity-checks --with-headers=$HEAD \
--enable-hacker-mode

if [ $? -ne 0 ]
then
	echo "Something went wrong in configure of binutils-headers. Please check"
	echo "exiting .... "
	exit
fi


libc_cv_ppc_machine=yes \
make CFLAGS=-DBOOTSTRAP_GCC sysdeps/gnu/errlist.c
mkdir -p stdio-common
touch stdio-common/errlist-compat.c
if [ $? -ne 0 ]
then
	echo "Something went wrong in make errlist of glibc-headers. Please check"
	echo "exiting .... "
	exit
fi

libc_cv_ppc_machine=yes \
make cross-compiling=yes install_root=$SYSR CFLAGS=-DBOOTSTRAP_GCC
install-headers
if [ $? -ne 0 ]
then
	echo "Something went wrong in make install-headers of glibc-headers.
Please check"
	echo "exiting .... "
	exit
fi

mkdir -p $HEAD/gnu
touch $HEAD/gnu/stubs.h
cp $FRES/glibc/include/features.h $HEAD/features.h
mkdir -p $HEAD/bits
cp bits/stdio_lim.h $HEAD/bits/stdio_lim.h

cd ..

echo " now building glibc complete"

cd glibc-comp

BUILD_CC=gcc CC="${FTARG}-gcc " AR=${FTARG}-ar \
RANLIB=${FTARG}-ranlib \
$FRES/glibc/configure  --prefix=/usr \
--host=$FTARG --with-sysroot=$SYSR --without-cvs \
--disable-profile --disable-debug --without-gd --enable-shared \
--enable-add-ons=linuxthreads, --with-headers=$HEAD

make LD=${FTARG}-ld RANLIB=${FTARG}-ranlib all
if [ $? -ne 0 ]
then
	echo "Something went wrong in make  of glibc-make . Please check"
	echo "exiting .... "
	exit
fi
make install_root=$SYSR install
if [ $? -ne 0 ]
then
	echo "Something went wrong in make install of glibc-comp. Please check"
	echo "exiting .... "
	exit
fi

cd ..
cd gcc-comp
$FRES/gcc/configure --target=${FTARG} --prefix=${FPRE}/
--with-sysroot=$SYSR/ --enable-local-prefix=$SYSR/ \
--disable-nls --enable-threads=posix --enable-symvers=gnu
--enable-__cxa_atexit \
--enable-languages=c,c++ --enable-shared --enable-c99 --enable-long-long

make all
if [ $? -ne 0 ]
then
	echo "Something went wrong in make  of gcc-comp-make . Please check"
	echo "exiting .... "
	exit
fi
make install
if [ $? -ne 0 ]
then
	echo "Something went wrong in make  of gcc-comp-install . Please check"
	echo "exiting .... "
	exit
fi
cd ..

echo "Your build environment is in cross . Successfully installed.
What a thing."

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: building a crosscompiler drives me mad
  2006-04-16  6:43 ` Niklaus
@ 2006-04-17 23:00   ` Kai Ruottu
  0 siblings, 0 replies; 3+ messages in thread
From: Kai Ruottu @ 2006-04-17 23:00 UTC (permalink / raw)
  To: sp4rc; +Cc: gcc-help

Niklaus kirjoitti:
> On 4/15/06, sp4rc <sammyshome@gmx.net> wrote:
>   
>> Dear list-members and gcc-gurus,
>>
>> I am trying to build a crosscompiler on a NetBSD 3.0 (i386) system for a
>> Gentoo Linux (i386) system. These are the steps I have performed.
>>
>> [+] The versions I am using:
>> binutils-2.15
>> gcc-3.4.5
>> glibc-2.3.5
>>     
The "Gentoo Linux" most probably already has a built & tested 
glibc-2.3.5 for it !  Or then it is totally
different from Red Hat & Fedora, SuSE, Mandriva, Debian, Ubuntu etc. 
usual "Linux distros"...
>> linux-2.6.8
>>     
 Where you think to require the Linux kernel headers and why the Gentoo 
Linux doesn't provide them is
also quite weird...   RedHat&Fedora has had them in a 
'kernel-headers-x.y.z.rpm' package, SuSE and
Debian have these included into the glibc packages.

> Binutils should build without a problem.
> 1) Binutils
>   

My advice for the next step would be :

 2. copy the Gentoo Linux's own binary 'glibc-2.3.5' packages into your 
NetBSD host and install the "target C
     library" in them into the same place where the target binutils are 
now (in 'bin' there).  This is the '$tooldir' ,
     which is the same as '$prefix/$target'...
 
> 2) Copy linux headers  after you do make config. This is important
> because certain files are generated i think. Also you have to copy
> asm-i386, asm-generic , linux inside include .

 Copying the whole "target C library", all headers, libraries and 
startups from 'glibc-2.3.5', 'glibc-devel-2.3.5'
etc. packages for the target should be quite usual practice with all the 
Linux (distro) target crosscompilers...

> then you have to do make install-headers for glibc. that is copying
> the proper headers from glibc.
>
> then build the  gcc stage1.
> then build glibc with gcc-stage1.
> Then build gcc-stage2.
>
> I find you not copying asm-generic. Also you want to look at
> crosstool.sh of Dan kegel's crosstool. It is all automated in it.
>   
 Automated "bolshevism"?   This expects the target system being totally 
unexisting.  Or being totally neglected
as if it never had existed.  The original bolsheviks had this idea about 
not using anything from the bad capitalism,
creating a better and perfect world from absolute scratch....  I have 
always wondered where this "from scratch"
starts from.... NetBSD has sources for its GCC, its C library, tools 
etc. so maybe one should start on a system
which absolutely has no "pristine sources" for anything, so nothing 
could require this "build from pristine sources"
approach...  The usual explanation afterwards for the miserable failures 
(millions died in hunger etc.) has been
that "the idea was good but the implementation was bad" for the original 
bolshevism...  We will see how long
this new bolshevism will stay and people continue to believe in it...

 So instead of thinking that the Gentoo Linux doesn't yet exist and 
therefore everything for it should be built from
scratch, one could think that there are no sources available for 
anything the Gentoo Linux has, so one must be
happy with the available binaries for Gentoo Linux, its glibc-2.3.5 
binaries, its X11 libraries binaries, its Gnome
libraries binaries, whatever libraries one thinks to need in the 
crosstoolchain for Gentoo Linux...  This would be
the case if the target would be AIX, HP-UX, Irix or some other 
commercial Unix... No sources for their own libs.

 That Linux has its shared libs mainly in '/lib' but the startups and 
static libs in '/usr/lib', can be a small problem, but
when one sees that almost everything in '/lib' was symlinked to be seen 
in '/usr/lib', then putting stuff for both into
the '$prefix/$target/lib' shouldn't be that hard.  Or first unpacking a 
"1:1" image for the native glibc install  below
some '$sysroot', into 'lib', 'usr/lib', 'usr/include' etc. there.  My 
standard $sysroot name is '/opt/host-$target', for
instance '/opt/host-i686-gentoo-linux' with this "Gentoo Linux/x86" case 
could be my choice.  And then symlink
the '/opt/host-i686-gentoo-linux/usr/include' and 
'/opt/host-i686-gentoo-linux/usr/lib' to be seen as the
'$prefix/i686-gentoo-linux/include' and '$prefix/i686-gentoo-linux/lib' 
because the crosscompiler searches the
target headers and libraries from them....

 One existing (and long-standing) GCC bug requires the target headers 
being seen also in the
'$prefix/$target/sys-include'  (although the GCC manuals have told the 
'include' being enough) during the GCC
build (not after its installation), but this is another issue.  
Basically the target stuff (binutils, headers, libs) being
below the '$prefix/$target' in 'bin', 'include' and 'lib' should be 
enough and the GCC build should succeed....
Furthermore the Linux's 'libc.so' is somehow "one eyed" and expects only 
native installations and therefore has
'/lib/libc.so.6 /usr/lib/libc_nonshared.a' there, so one must edit the 
absolute pathnames away and leave only the
file names into a 'libc.so' used in a crosstoolchain...

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-04-17 23:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-15 15:47 building a crosscompiler drives me mad sp4rc
2006-04-16  6:43 ` Niklaus
2006-04-17 23:00   ` Kai Ruottu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).