From 33144a643808357711f34f698e4f275b66e03f08 Mon Sep 17 00:00:00 2001 From: "Yann E. MORIN\"" Date: Sun, 6 Sep 2009 10:45:31 +0200 Subject: docs: typo in overview.txt --- docs/overview.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docs') diff --git a/docs/overview.txt b/docs/overview.txt index 11763521..3b100a18 100644 --- a/docs/overview.txt +++ b/docs/overview.txt @@ -398,7 +398,7 @@ toolchain. The libraries are built as shared libraries, because building them as static libraries has some short-comings. This poses no problem at build time, as -crosstool-NG correctly points gcc (and binutiols and gdb) to the correct +crosstool-NG correctly points gcc (and binutils and gdb) to the correct place where our own version of the libraries are installed. But it poses a problem when gcc et al. are run: the place where the libraries are is most probably not known to the host dynamic linker. Still worse, if the host system @@ -408,7 +408,7 @@ So we have to force the dynamic linker to load the correct version. We do this by using the LD_LIBRARY_PATH variable, that informs the dynamic linker where to look for shared libraries prior to searching its standard places. But we can't impose that burden on all the system (because it'd be a nightmare to -configure, and because two tolchains on the same system may use different +configure, and because two toolchains on the same system may use different versions of the libraries); so we have to do it on a per-toolchain basis. So we rename all binaries of the toolchain (by adding a dot '.' as their first -- cgit v1.2.3 From e3cc9d1b272dac8a96fd36d0581feee2ced2e82f Mon Sep 17 00:00:00 2001 From: Blair Burtan Date: Mon, 7 Sep 2009 23:12:25 +0200 Subject: docs: add a tutorial on how to build a toolchain on Mac OS-X Add a step-bystep tutorial to build a cross-toolchain on Mac OS-X. --- docs/MacOS-X.txt | 283 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 283 insertions(+) create mode 100644 docs/MacOS-X.txt (limited to 'docs') diff --git a/docs/MacOS-X.txt b/docs/MacOS-X.txt new file mode 100644 index 00000000..ecf9c6ad --- /dev/null +++ b/docs/MacOS-X.txt @@ -0,0 +1,283 @@ +Introduction +------------ + +This file introduces you to building a cross-toolchain on MacOS-X. +Apart from the crosstool-NG configuration options for the specific target, +what is important is: + - what pre-requisites to install + - how to install them + - how to work around the case-insensitivity of HFS+ + +This file was submitted by: + Blair Burtan +The original version was found at: + http://homepage.mac.com/macg3/TS7390-OSX-crosstool-instructions.txt + + +Text +---- + +Compiling cross compiler for default TS-7390 debian system on Mac OS X + +Forewarning: It's kind of a pain. Several of OS X's packages aren't good enough +so you need to install some GNU stuff. You might have an easier time using a +package manager for OS X but I prefer to compile everything from source so I'm +going to provide the instructions for that. Also there are a few little catches +with how some of the older gcc/glibc stuff compiles on OS X. + +The version of glibc on the TS-7390 default file system is 2.3.6. So we need to +make a compiler with glibc 2.3.6 or older. I guess you can pick whatever version +of gcc you want to use. I'll pick 4.1.2, which is what is included with the 7390 +debian. But you could theoretically do something newer like 4.3.3 (or older, +like 4.0.4) if you want, I think. All I know is the following works fine for gcc +4.1.2 and glibc 2.3.6. + +First, you have to install some prerequisites. Go in a temporary folder +somewhere and follow these directions. + +Some of the included OS X utilities aren't cool enough. So we need to download +and install some GNU utilities. Luckily they compile with no trouble in +Mac OS X! Nice work GNU people! + +First make sure you've installed the latest version of Xcode so you have gcc +on your Mac. + +Install GNU sed into /usr/local. Note: I believe configure defaults to +/usr/local as a prefix, but better safe than sorry. + + curl -O http://ftp.gnu.org/gnu/sed/sed-4.2.1.tar.bz2 + tar -xf sed-4.2.1.tar.bz2 + cd sed-4.2.1 + ./configure --prefix=/usr/local + make -j 2 (or 4 or whatever...# of jobs that can run in parallel... + on a dual core machine I use 4) + sudo make install + +Install GNU coreutils: + + curl -O http://ftp.gnu.org/gnu/coreutils/coreutils-7.4.tar.gz + tar -xf coreutils-7.4.tar.gz + cd coreutils-7.4 + ./configure --prefix=/usr/local + make -j 2 + sudo make install + +Install GNU libtool: + + curl -O http://ftp.gnu.org/gnu/libtool/libtool-2.2.6a.tar.gz + tar -xf libtool-2.2.6a.tar.gz + cd libtool-2.2.6 + ./configure --prefix=/usr/local + make -j 2 + sudo make install + +Install GNU awk, needed to fix a weird error in glibc compile: + + curl -O http://ftp.gnu.org/gnu/gawk/gawk-3.1.7.tar.bz2 + tar -xf gawk-3.1.7.tar.bz2 + cd gawk-3.1.7 + ./configure --prefix=/usr/local + make -j 2 + sudo make install + +Xcode doesn't come with objcopy/objdump, but you need them. Download GNU +binutils 2.19.1 and install just objcopy and objdump. Not sure how exactly to +do only them so I compile it all and copy them manually....there may be a +better way. + + curl -O http://ftp.gnu.org/gnu/binutils/binutils-2.19.1.tar.bz2 + tar -xf binutils-2.19.1.tar.bz2 + cd binutils-2.19.1 + ./configure --prefix=/usr/local + make -j 2 + sudo cp binutils/obj{dump,copy} /usr/local/bin + + +Done installing prerequisites...now do the fun stuff! + + +1) Create a disk image with Disk Utility (in /Utilities/Disk Utility). + Open it and go to File->New->Blank Disk Image. + Save As: Call it whatever you want. + Volume name: Call it CrosstoolCompile + Volume size: Go to custom and choose 2000 MB. This is a temporary image you + can delete once you're done compiling if you wish. + Volume format: Choose Mac OS Extended (Case-sensitive, journaled). + Mac OS X's default file system does not allow you to name two files + the same with different cases (abcd and ABCD) but you need this for + crosstool. So that's why we're creating a disk image. Leave everything + else the default and save it wherever you want. + +2) Create another disk image where the final toolchain will be installed. + Your crosstool needs to go on a disk image for the same reason--needs a + case sensitive file system and regular Mac OS X HFS+ is not. So we have to + make another one. Follow the steps above but set the volume name to + Crosstool and then make the volume size something like 300MB. Just make + sure you leave plenty of room for any libraries you want to add to your + cross compiler and that kind of stuff. The resulting toolchain will be about + 110 MB in size. Set the Volume Format to + Mac OS Extended (Case-sensitive, journaled). + Save this image somewhere handy. You'll be using it forever after this. + + +3) Make sure they're both mounted. + +4) cd /Volumes/CrosstoolCompile + +5) Grab crosstool-ng: + curl -O http://ymorin.is-a-geek.org/download \ + /crosstool-ng/crosstool-ng-1.4.2.tar.bz2 + (OS X doesn't come with wget by default) + +6) Expand it + tar -xf crosstool-ng-1.4.2.tar.bz2 + cd crosstool-ng-1.4.2 + +7) Build it + export PATH=/usr/local/bin:$PATH + + Make sure you do it like this. + /usr/local/bin has to come in the path BEFORE anything else. + + ./configure --local + make + +8) Configure crosstool + ./ct-ng menuconfig + +At this point you should have a screen up similar to the Linux kernel config. +Now set up options. Leave options as default if I haven't mentioned them. + +Paths and misc options: + Enable Use obsolete features + Enable Try features marked as EXPERIMENTAL + Set prefix directory to: + /Volumes/Crosstool/${CT_TARGET} + (this tells it to install on the disk image you created) + Number of parallel jobs: Multiply the number of cores you have times 2. + That's what I generally do. So my dual core can do 4 jobs. + Makes compiling the toolchain faster. + +Target options: + Target Architecture: ARM + Use EABI: Do NOT check this. The default TS Debian filesystem is OABI. + If you are doing an EABI one, you can set this to true (but may want + to do a different version of gcc/glibc) + Architecture level: armv4t + armv4t is for the EP9302. other processors you would pick the + right architecture here. + Floating point: Hardware + + I believe this is correct even though it's not really using an FPU because + the pre-EABI debian distro was compiled with hardfloat instructions so + whenever you do a floating point instruction the kernel is actually + trapping an illegal instruction error, makes for slow floating point... + EABI is so much better. + + I know hardware is the default, but I just wanted to clarify that you need + to choose hardware here. I'm pretty sure anyway. + +Toolchain Options: + Tuple's vendor string: whatever you want. + It'll be arm-yourtuple-linux-gnu when you're finished. + +Operating System: + Target OS: linux + Linux kernel version: 2.6.21.7 (best match for TS kernel!) + +binutils: + version: 2.19.1 +C compiler: + gcc + version: 4.1.2 + choose C++ below, so you can compile C++! +C-library: + glibc (NOT eglibc for this) + glibc version: 2.3.6 + Threading implementation to use: linuxthreads + +(note: nptl is better than linuxthreads, but it looks like nptl didn't support + ARM back in glibc 2.3.6? + +Exit and save config. + +Now we need to add a patch. Looks like the configure script for glibc does not +like some of apple's binutils, so we need to patch it to skip the version tests +for as and ld. Stick this patch in crosstool-ng-1.4.2/patches/glibc/2.3.6 to +skip the version test for as and ld: + +http://homepage.mac.com/macg3/300-glibc-2.3.6-configure-patch-OSX.patch + +(or see below, at the end of this file) + +--------- + +Okay, done setting up crosstool...now... + +./ct-ng build + +Sit back, relax, wait a while. Crosstool-ng will do the rest, automatically +downloading tarballs, patching them, installing them. Could take quite a long +time. The actual compiling took about 30 minutes on my older MacBook Pro. When +you're done you have a cross compiler on your disk image that you named +"Crosstool". Look in there and you're all set! + +So whenever you want to use the cross compiler, you need to mount this disk +image. You could also create an actual partition on your computer that is +Mac OS X extended case-sensitive if you wish. Then you don't need the disk +image. + +You can delete the CrosstoolCompile disk image. It was just used temporarily +while compiling everything. + +Note that I'm pretty sure gcc 4.1.2 has a bug in assembly generation that will +cause Qt 4.5 to segfault. I'm fairly sure I saw this problem before with 4.1.2. +I know for a fact that gcc 4.3.3 has the bug. This bug report: +http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39429 has the details. I adapted the +patch at the bottom to work with gcc 4.3.3. you might be able to apply it to +other gcc versions. Not sure. I think 4.0.4 does not have this bug so you might +even try compiling 4.0.4 instead of 4.1.2. Lots of options. Hope this helps, +I've struggled with this stuff a lot but it's so convenient to have a native +OS X toolchain! + + +Patch +----- + +Here is the afore-mentioned patch: + +---8<--- +Mac OS X fails configuring because its included binutils kind of suck. +This patch makes the glibc 2.3.6 configure script ignore the +installed version of as and ld. It just makes the configure +script believe that it's as version 2.13 and ld 2.13. + +Made on 2009-08-08 by Doug Brown + +--- glibc-2.3.6/configure.orig 2009-08-08 10:40:10.000000000 -0700 ++++ glibc-2.3.6/configure 2009-08-08 10:42:49.000000000 -0700 +@@ -3916,10 +3916,7 @@ else + echo $ECHO_N "checking version of $AS... $ECHO_C" >&6 + ac_prog_version=`$AS -v &1 | sed -n 's/^.*GNU assembler.* \([0-9]*\.[0-9.]*\).*$/\1/p'` + case $ac_prog_version in +- '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;; +- 2.1[3-9]*) +- ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;; +- *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;; ++ *) ac_prog_version="2.13, ok"; ac_verc_fail=no;; + + esac + echo "$as_me:$LINENO: result: $ac_prog_version" >&5 +@@ -3977,10 +3974,7 @@ else + echo $ECHO_N "checking version of $LD... $ECHO_C" >&6 + ac_prog_version=`$LD --version 2>&1 | sed -n 's/^.*GNU ld.* \([0-9][0-9]*\.[0-9.]*\).*$/\1/p'` + case $ac_prog_version in +- '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;; +- 2.1[3-9]*) +- ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;; +- *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;; ++ *) ac_prog_version="2.13, ok"; ac_verc_fail=no;; + + esac + echo "$as_me:$LINENO: result: $ac_prog_version" >&5 +---8<--- -- cgit v1.2.3 From 443f51a2dcaec99457e5797758c65e5c6c1d3664 Mon Sep 17 00:00:00 2001 From: "Yann E. MORIN\"" Date: Fri, 2 Oct 2009 22:10:38 +0200 Subject: libc/glibc: fix building for seemingly native toolchains Build glibc with -O2 as a fix/workaround to building seemingly-native toolchains. See: - docs/overview.txt - docs/known-issues.txt - http://sourceware.org/ml/crossgcc/2009-09/msg00055.html --- docs/known-issues.txt | 6 ++++-- docs/overview.txt | 16 ++++++++++++++++ scripts/build/libc/glibc.sh | 8 ++++---- 3 files changed, 24 insertions(+), 6 deletions(-) (limited to 'docs') diff --git a/docs/known-issues.txt b/docs/known-issues.txt index 3c7eaab5..757939f2 100644 --- a/docs/known-issues.txt +++ b/docs/known-issues.txt @@ -51,8 +51,10 @@ Fix: None known. Workaround: - If this happens for you, stick with glibc-2.6.1 for now. - Or investigate! :-) + It seems that using -O2 in the CFLAGS fixes the problem. It has been + confirmed in the following threads: + http://sourceware.org/ml/crossgcc/2009-09/msg00055.html (for glibc) + http://sourceware.org/ml/crossgcc/2009-10/msg00001.html (for eglibc) -------------------------------- Symptoms: diff --git a/docs/overview.txt b/docs/overview.txt index 3b100a18..8d9a6f04 100644 --- a/docs/overview.txt +++ b/docs/overview.txt @@ -28,6 +28,7 @@ Running crosstool-NG Tools wrapper Using the toolchain Toolchain types + Seemingly-native toolchains Internals Makefile front-end Kconfig parser @@ -590,6 +591,21 @@ anyway!) were all being hashed out, Canada had three national political parties. http://en.wikipedia.org/wiki/Cross_compiler +Seemingly-native toolchains | +----------------------------+ + +Seemingly-native toolchains are toolchains that target the same architecture +as the one it is built on, and on which it will run, but the machine tuple +may be different (eg i686 vs. i386, or x86_64-unknown-linux-gnu vs. +x86_64-pc-linux-gnu). This also applies if the target architecture is of the +same kind (eg. x86 vs. x86_64, or ppc vs. ppc64). + +Such toolchain is tricky to build, as the configure scripts may incorrectly +assume that files (headers and libs) from the build (or host) machine can be +used by the cross-compiler it is going to build. The problem seems to arise +only with glibc (and eglibc?) starting with version 2.7. + + _____________ / Internals / diff --git a/scripts/build/libc/glibc.sh b/scripts/build/libc/glibc.sh index a83fb253..0f60bd13 100644 --- a/scripts/build/libc/glibc.sh +++ b/scripts/build/libc/glibc.sh @@ -180,7 +180,7 @@ do_libc_headers() { libc_cv_ppc_machine=yes \ CT_DoExecLog ALL \ - make CFLAGS="-O -DBOOTSTRAP_GCC" \ + make CFLAGS="-O2 -DBOOTSTRAP_GCC" \ OBJDUMP_FOR_HOST="${CT_TARGET}-objdump" \ PARALLELMFLAGS="${PARALLELMFLAGS}" \ sysdeps/gnu/errlist.c @@ -197,7 +197,7 @@ do_libc_headers() { CT_DoExecLog ALL \ make cross-compiling=yes \ install_root=${CT_SYSROOT_DIR} \ - CFLAGS="-O -DBOOTSTRAP_GCC" \ + CFLAGS="-O2 -DBOOTSTRAP_GCC" \ ${LIBC_SYSROOT_ARG} \ OBJDUMP_FOR_HOST="${CT_TARGET}-objdump" \ PARALLELMFLAGS="${PARALLELMFLAGS}" \ @@ -325,7 +325,7 @@ do_libc_start_files() { # Please see the comment for the configure step in do_libc(). BUILD_CC="${CT_BUILD}-gcc" \ - CFLAGS="${CT_TARGET_CFLAGS} ${CT_LIBC_GLIBC_EXTRA_CFLAGS} -O " \ + CFLAGS="${CT_TARGET_CFLAGS} ${CT_LIBC_GLIBC_EXTRA_CFLAGS} -O2" \ CC="${cross_cc} ${CT_LIBC_EXTRA_CC_ARGS} ${extra_cc_args}" \ AR=${CT_TARGET}-ar \ RANLIB=${CT_TARGET}-ranlib \ @@ -457,7 +457,7 @@ do_libc() { # silly messages. GNU folks again, he? BUILD_CC="${CT_BUILD}-gcc" \ - CFLAGS="${CT_TARGET_CFLAGS} ${CT_LIBC_GLIBC_EXTRA_CFLAGS} -O" \ + CFLAGS="${CT_TARGET_CFLAGS} ${CT_LIBC_GLIBC_EXTRA_CFLAGS} -O2" \ CC="${CT_TARGET}-gcc ${CT_LIBC_EXTRA_CC_ARGS} ${extra_cc_args}" \ AR=${CT_TARGET}-ar \ RANLIB=${CT_TARGET}-ranlib \ -- cgit v1.2.3 From 1e1f247accfb508c7094294627f6f0b765b2da18 Mon Sep 17 00:00:00 2001 From: "Yann E. MORIN\"" Date: Sat, 3 Oct 2009 17:23:17 +0200 Subject: doc: update documentation, mostly eye-candy --- README | 5 ++++- docs/overview.txt | 9 ++++----- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'docs') diff --git a/README b/README index 4fe8d882..560d3d06 100644 --- a/README +++ b/README @@ -4,7 +4,7 @@ TABLE OF CONTENT / ________________/ - GETTING STARTED - - PARTICIPATING + - CONTRIBUTING - Sending a bug report - Sending patches - CREDITS @@ -22,6 +22,7 @@ You can find a (terse and WIP) documentation in docs/overview.txt. You can also point your browser to http://ymorin.is-a-geek.org/projects/crosstool + CONTRIBUTING / ____________/ @@ -87,11 +88,13 @@ Here's a typical hacking session: Note: replace' (at) ' above with a plain '@'. + CREDITS / _______/ The people that helped are listed in docs/CREDITS. Many thanks to them! :-) + KNOWN ISSUES / ____________/ diff --git a/docs/overview.txt b/docs/overview.txt index 8d9a6f04..61b4cba5 100644 --- a/docs/overview.txt +++ b/docs/overview.txt @@ -27,6 +27,7 @@ Running crosstool-NG Note on // jobs Tools wrapper Using the toolchain + The 'populate' script Toolchain types Seemingly-native toolchains Internals @@ -155,11 +156,9 @@ Stay in the directory holding the sources, and run: See below for complete usage. -Now, provided you checked-out the code, you can send me your interesting changes -by running: - svn diff - -and mailing me the result! :-P +Now, provided you used a clone of the repository, you can send me your changes. +See the file README, at the top of crosstool-NG source, for how to submit +changees. Preparing for packaging | ------------------------+ -- cgit v1.2.3