This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

cross compiling gcc


So... I've been for several days now, attempting to build a cross
compiler for an sh4-linux arch from a laptop with
x86_64-unknown-linux-gnu.
Not a Canadian cross or anything that special. just a version of gcc
that runs on my laptop and produces executables for my
hico7760(sh4-linux).

Just to make sure I've understood it right heres what I understand about
building a cross compiler.
step 1) build the binutils
step 2) get linux headers
step 3) build a mini version of gcc
step 4) build the standard libs
step 5) use them to rebuild a full version of gcc

The following details these steps as I took them (as far as I got).

  * First I downloaded(and unpacked) all sources to /home/dev/src
  * that means binutils-2.20,linux-2.6.35,gcc-4.5.1,glibc-2.12.1, and
because I read it was good for embedded devices(and got stuck compiling
glibc) newlib-1.18.0 

  $ pwd
/home/dev/src
  $ laptop=x86_64-unknown-linux-gnu
  $ target=sh4-linux
  $ tc_dir=/home/dev/toolchain

  $ mkdir zbinutils_build
  $ cd zbinutild_build
  $ ../binutils-2.20/configure \
    --prefix=$tc_dir \
    --build=$laptop \
    --host=$laptop \
    --target=$target \
    --disable-nls \
    --disable-multilib \
    --disable-shared

  $ make
  $ make install
  $ PATH=$tc_dir/bin:$PATH
  $ cd ../

  $ cd linux-2.6.35
  $ make ARCH=sh headers_install
  $ cp -a include $tc_dir/$target/include
  $ cd $tc_dir/$target/
  $ ln -s include sys_include
  $ cd /home/dev/src

  $ mkdir zgcc_build
  $ cd zgcc_build
  $ ../gcc-4.5.1/configure \
    --prefix=$tc_dir \
    --build=$laptop \
    --host=$laptop \
    --target=$target \
    --disable-nls \
    --disable-multilib \
    --disable-shared \
    --disable-threads \
    --enable-languages=c
  $ make all-gcc
  $ make install
