Page 1 of 1

GCC cross compiler problems

Posted: Wed Oct 21, 2009 7:38 pm
by bluechill
Here when I try to build gcc on mac os x snow leopard 10.6.1 it fails.

Code: Select all

ld: duplicate symbol _init_inline_once in libbackend.a(tree-inline.o) and tree-inline.o
collect2: ld returned 1 exit status
make[2]: *** [cc1plus-dummy] Error 1
make[1]: *** [all-gcc] Error 2
make: *** [all] Error 2
I can compile binutils fine

here is what I do
  1. follow http://wiki.osdev.org/GCC_Cross-Compiler up to gcc part
  2. export stuff and cd into gcc build-gcc directory
  3. copy gcc-g++ into gcc src directory
  4. run configure command
  5. make
then I get those unresolved symbols errors

gcc 4.4.0
binutils 2.19.1

I am using the commands give in the cross compiler tutorial and have mpfr in the gcc directory so gcc will compile it with it and have latest version of gmp.

if there is a script which works on snow leopard for making a cross compiler for i686 or i586 elf then can you also tell me that because that would help alot too.

Re: GCC cross compiler problems

Posted: Wed Oct 21, 2009 10:38 pm
by Solar

Code: Select all

ld: duplicate symbol _init_inline_once in libbackend.a(tree-inline.o) and tree-inline.o
Apparently tree-inline.o gets linked twice, once through libbackend.a and once directly.

I assume that the build process for MacOS doesn't deviate from the "normal" process enough to result in errors like this, so I wonder where the duplication comes from. In your description, two things spring to mind:
  • when you say "copy gcc-g++ into gcc src directory", do you unpack the gcc-g++ tarball in a subdirectory of the GCC tree? Note that the cross-compiler tutorial says "download both gcc-core and gcc-g++, and unpack them in the same directory".
  • try building MPFR seperately instead of copying it into the GCC source tree.
Do the problems still persist?

Re: GCC cross compiler problems

Posted: Thu Oct 22, 2009 12:24 am
by ucosty
Solar wrote:

Code: Select all

ld: duplicate symbol _init_inline_once in libbackend.a(tree-inline.o) and tree-inline.o
Apparently tree-inline.o gets linked twice, once through libbackend.a and once directly.

I assume that the build process for MacOS doesn't deviate from the "normal" process enough to result in errors like this, so
I got the same problem following the guide as I always have. I can't remember the exact workaround I used but I think I let it get to the point of failure and then removed the offending .o files from a file as to prevent it from failing.

Re: GCC cross compiler problems

Posted: Thu Oct 22, 2009 3:11 am
by Solar
Might be. I haven't tried that tutorial myself since, I think, GCC 4.1 or somesuch. (My own need for a cross-compiler has gone away.)

Re: GCC cross compiler problems

Posted: Thu Oct 22, 2009 5:13 am
by ucosty
Solar wrote:Might be. I haven't tried that tutorial myself since, I think, GCC 4.1 or somesuch. (My own need for a cross-compiler has gone away.)
The problem only seems to affect Snow Leopard (or does it also affect Leopard with the latest xcode?)

Re: GCC cross compiler problems

Posted: Thu Oct 22, 2009 5:23 am
by Solar
Apparently a known bug. If I skimmed this bug report correctly, it's a bug in the XCode linker. The report also provides patches / workarounds.

Re: GCC cross compiler problems

Posted: Thu Oct 22, 2009 6:01 am
by bluechill
the bug with apple's gcc is that it doesn't ignor duplicate symbols in static libraries like it should. and I do unpack them into the same directory.

I really want to get this to work because I've been making my operating system in vmware fusion linux and would like to do it on mac where I'm used to the os. (host os)

After a couple google searches today I found that, any work around? like would deleting the file help? or changing the make file?

Edit: mpfr doesn't compile on snow leopard either so I just put it in the directory and let gcc do it. it seems to compile mpfr fine when I do that.

Edit: nevermind found it

Re: GCC cross compiler problems

Posted: Thu Oct 22, 2009 6:12 am
by Solar
Solar wrote:Apparently a known bug. If I skimmed this bug report correctly, it's a bug in the XCode linker. The report also provides patches / workarounds.
:roll:

Re: GCC cross compiler problems

Posted: Thu Oct 22, 2009 6:24 am
by bluechill
yeah sorry it took me a little bit to find it but I'll upgrade gcc to trunk and then apply this patch.

and upgrade binutils to 2.20 instead of 2.19.1 and have a totally update to date compiler

thank you

Re: GCC cross compiler problems

Posted: Thu Oct 22, 2009 1:06 pm
by bluechill
ok now I get this

Code: Select all

gcc -g -O2  -o fixincl fixincl.o fixtests.o fixfixes.o server.o procopen.o fixlib.o fixopts.o ../libiberty/libiberty.a
ld: warning: in ../libiberty/libiberty.a, file is not of required architecture
Undefined symbols:
  "_xmalloc_set_program_name", referenced from:
      _initialize in fixincl.o
  "_xmalloc", referenced from:
      _process in fixincl.o
      _wrap_fix in fixfixes.o
      _run_shell in server.o
  "_xrealloc", referenced from:
      _run_shell in server.o
      _run_shell in server.o
      _load_file_data in fixlib.o
      _load_file_data in fixlib.o
  "_xregexec", referenced from:
      _egrep_test in fixincl.o
      _process in fixincl.o
      _process in fixincl.o
      _machine_name_test in fixtests.o
      _machine_name_test in fixtests.o
      _gnu_type_fix in fixfixes.o
      _wrap_fix in fixfixes.o
      _machine_name_fix in fixfixes.o
      _machine_name_fix in fixfixes.o
      _char_macro_def_fix in fixfixes.o
      _char_macro_use_fix in fixfixes.o
      _format_fix in fixfixes.o
  "__sch_toupper", referenced from:
      _gnu_type_fix in fixfixes.o
      _wrap_fix in fixfixes.o
  "__sch_istable", referenced from:
      _initialize in fixincl.o
      _process in fixincl.o
      _process in fixincl.o
      _main in fixincl.o
      _wrap_fix in fixfixes.o
      _char_macro_def_fix in fixfixes.o
      _char_macro_use_fix in fixfixes.o
      _format_fix in fixfixes.o
      _run_shell in server.o
  "_xcalloc", referenced from:
      _run_compiles in fixincl.o
      _run_shell in server.o
  "_xregerror", referenced from:
      _compile_re in fixlib.o
  "_xstrerror", referenced from:
      _create_file in fixincl.o
      _load_file in fixincl.o
      _load_file in fixincl.o
      _initialize in fixincl.o
      _process in fixincl.o
      _process in fixincl.o
      _process in fixincl.o
      _process in fixincl.o
      _chain_open in procopen.o
      _load_file_data in fixlib.o
  "_fdopen_unlocked", referenced from:
      _create_file in fixincl.o
      _load_file in fixincl.o
      _process in fixincl.o
      _proc2_fopen in procopen.o
      _proc2_fopen in procopen.o
  "_freopen_unlocked", referenced from:
      _initialize in fixincl.o
      _main in fixincl.o
  "_xregcomp", referenced from:
      _compile_re in fixlib.o
  "_xstrdup", referenced from:
      _run_shell in server.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[2]: *** [full-stamp] Error 1
make[1]: *** [all-fixincludes] Error 2
make: *** [all] Error 2
when I compile gcc 4.4.2 with the patch on the site there.

know why now?

I'm compiling same way on os dev gcc cross compiler tutorial non 64 bit

would adding -m32 help any?