ASIC SoC2009. 12. 17. 13:17
오래간만의 컴파일러 빌드입니다.

1) binutils  설치하기


우선 binutils를 다운 받습니다.
커맨드는 아래와 같습니다.

cvs -z 9 -d :pserver:anoncvs@sourceware.org:/cvs/src login
{enter "anoncvs" as the password}
cvs -z 9 -d :pserver:anoncvs@sourceware.org:/cvs/src co binutils
  

빌드는 아래와 같이 합니다.

mkdir build
cd build
 ../binutils-2.20/configure  --target=mips-elf --prefix=/Volumes/ZGUNDAM/usr/lcao --with-gnu-as --with-gnu-ld
make all
make install

설치가 끝나고 확인하면 아래와 같습니다.

GUNDAMMACPRO:build kevinIm$ ls /Volumes/ZGUNDAM/usr/local/bin/
mips-elf-addr2line      mips-elf-ld             mips-elf-ranlib         mips-elf-strip
mips-elf-ar             mips-elf-nm             mips-elf-readelf
mips-elf-as             mips-elf-objcopy        mips-elf-size
mips-elf-c++filt        mips-elf-objdump        mips-elf-strings

패스가 추가되어야 하기 때문에

export PATH=$PATH:/Volumes/ZGUNDAM/usr/local/bin

으로 미리 추가해 둡니다.

2. gcc를 빌드하기



에서 gcc 최신 버전을 다운 받습니다. 이 글을 쓰는 시점에서는 4.4.2입니다.

다운받아서 압축을 풀고 빌드를 합니다.

mkdir build
cd build
../gcc-4.4.2/configure --target=mips-elf --without-headers --with-gnu-as --with-gnu-ld --disable-shared --prefix=/Volumes/ZGUNDAM/usr/local/ --with-newlib --disable-libssp

그러면 아래와 같은 오류가 발생합니다.

....
checking for correct version of gmp.h... no
configure: error: Building GCC requires GMP 4.1+ and MPFR 2.3.2+.
Try the --with-gmp and/or --with-mpfr options to specify their locations.
Copies of these libraries' source code can be found at their respective
hosting sites as well as at ftp://gcc.gnu.org/pub/gcc/infrastructure/.
.......

GMP 4.1과 MPFR2.32 이상 버전이 필요하다는 의미입니다.
MAC에서는 소스를 가지고 와서 빌드하는 것과 fink등을 이용해서 다운 받는것이 가능합니다.
여기선 그냥 다운 받는것으로 하고 진행합니다.

sudo port install gmp
--->  Fetching gmp
--->  Attempting to fetch gmp-4.3.1.tar.bz2 from ftp://ftp.dti.ad.jp/pub/GNU/gmp
--->  Verifying checksum(s) for gmp
--->  Extracting gmp
--->  Applying patches to gmp
--->  Configuring gmp
--->  Building gmp
--->  Staging gmp into destroot
--->  Installing gmp @4.3.1_1
--->  Activating gmp @4.3.1_1
--->  Cleaning gmp

GUNDAMMACPRO:build kevinIm$ sudo port install mpfr
--->  Fetching lzmautils
--->  Attempting to fetch lzma-4.32.7.tar.gz from http://distfiles.macports.org/lzmautils
--->  Verifying checksum(s) for lzmautils
--->  Extracting lzmautils
--->  Configuring lzmautils
--->  Building lzmautils
--->  Staging lzmautils into destroot
--->  Installing lzmautils @4.32.7_1
--->  Activating lzmautils @4.32.7_1
--->  Cleaning lzmautils
--->  Fetching mpfr
--->  Attempting to fetch patch01 from http://distfiles.macports.org/mpfr/2.4.1
--->  Attempting to fetch patch02 from http://distfiles.macports.org/mpfr/2.4.1
--->  Attempting to fetch patch03 from http://distfiles.macports.org/mpfr/2.4.1
--->  Attempting to fetch patch04 from http://distfiles.macports.org/mpfr/2.4.1
--->  Attempting to fetch mpfr-2.4.1.tar.lzma from http://distfiles.macports.org/mpfr/2.4.1
--->  Verifying checksum(s) for mpfr
--->  Extracting mpfr
--->  Applying patches to mpfr
--->  Configuring mpfr
--->  Building mpfr
--->  Staging mpfr into destroot
--->  Installing mpfr @2.4.1-p4_1
--->  Activating mpfr @2.4.1-p4_1
--->  Cleaning mpfr


그러면 설치가 된다. 설치된 위치는 /opt/local입니다.
이 위치를 반영하여서 다시 아래와 같이 커맨드를 넣습니다.