...
make[3]: Entering directory
`/home/dev/src/zgcc_build/libiberty/testsuite'
make[3]: Nothing to be done for `install'.
make[3]: Leaving directory
`/home/dev/src/zgcc_build/libiberty/testsuite'
make[2]: Leaving directory `/home/dev/src/zgcc_build/libiberty'
/bin/bash: line 3: cd: sh4-linux/libmudflap: No such file or directory
make[1]: *** [install-target-libmudflap] Error 1
make[1]: Leaving directory `/home/dev/src/zgcc_build'
make: *** [install] Error 2

  * can I ignore these errors?
  * I now have a mini gcc located at $tc_dir/bin/${target}-gcc , and
($tc_dir/bin being in my path) is accessible through ${target}-gcc

  $ ${target}-gcc -v
Using built-in specs.
COLLECT_GCC=sh4-linux-gcc
COLLECT_LTO_WRAPPER=/home/dev/toolchain/libexec/gcc/sh4-linux/4.5.1/lto-wrapper
Target: sh4-linux
Configured with: ../gcc-4.5.1/configure --prefix=/home/dev/toolchain
--build=x86_64-unknown-linux-gnu --host=x86_64-unknown-linux-gnu
--target=sh4-linux --disable-nls --disable-multilib --disable-shared
--disable-threads --enable-languages=c
Thread model: single
gcc version 4.5.1 (GCC)

  * I can not however build the simplest of programs. (libs are
missing... naturally... they have not been compiled)
  * the idea would then be to build glibc

  $ cd ../

  $ cd zglibc_build
  * I decided to configure glibc to install into /home/dev/cross_glibc
so I could examine the results. I would then coppy it wherever manually
later
  * this is also where I am stuck...
  $ ../glibc-2.12.1/configure \
  --prefix=/home/dev/cross_glibc \
  --host=$target \
  --build=$laptop \
  --disable-profile \
  --enable-add-ons \
  --with-tls \
  --enable-kernel=2.6.0 \
  --with-__thread \
  --with-binutils=$tc_dir/bin \
  --with-headers=$tc_dir/$target/include

checking build system type... x86_64-unknown-linux-gnu
checking host system type... sh4-unknown-linux-gnu
checking for sh4-linux-gcc... sh4-linux-gcc
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether sh4-linux-gcc accepts -g... yes
checking for sh4-linux-gcc option to accept ISO C89... unsupported
checking for gcc... gcc
checking how to run the C preprocessor... sh4-linux-gcc -E
checking for sh4-linux-g++... no
checking for sh4-linux-c++... no
checking for sh4-linux-gpp... no
checking for sh4-linux-aCC... no
checking for sh4-linux-CC... no
checking for sh4-linux-cxx... no
checking for sh4-linux-cc++... no
checking for sh4-linux-cl.exe... no
checking for sh4-linux-FCC... no
checking for sh4-linux-KCC... no
checking for sh4-linux-RCC... no
checking for sh4-linux-xlC_r... no
checking for sh4-linux-xlC... no
checking for g++... g++
configure: WARNING: using cross tools not prefixed with host triplet
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
configure: running configure fragment for add-on libidn
configure: running configure fragment for add-on nptl
checking sysdep dirs... checking for assembler gnu_indirect_function
symbol type support... yes
sysdeps/sh/elf nptl/sysdeps/unix/sysv/linux/sh/sh4
sysdeps/unix/sysv/linux/sh/sh4 nptl/sysdeps/unix/sysv/linux/sh
sysdeps/unix/sysv/linux/sh nptl/sysdeps/unix/sysv/linux
nptl/sysdeps/pthread sysdeps/pthread sysdeps/unix/sysv/linux sysdeps/gnu
sysdeps/unix/common sysdeps/unix/mman sysdeps/unix/inet
nptl/sysdeps/unix/sysv sysdeps/unix/sysv sysdeps/unix/sh
nptl/sysdeps/unix sysdeps/unix sysdeps/posix sysdeps/sh/sh4/fpu
sysdeps/sh/sh4 nptl/sysdeps/sh sysdeps/sh sysdeps/wordsize-32
sysdeps/ieee754/flt-32 sysdeps/ieee754/dbl-64 sysdeps/ieee754
sysdeps/generic/elf sysdeps/generic
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln -s works... yes
checking
whether /home/dev/toolchain/lib/gcc/sh4-linux/4.5.1/../../../../sh4-linux/bin/as is GNU as... yes
checking
whether /home/dev/toolchain/lib/gcc/sh4-linux/4.5.1/../../../../sh4-linux/bin/ld is GNU ld... yes
checking
for /home/dev/toolchain/lib/gcc/sh4-linux/4.5.1/../../../../sh4-linux/bin/as... /home/dev/toolchain/lib/gcc/sh4-linux/4.5.1/../../../../sh4-linux/bin/as
checking version
of /home/dev/toolchain/lib/gcc/sh4-linux/4.5.1/../../../../sh4-linux/bin/as... 2.20, ok
checking
for /home/dev/toolchain/lib/gcc/sh4-linux/4.5.1/../../../../sh4-linux/bin/ld... /home/dev/toolchain/lib/gcc/sh4-linux/4.5.1/../../../../sh4-linux/bin/ld
checking version
of /home/dev/toolchain/lib/gcc/sh4-linux/4.5.1/../../../../sh4-linux/bin/ld... 2.20, ok
checking for pwd... /bin/pwd
checking for sh4-linux-gcc... (cached) sh4-linux-gcc
checking version of sh4-linux-gcc... 4.5.1, ok
checking for gnumake... no
checking for gmake... no
checking for make... make
checking version of make... 3.81, ok
checking for gnumsgfmt... no
checking for gmsgfmt... no
checking for msgfmt... msgfmt
checking version of msgfmt... 0.17, ok
checking for makeinfo... makeinfo
checking version of makeinfo... 4.13, ok
checking for sed... sed
checking version of sed... 4.2.1, ok
checking for autoconf... autoconf
checking whether autoconf works... yes
checking whether ranlib is necessary... no
checking LD_LIBRARY_PATH variable... ok
checking whether GCC supports -static-libgcc... -static-libgcc
checking for bash... /bin/bash
checking for gawk... gawk
checking for perl... /usr/bin/perl
checking for install-info... /usr/sbin/install-info
checking for bison... no
checking for signed size_t type... no
checking for libc-friendly stddef.h... yes
checking whether we need to use -P to assemble .S files... no
checking whether .text pseudo-op must be used... yes
checking for assembler global-symbol directive... .globl
checking for .set assembler directive... yes
checking for assembler .type directive prefix... @
checking for assembler gnu_unique_object symbol type... yes
checking for .symver assembler directive... yes
checking for ld --version-script... yes
checking for .previous assembler directive... yes
checking for .protected and .hidden assembler directive... yes
checking whether __attribute__((visibility())) is supported... yes
checking for broken __attribute__((visibility()))... no
checking for broken __attribute__((alias()))... no
checking whether to put _rtld_local into .sdata section... yes
checking for .preinit_array/.init_array/.fini_array support... yes
checking for libunwind-support in compiler... no
checking for -z nodelete option... yes
checking for -z nodlopen option... yes
checking for -z initfirst option... yes
checking for -Bgroup option... yes
checking for libgcc_s suffix... 
checking for --as-needed option... no
checking whether --noexecstack is desirable for .S files... yes
checking for -z combreloc... yes
checking for -z execstack... yes
checking for -fpie... no
checking for --hash-style option... yes
checking for -fno-toplevel-reorder -fno-section-anchors... yes
checking for -fstack-protector... no
checking for -fgnu89-inline... yes
checking whether cc puts quotes around section names... no
checking for assembler .weak directive... yes
checking whether CFI directives are supported... yes
checking for ld --no-whole-archive... yes
checking for gcc -fexceptions... yes
checking for __builtin_expect... no
checking for __builtin_memset... no
checking for redirection of built-in functions... yes
checking for __thread... yes
checking for tls_model attribute... yes
checking for libgd... no
checking for is_selinux_enabled in -lselinux... no
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... no
checking for sys/types.h... no
checking for sys/stat.h... no
checking for stdlib.h... no
checking for string.h... no
checking for memory.h... no
checking for strings.h... no
checking for inttypes.h... no
checking for stdint.h... no
checking for unistd.h... no
checking size of long double... 0
running configure fragment for sysdeps/sh/elf
checking for SH TLS support... yes
running configure fragment for nptl/sysdeps/pthread
checking for forced unwind support... no
configure: error: forced unwind support is required

################################################ config.log

configure:27: checking for forced unwind support
configure:56: sh4-linux-gcc -o conftest -g -O2   conftest.c  >&5
/home/dev/toolchain/lib/gcc/sh4-linux/4.5.1/../../../../sh4-linux/bin/ld: crt1.o: No such file: No such file or directory
collect2: ld returned 1 exit status
configure:63: $? = 1
configure: failed program was:
| /* confdefs.h.  */
| #define PACKAGE_NAME "GNU C Library"
| #define PACKAGE_TARNAME "c-library"
| #define PACKAGE_VERSION "(see version.h)"
| #define PACKAGE_STRING "GNU C Library (see version.h)"
| #define PACKAGE_BUGREPORT "glibc"
| #define HAVE_LIBIDN 1
| #define ASM_GLOBAL_DIRECTIVE .globl
| #define HAVE_ASM_SET_DIRECTIVE 1
| #define ASM_TYPE_DIRECTIVE_PREFIX @
| #define HAVE_ASM_UNIQUE_OBJECT 1
| #define DO_VERSIONING 1
| #define HAVE_ASM_PREVIOUS_DIRECTIVE 1
| #define HAVE_SDATA_SECTION 1
| #define HAVE_Z_COMBRELOC 1
| #define NO_UNDERSCORES 1
| #define HAVE_ASM_WEAK_DIRECTIVE 1
| #define HAVE_ASM_CFI_DIRECTIVES 1
| #define HAVE_BUILTIN_REDIRECTION 1
| #define HAVE___THREAD 1
| #define HAVE_TLS_MODEL_ATTRIBUTE 1
| #define SIZEOF_LONG_DOUBLE 0
| #define HAVE_TLS_SUPPORT 1
| #define PI_STATIC_AND_HIDDEN 1
| /* end confdefs.h.  */
| #include <unwind.h>
| int
| main ()
| {
| 
| struct _Unwind_Exception exc;
| struct _Unwind_Context *context;
| _Unwind_GetCFA (context)
|   ;
|   return 0;
| }
configure:83: result: no
configure:158: error: forced unwind support is required

So the reaon this test fails is not necessarily because forced unwind
support is missing, but because crt1.o is...
I understand its gcc that tells ld where to look, so heres the output of
${target}-gcc -print-search-dirs
  $ ${target}-gcc -print-search-dirs
install: /home/dev/toolchain/lib/gcc/sh4-linux/4.5.1/
programs:
=/home/dev/toolchain/libexec/gcc/sh4-linux/4.5.1/:/home/dev/toolchain/libexec/gcc/sh4-linux/4.5.1/:/home/dev/toolchain/libexec/gcc/sh4-linux/:/home/dev/toolchain/lib/gcc/sh4-linux/4.5.1/:/home/dev/toolchain/lib/gcc/sh4-linux/:/home/dev/toolchain/lib/gcc/sh4-linux/4.5.1/../../../../sh4-linux/bin/sh4-linux/4.5.1/:/home/dev/toolchain/lib/gcc/sh4-linux/4.5.1/../../../../sh4-linux/bin/
libraries:
=/home/dev/toolchain/lib/gcc/sh4-linux/4.5.1/:/home/dev/toolchain/lib/gcc/sh4-linux/4.5.1/../../../../sh4-linux/lib/sh4-linux/4.5.1/:/home/dev/toolchain/lib/gcc/sh4-linux/4.5.1/../../../../sh4-linux/lib/!m4/:/home/dev/toolchain/lib/gcc/sh4-linux/4.5.1/../../../../sh4-linux/lib/

and indeed none of these dirs include the file "crt1.o"
What do I do now? did I miss something while building gcc?
already mentioned above... gcc never successfully installed.
  /bin/bash: line 3: cd: sh4-linux/libmudflap: No such file or directory

I have not built this. what is this for? does it contain crt1.o?
I hope to get to the bottom of this.

It can't honestly be that hard to build a cross compiler.
I must be doing something or other wrong.

I wait patiently (and thankfully) for your advice.

Thanks,
Max, S.

p.s. I can make available the entire output of the configure logs or
other things you may be interested in... but this email is already very
very long.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]