Page 1 of 1

Can't Compile binutils Under OS X Lion

Posted: Sat Feb 09, 2013 9:00 am
by Nathan
I've been trying to build the cross-compiler on OS X Lion, but for some reason binutils is failing to compile. When I run make all, this is what I get after a while:

Code: Select all

loading cache .././config.cache
checking whether to enable maintainer-specific portions of Makefiles... no
checking whether to install libbfd... no
checking for executable suffix... (cached) .dSYM
checking for gcc... (cached) /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2
checking whether the C compiler (/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2 -g -O2 ) works... no
configure: error: installation or configuration problem: C compiler cannot create executables.
make: * [configure-opcodes] Error 1
Looking at the config.log this is what I got:

Code: Select all

configure:565: checking for Cygwin environment
configure:598: checking for mingw32 environment
configure:675: checking host system type
configure:696: checking target system type
configure:714: checking build system type
configure:739: checking for gcc
configure:852: checking whether the C compiler (/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2 -g -O2 ) works
configure:868: /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2 -o conftest -g -O2   conftest.c  1>&5
configure:894: checking whether the C compiler (/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2 -g -O2 ) is a cross-compiler
configure:899: checking whether we are using GNU C
configure:927: checking whether /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2 accepts -g
configure:959: checking for POSIXized ISC
configure:997: checking for a BSD compatible install
configure:1050: checking whether build environment is sane
configure:1107: checking whether make sets ${MAKE}
configure:1153: checking for working aclocal
configure:1166: checking for working autoconf
configure:1179: checking for working automake
configure:1192: checking for working autoheader
configure:1205: checking for working makeinfo
configure:1228: checking for ar
configure:1260: checking for ranlib
configure:1407: checking for ld used by GCC
configure:1475: checking if the linker (/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2) is GNU ld
configure:1492: checking for /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2 option to reload object files
configure:1504: checking for BSD-compatible nm
configure:1542: checking whether ln -s works
configure:1563: checking how to recognise dependant libraries
configure:1736: checking for object suffix
configure:1762: checking for executable suffix
configure:1932: checking for ranlib
configure:1999: checking for strip
ltconfig:678:checking for /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2 option to produce PIC
ltconfig:687:checking that /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2 PIC flag  -fPIC -DPIC works.
ltconfig:749: checking if /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2 static flag  works
ltconfig:780: finding the maximum length of command line arguments
ltconfig:@lineno@: result: 98305
ltconfig:887: checking if /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2 supports -fno-rtti -fno-exceptions
ltconfig:888: /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2 -c -g -O2 -fno-rtti -fno-exceptions -c conftest.c  conftest.c 1>&5
ltconfig:1431: checking if global_symbol_pipe works
ltconfig:1432: /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2 -c -g -O2  conftest.c 1>&5
ltconfig:1435: eval "nm conftest.o | sed -n -e 's/^.*[  ]\([BCDEGRST][BCDEGRST]*\)[     ][  ]*\(\)\([_A-Za-z][_A-Za-z0-9]*\)$/\1 \2\3 \3/p' > conftest.nm"
cannot find nm_test_var in conftest.nm
ltconfig:1431: checking if global_symbol_pipe works
ltconfig:1432: /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2 -c -g -O2  conftest.c 1>&5
ltconfig:1435: eval "nm conftest.o | sed -n -e 's/^.*[  ]\([BCDEGRST][BCDEGRST]*\)[     ][  ]*\(_\)\([_A-Za-z][_A-Za-z0-9]*\)$/\1 \2\3 \3/p' > conftest.nm"
ltconfig:1487: /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2 -o conftest -g -O2 -fno-builtin   conftest.c conftstm.o 1>&5
configure:2338: checking whether to enable maintainer-specific portions of Makefiles
configure:2361: checking whether to install libbfd
configure:2398: checking for executable suffix
configure:2434: checking for gcc
configure:2547: checking whether the C compiler (/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2 -g -O2 ) works
configure:2563: /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2 -o conftest.dSYM -g -O2   conftest.c  1>&5
ld: can't open output file for writing: conftest.dSYM, errno=21 for architecture x86_64
collect2: ld returned 1 exit status
configure: failed program was:

#line 2558 "configure"
#include "confdefs.h"

main(){return(0);}
Any clue about how to solve this?

Re: Can't Compile binutils Under OS X Lion

Posted: Sat Feb 09, 2013 12:29 pm
by BenjiWiebe
Try changing the directory into the directory where config.log is located, and delete the directory conftest.dSYM because errno=21 is 'Error: is a directory'. Then re-run configure.

