I'm installing gcc 4.6.1
on OS X for MIT xv6:
tar xjf gcc-core-4.6.1.tar.bz2
cd gcc-4.6.1
mkdir build
cd build
../configure --prefix=/usr/local \
--target=i386-jos-elf --disable-werror \
--disable-libssp --disable-libmudflap --with-newlib \
--without-headers --enable-languages=c
Things are good until make all-gcc
:
gtype-desc.c:8838:18: error: subscripted value is not an array,
pointer, or vector
sizeof (x_rtl[0]),
~~~~~^~
gtype-desc.c:8957:36: error: subscripted value is not an array,
pointer, or vector
sizeof (default_target_libfuncs[0]),
~~~~~~~~~~~~~~~~~~~~~~~^~
gtype-desc.c:9041:31: error: subscripted value is not an array,
pointer, or vector
sizeof (default_target_rtl[0]),
~~~~~~~~~~~~~~~~~~^~
gtype-desc.c:9062:31: error: subscripted value is not an array,
pointer, or vector
sizeof (default_target_rtl[0]),
~~~~~~~~~~~~~~~~~~^~
gtype-desc.c:9069:31: error: subscripted value is not an array,
pointer, or vector
sizeof (default_target_rtl[0]),
~~~~~~~~~~~~~~~~~~^~
gtype-desc.c:9076:31: error: subscripted value is not an array,
pointer, or vector
sizeof (default_target_rtl[0]),
~~~~~~~~~~~~~~~~~~^~
68 warnings and 6 errors generated.
make[1]: *** [gtype-desc.o] Error 1
make: *** [all-gcc] Error 2
There are also errors in make install-gcc
, make all-target-libgcc
and make install-target-libgcc
and i386-jos-elf-gcc -v
show command not found
.
What should I do to fix this? Is there an alternative to use command i386-jos-elf-gcc
?
gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.1.0 (clang-602.0.49) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin15.3.0
Thread model: posix
>
>
which gcc
/usr/bin/gcc
It seems that I do have a gcc compiler, but which has been redirected to clang?
[This is not a complete answer.]
First, see the answers at Building GCC on OS X 10.11 .
Second: If you're trying to build a cross-compiler, it's highly recommended that you first bootstrap a native version of gcc. See also the section "Building a cross compiler" in INSTALL/build.html
. I built mine with --prefix=/usr/local/gcc
, so that my native gcc ended up in /usr/local/gcc/bin/gcc
. Then I added /usr/local/gcc/bin
to my $PATH
, and got rid of /usr/bin/gcc
and /usr/bin/g++
to be on the safe side.
As build.html
points out, you're also going to need a "cross-assembler" and "cross-linker". So you generally need to download an appropriate version of binutils, and build those before trying to build your cross-compiler. (This is the step I, myself, am currently stuck on. I may have more to say about this later.)
Finally, if you discover that your build is failing because you configured it improperly, such that you have to rerun configure
with different options, it's safer to delete your entire build directory and start from scratch. The configure and build system sometimes, but it seems not 100% reliably, detects what might need rebuilding in that case. (Deleting and starting over is frustrating, I agree, but again, it can really save time in the long run.)
I am also installing gcc 4.6.1
for MIT xv6 now, but on Ubuntu. I do not know if you see this:
MAC OS X 10.7 "LION" NOTE: The default clang compiler on Mac OS X 10.7
cannot build a working version of GCC. Use the following configure
line to work around the problem (this has reported to work with OS X 10.9.4 withXCode 5.1.1 and its Command Line Tools package (for gcc):
../configure --prefix=/usr/local \
--target=i386-jos-elf --disable-werror \
--disable-libssp --disable-libmudflap --with-newlib \
--without-headers --enable-languages=c \
CC=/usr/bin/gcc-4.2 \
I copied it from this page.(But I think it is not necessary for you to use that command, coz you said things are good.)
If you still have that problem,this page may give you some tips. On your Mac, use tools or command mdfind
to find where the file gengtype.c
is, and modify the code that it mentioned on that page. I hope you can solve it.