GUNDAMMACPRO:build kevinIm$ ../gcc-4.4.2/configure --target=mips-elf --without-headers --with-gnu-as --with-gnu-ld --disable-shared --prefix=/Volumes/ZGUNDAM/usr/local/ --with-newlib --disable-libssp --with-gmp=/opt/local --with-mpfr=/opt/local  --enable-languages="c"

make all

그러면 한참 컴파일을 합니다.

그러다가 다음과 같은 오류를 냅니다.

gcc  -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE  -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wcast-qual -Wold-style-definition -Wmissing-format-attribute   -DHAVE_CONFIG_H  -o cc1-dummy c-lang.o stub-objc.o attribs.o c-errors.o c-lex.o c-pragma.o c-decl.o c-typeck.o c-convert.o c-aux-info.o c-common.o c-opts.o c-format.o c-semantics.o c-ppoutput.o c-cppbuiltin.o c-objc-common.o c-dump.o c-pch.o c-parser.o  c-gimplify.o tree-mudflap.o c-pretty-print.o c-omp.o dummy-checksum.o \
          main.o  libbackend.a ../libcpp/libcpp.a ../libdecnumber/libdecnumber.a ../libcpp/libcpp.a ./../intl/libintl.a -liconv  ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a   -L/opt/local/lib -L/opt/local/lib -lmpfr -lgmp
Undefined symbols:
  "_iconv_close", referenced from:
      __cpp_destroy_iconv in libcpp.a(charset.o)
      __cpp_destroy_iconv in libcpp.a(charset.o)
      __cpp_convert_input in libcpp.a(charset.o)
      __nl_free_domain_conv in libintl.a(loadmsgcat.o)
  "_iconv", referenced from:
      _convert_using_iconv in libcpp.a(charset.o)
      _convert_using_iconv in libcpp.a(charset.o)
......


이 오류는 다음과 같이 커맨드를 넣어서 해결한다.

sudo port deactivate libiconv
/sw/bin/fink update libgettext3-dev

이후에 make를 하면 잘 진행된다.

make all
make install

테스트를 하면

GUNDAMMACPRO:build kevinIm$ mips-elf-gcc --help
Usage: mips-elf-gcc [options] file...
Options:
  -pass-exit-codes         Exit with highest error code from a phase
  --help                   Display this information
  --target-help            Display target specific command line options
  --help={target|optimizers|warnings|params|[^]{joined|separate|undocumented}}[,...]
                           Display specific types of command line options
  (Use '-v --help' to display command line options of sub-processes)
  --version                Display compiler version information
  -dumpspecs               Display all of the built in spec strings
  -dumpversion             Display the version of the compiler
  -dumpmachine             Display the compiler's target processor
  -print-search-dirs       Display the directories in the compiler's search path
  -print-libgcc-file-name  Display the name of the compiler's companion library
  -print-file-name=<lib>   Display the full path to library <lib>
  -print-prog-name=<prog>  Display the full path to compiler component <prog>
  -print-multi-directory   Display the root directory for versions of libgcc
.......

3) Newlib 컴파일 하기

다운로드는 다음 커맨드로 받습니다.
  cvs -z 9 -d :pserver:anoncvs@sources.redhat.com:/cvs/src login
  {enter "anoncvs" as the password}
  cvs -z 9 -d :pserver:anoncvs@sources.redhat.com:/cvs/src co newlib

../src/configure --target=mips-elf -prefix=/Volumes/ZGUNDAM/usr/local --with-gnu-as --with-gnu-ld

이후에

make all
make install

을 하면 됩니다.


확인은 아래와 같이 합니다.
GUNDAMMACPRO:build kevinIm$ ls /Volumes/ZGUNDAM/usr/local/mips-elf/lib/

cfe.ld          ddb.ld          ldscripts       libidt.a        libnullmon.a    pcrt0.o
crt0.o          el              libc.a          liblsi.a        libpmon.a       pmon.ld
crt0_cfe.o      idt.ld          libcfe.a        libm.a          lsi.ld          soft-float
ddb-kseg0.ld    idtecoff.ld     libg.a          libnosys.a      nullmon.ld
GUNDAMMACPRO:build kevinIm$



 

'ASIC SoC' 카테고리의 다른 글

Sound Effect Processor  (0) 2010.02.01
[SC] Structure  (0) 2010.01.18
PERL TIP  (0) 2009.12.05
Timing Chart  (0) 2009.11.08
SystemC에서 main() 함수 넣기  (0) 2009.11.04
Posted by GUNDAM_IM