Re: Can't Compile binutils Under OS X Lion

Posted: Sat Feb 09, 2013 12:56 pm
by Nathan
Did and got the same error. The compiler is creating these .dSYM files and ld is using it instead of the .o:

Code: Select all

checking for executable suffix... (cached) .dSYM
Shouldn't that be .o?

Re: Can't Compile binutils Under OS X Lion

Posted: Sat Feb 09, 2013 12:59 pm
by BenjiWiebe
Nathan wrote:Did and got the same error. The compiler is creating these .dSYM files and ld is using it instead of the .o:

Code: Select all

checking for executable suffix... (cached) .dSYM
Shouldn't that be .o?
Yes, it should be.

Re: Can't Compile binutils Under OS X Lion

Posted: Sat Feb 09, 2013 1:11 pm
by Nathan
Is there anyway to override that?

Re: Can't Compile binutils Under OS X Lion

Posted: Sat Feb 09, 2013 1:19 pm
by BenjiWiebe
Nathan wrote:Is there anyway to override that?
I think you could edit the configure script and hard code it. I have done things like that sometimes.

Re: Can't Compile binutils Under OS X Lion

Posted: Sat Feb 09, 2013 1:25 pm
by Nathan
I've changed it in config.cache and it's working, but now what I'm getting is this:

Code: Select all

/usr/local/Cellar/gcc/4.7.2/bin/gcc-4.7 -DHAVE_CONFIG_H -I. -I. -I. -D_GNU_SOURCE -I. -I. -I../bfd -I./../bfd -I./../include -I./../intl -I../intl -DLOCALEDIR="\"/usr/local/i586-elf/share/locale\"" -Dbin_dummy_emulation=bin_vanilla_emulation   -W -Wall -Wstrict-prototypes -Wmissing-prototypes -g -O2 -c filemode.c
/bin/sh ./libtool --mode=link /usr/local/Cellar/gcc/4.7.2/bin/gcc-4.7 -W -Wall -Wstrict-prototypes -Wmissing-prototypes -g -O2  -o size.o  size.o bucomm.o version.o filemode.o ../bfd/libbfd.la ../libiberty/libiberty.a  
mkdir .libs
libtool: link: `../bfd/libbfd.la' is not a convenience library
make[3]: *** [size.o] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive-am] Error 2
make: *** [all-binutils] Error 2

Re: Can't Compile binutils Under OS X Lion

Posted: Sat Feb 09, 2013 1:29 pm
by BenjiWiebe
Nathan wrote:I've changed it in config.cache and it's working, but now what I'm getting is this:

Code: Select all

/usr/local/Cellar/gcc/4.7.2/bin/gcc-4.7 -DHAVE_CONFIG_H -I. -I. -I. -D_GNU_SOURCE -I. -I. -I../bfd -I./../bfd -I./../include -I./../intl -I../intl -DLOCALEDIR="\"/usr/local/i586-elf/share/locale\"" -Dbin_dummy_emulation=bin_vanilla_emulation   -W -Wall -Wstrict-prototypes -Wmissing-prototypes -g -O2 -c filemode.c
/bin/sh ./libtool --mode=link /usr/local/Cellar/gcc/4.7.2/bin/gcc-4.7 -W -Wall -Wstrict-prototypes -Wmissing-prototypes -g -O2  -o size.o  size.o bucomm.o version.o filemode.o ../bfd/libbfd.la ../libiberty/libiberty.a  
mkdir .libs
libtool: link: `../bfd/libbfd.la' is not a convenience library
make[3]: *** [size.o] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive-am] Error 2
make: *** [all-binutils] Error 2
IDK, maybe try

Code: Select all

rm -f ../bfd/libbfd.{la,so,a}
and re build.

Re: Can't Compile binutils Under OS X Lion

Posted: Sat Feb 09, 2013 1:33 pm
by Nathan
Still getting the same error. :(

Re: Can't Compile binutils Under OS X Lion

Posted: Sat Feb 09, 2013 4:00 pm
by Nathan
After getting some awesome help with geist at #osdev we figured the problem was that I was trying to compile a version of binutils that was too old. Downloaded 2.21.1 and it compiled perfectly!

Re: Can't Compile binutils Under OS X Lion

Posted: Sat Feb 09, 2013 4:06 pm
by BenjiWiebe
Nathan wrote:After getting some awesome help with geist at #osdev we figured the problem was that I was trying to compile a version of binutils that was too old. Downloaded 2.21.1 and it compiled perfectly!
Great!! It used to take me forever to compile binutils/GCC from source; everything that could go wrong, would go wrong. :oops: