Trying to build latest GCC under mac os x el captain

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Dng88
Posts: 16
Joined: Wed Oct 21, 2015 5:12 pm

Trying to build latest GCC under mac os x el captain

Post by Dng88 »

Surprise to find that I do NOT need to build the latest GCC to build the cross compiler under gcc 6.1.0 and binutils 2.26. clang can do it (and have no issue with -c as its strip has this option!)

Is it simply impossible?

==============

After successfully done gcc-4.8.3 and binutils-2.24 under various platforms, I guess I move on to try building the latest one. Following the script, the make step has an issue for trying gcc-6.1.0 and binutils-2.26:

Code: Select all


rm libgcc_s.1.dylib_T*
MLIBS=`/Users/chichunng/src/build-gcc/./gcc/xgcc -B/Users/chichunng/src/build-gcc/./gcc/ -B/Users/chichunng/opt/gcc-6.1.0/x86_64-apple-darwin15.5.0/bin/ -B/Users/chichunng/opt/gcc-6.1.0/x86_64-apple-darwin15.5.0/lib/ -isystem /Users/chichunng/opt/gcc-6.1.0/x86_64-apple-darwin15.5.0/include -isystem /Users/chichunng/opt/gcc-6.1.0/x86_64-apple-darwin15.5.0/sys-include    --print-multi-lib | sed -e 's/;.*$//'` ; \
	for mlib in $MLIBS ; do \
	  /Users/chichunng/opt/gcc-6.1.0/x86_64-apple-darwin15.5.0/bin/strip -o libgcc_ext.10.4.dylib_T${mlib} \
	    -R ../../../gcc-6.1.0/libgcc/config/i386/libgcc-darwin.10.4.ver -c -urx \
	    ../${mlib}/libgcc/${mlib}/libgcc_s.dylib || exit 1 ; \
	done
strip: invalid option -- c
Usage: /Users/chichunng/opt/gcc-6.1.0/x86_64-apple-darwin15.5.0/bin/strip <option(s)> in-file(s)
 Removes symbols and sections from files
 The options are:
  -I --input-target=<bfdname>      Assume input file is in format <bfdname>
  -O --output-target=<bfdname>     Create an output file in format <bfdname>
  -F --target=<bfdname>            Set both input and output format to <bfdname>
  -p --preserve-dates              Copy modified/access timestamps to the output
  -D --enable-deterministic-archives
                                   Produce deterministic output when stripping archives
  -U --disable-deterministic-archives
                                   Disable -D behavior (default)
  -R --remove-section=<name>       Also remove section <name> from the output
  -s --strip-all                   Remove all symbol and relocation information
  -g -S -d --strip-debug           Remove all debugging symbols & sections
     --strip-dwo                   Remove all DWO sections
     --strip-unneeded              Remove all symbols not needed by relocations
     --only-keep-debug             Strip everything but the debug information
  -N --strip-symbol=<name>         Do not copy symbol <name>
  -K --keep-symbol=<name>          Do not strip symbol <name>
     --keep-file-symbols           Do not strip file symbol(s)
  -w --wildcard                    Permit wildcard in symbol comparison
  -x --discard-all                 Remove all non-global symbols
  -X --discard-locals              Remove any compiler-generated symbols
  -v --verbose                     List all object files modified
  -V --version                     Display this program's version number
  -h --help                        Display this output
     --info                        List object formats & architectures supported
  -o <file>                        Place stripped output into <file>
/Users/chichunng/opt/gcc-6.1.0/x86_64-apple-darwin15.5.0/bin/strip: supported targets: mach-o-x86-64 mach-o-i386 mach-o-le mach-o-be mach-o-fat pef pef-xlib sym plugin srec symbolsrec verilog tekhex binary ihex
make[3]: *** [libgcc_ext.10.4.dylib] Error 1
make[2]: *** [all-stage1-target-libgcc] Error 2
make[1]: *** [stage1-bubble] Error 2
make: *** [all] Error 2

I have installed under macport the followings:

The following ports are currently installed:
gmp @6.1.0_1 (active)
libmpc @1.0.3_0 (active)
mpfr @3.1.3_0 (active)

and under gcc-6.1.0 have cloog, isl, libiconv, texinfo alias point to

cloog-0.18.4
isl-0.17
libiconv-1.14
texinfo-6.1

Is this an issue of llvm. Anyone know what is the latest version I can try under mac if that is so?

(FYI: I have used same mac to build both i686-elf and x86_64-elf and it is fine for gcc-4.8.3 and binutil-2.24)

(not whether relevant I noted man strip (under clang?) has -c but I check my generated i686-elf-strip --help does not say anything about -c option)

(both gcc 6.1.0 and gcc 5.3.0 - two options said ok in cross compile and hence select this - against binutils 2.26)


Here, I also include the binutils make log to see whether it might be the issues (binutils 2.26 and gcc 5.3.0)

Code: Select all


config.status: creating Makefile
make[2]: Nothing to be done for `all'.
make[1]: Nothing to be done for `all-target'.
Chis-MacBook-Pro:build-binutils chichunng$ make install
/bin/sh ../binutils-2.26/mkinstalldirs /Users/chichunng/opt/gcc-5.3.0 /Users/chichunng/opt/gcc-5.3.0
mkdir /Users/chichunng/opt/gcc-5.3.0
/Applications/Xcode.app/Contents/Developer/usr/bin/make  install-recursive
Making install in doc
test -z "/Users/chichunng/opt/gcc-5.3.0/share/info" || ../../../binutils-2.26/bfd/../install-sh -c -d "/Users/chichunng/opt/gcc-5.3.0/share/info"
 /usr/bin/install -c -m 644 ../../../binutils-2.26/bfd/doc/bfd.info '/Users/chichunng/opt/gcc-5.3.0/share/info'
 install-info --info-dir='/Users/chichunng/opt/gcc-5.3.0/share/info' '/Users/chichunng/opt/gcc-5.3.0/share/info/bfd.info'
Making install in po
make[4]: Nothing to be done for `install'.
make[5]: Nothing to be done for `install-exec-am'.
test -z "/Users/chichunng/opt/gcc-5.3.0/include" || ../../binutils-2.26/bfd/../install-sh -c -d "/Users/chichunng/opt/gcc-5.3.0/include"
 /usr/bin/install -c -m 644 bfd.h ../../binutils-2.26/bfd/../include/ansidecl.h ../../binutils-2.26/bfd/../include/symcat.h ../../binutils-2.26/bfd/../include/bfdlink.h ../../binutils-2.26/bfd/../include/plugin-api.h '/Users/chichunng/opt/gcc-5.3.0/include'
test -z "/Users/chichunng/opt/gcc-5.3.0/lib" || ../../binutils-2.26/bfd/../install-sh -c -d "/Users/chichunng/opt/gcc-5.3.0/lib"
 /bin/sh ./libtool   --mode=install /usr/bin/install -c   libbfd.la '/Users/chichunng/opt/gcc-5.3.0/lib'
libtool: install: /usr/bin/install -c .libs/libbfd.lai /Users/chichunng/opt/gcc-5.3.0/lib/libbfd.la
libtool: install: /usr/bin/install -c .libs/libbfd.a /Users/chichunng/opt/gcc-5.3.0/lib/libbfd.a
libtool: install: chmod 644 /Users/chichunng/opt/gcc-5.3.0/lib/libbfd.a
libtool: install: ranlib /Users/chichunng/opt/gcc-5.3.0/lib/libbfd.a
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: /Users/chichunng/opt/gcc-5.3.0/lib/libbfd.a(bfdwin.o) has no symbols
----------------------------------------------------------------------
Libraries have been installed in:
   /Users/chichunng/opt/gcc-5.3.0/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `DYLD_LIBRARY_PATH' environment variable
     during execution

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
Making install in .
make[4]: Nothing to be done for `install-exec-am'.
test -z "/Users/chichunng/opt/gcc-5.3.0/include" || ../../binutils-2.26/opcodes/../install-sh -c -d "/Users/chichunng/opt/gcc-5.3.0/include"
 /usr/bin/install -c -m 644 ../../binutils-2.26/opcodes/../include/dis-asm.h '/Users/chichunng/opt/gcc-5.3.0/include'
test -z "/Users/chichunng/opt/gcc-5.3.0/lib" || ../../binutils-2.26/opcodes/../install-sh -c -d "/Users/chichunng/opt/gcc-5.3.0/lib"
 /bin/sh ./libtool   --mode=install /usr/bin/install -c   libopcodes.la '/Users/chichunng/opt/gcc-5.3.0/lib'
libtool: install: /usr/bin/install -c .libs/libopcodes.lai /Users/chichunng/opt/gcc-5.3.0/lib/libopcodes.la
libtool: install: /usr/bin/install -c .libs/libopcodes.a /Users/chichunng/opt/gcc-5.3.0/lib/libopcodes.a
libtool: install: chmod 644 /Users/chichunng/opt/gcc-5.3.0/lib/libopcodes.a
libtool: install: ranlib /Users/chichunng/opt/gcc-5.3.0/lib/libopcodes.a
----------------------------------------------------------------------
Libraries have been installed in:
   /Users/chichunng/opt/gcc-5.3.0/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `DYLD_LIBRARY_PATH' environment variable
     during execution

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
Making install in po
make[3]: Nothing to be done for `install'.
/Applications/Xcode.app/Contents/Developer/usr/bin/make  install-recursive
Making install in doc
make[5]: Nothing to be done for `install-exec-am'.
test -z "/Users/chichunng/opt/gcc-5.3.0/share/info" || ../../../binutils-2.26/binutils/../install-sh -c -d "/Users/chichunng/opt/gcc-5.3.0/share/info"
 /usr/bin/install -c -m 644 ../../../binutils-2.26/binutils/doc/binutils.info '/Users/chichunng/opt/gcc-5.3.0/share/info'
 install-info --info-dir='/Users/chichunng/opt/gcc-5.3.0/share/info' '/Users/chichunng/opt/gcc-5.3.0/share/info/binutils.info'
test -z "/Users/chichunng/opt/gcc-5.3.0/share/man/man1" || ../../../binutils-2.26/binutils/../install-sh -c -d "/Users/chichunng/opt/gcc-5.3.0/share/man/man1"
 /usr/bin/install -c -m 644 ../../../binutils-2.26/binutils/doc/addr2line.1 ../../../binutils-2.26/binutils/doc/ar.1 ../../../binutils-2.26/binutils/doc/dlltool.1 ../../../binutils-2.26/binutils/doc/nlmconv.1 ../../../binutils-2.26/binutils/doc/nm.1 ../../../binutils-2.26/binutils/doc/objcopy.1 ../../../binutils-2.26/binutils/doc/objdump.1 ../../../binutils-2.26/binutils/doc/ranlib.1 ../../../binutils-2.26/binutils/doc/readelf.1 ../../../binutils-2.26/binutils/doc/size.1 ../../../binutils-2.26/binutils/doc/strings.1 ../../../binutils-2.26/binutils/doc/strip.1 ../../../binutils-2.26/binutils/doc/elfedit.1 ../../../binutils-2.26/binutils/doc/windres.1 ../../../binutils-2.26/binutils/doc/windmc.1 c++filt.1 '/Users/chichunng/opt/gcc-5.3.0/share/man/man1'
Making install in po
make[4]: Nothing to be done for `install'.
test -z "/Users/chichunng/opt/gcc-5.3.0/bin" || ../../binutils-2.26/binutils/../install-sh -c -d "/Users/chichunng/opt/gcc-5.3.0/bin"
  /bin/sh ./libtool   --mode=install /usr/bin/install -c size objdump ar strings ranlib objcopy addr2line readelf elfedit '/Users/chichunng/opt/gcc-5.3.0/bin'
libtool: install: /usr/bin/install -c size /Users/chichunng/opt/gcc-5.3.0/bin/size
libtool: install: /usr/bin/install -c objdump /Users/chichunng/opt/gcc-5.3.0/bin/objdump
libtool: install: /usr/bin/install -c ar /Users/chichunng/opt/gcc-5.3.0/bin/ar
libtool: install: /usr/bin/install -c strings /Users/chichunng/opt/gcc-5.3.0/bin/strings
libtool: install: /usr/bin/install -c ranlib /Users/chichunng/opt/gcc-5.3.0/bin/ranlib
libtool: install: /usr/bin/install -c objcopy /Users/chichunng/opt/gcc-5.3.0/bin/objcopy
libtool: install: /usr/bin/install -c addr2line /Users/chichunng/opt/gcc-5.3.0/bin/addr2line
libtool: install: /usr/bin/install -c readelf /Users/chichunng/opt/gcc-5.3.0/bin/readelf
libtool: install: /usr/bin/install -c elfedit /Users/chichunng/opt/gcc-5.3.0/bin/elfedit
test -z "/Users/chichunng/opt/gcc-5.3.0/bin" || ../../binutils-2.26/binutils/../install-sh -c -d "/Users/chichunng/opt/gcc-5.3.0/bin"
  /bin/sh ./libtool  --mode=install /usr/bin/install -c nm-new /Users/chichunng/opt/gcc-5.3.0/bin/nm
libtool: install: /usr/bin/install -c nm-new /Users/chichunng/opt/gcc-5.3.0/bin/nm
  /bin/sh ./libtool  --mode=install /usr/bin/install -c strip-new /Users/chichunng/opt/gcc-5.3.0/bin/strip
libtool: install: /usr/bin/install -c strip-new /Users/chichunng/opt/gcc-5.3.0/bin/strip
  /bin/sh ./libtool  --mode=install /usr/bin/install -c cxxfilt /Users/chichunng/opt/gcc-5.3.0/bin/c++filt
libtool: install: /usr/bin/install -c cxxfilt /Users/chichunng/opt/gcc-5.3.0/bin/c++filt
/bin/sh ../../binutils-2.26/binutils/../mkinstalldirs /Users/chichunng/opt/gcc-5.3.0/x86_64-apple-darwin15.5.0/bin
mkdir /Users/chichunng/opt/gcc-5.3.0/x86_64-apple-darwin15.5.0
mkdir /Users/chichunng/opt/gcc-5.3.0/x86_64-apple-darwin15.5.0/bin
for i in nm-new strip-new ar ranlib dlltool objdump objcopy readelf; do \
	  if [ -f $i ]; then \
	    j=`echo $i | sed -e 's/-new//'`; \
	    k=`echo $j | sed 's,y,y,'`; \
	    if [ "/Users/chichunng/opt/gcc-5.3.0/bin/$k" != "/Users/chichunng/opt/gcc-5.3.0/x86_64-apple-darwin15.5.0/bin/$j" ]; then \
	      rm -f /Users/chichunng/opt/gcc-5.3.0/x86_64-apple-darwin15.5.0/bin/$j; \
	      ln /Users/chichunng/opt/gcc-5.3.0/bin/$k /Users/chichunng/opt/gcc-5.3.0/x86_64-apple-darwin15.5.0/bin/$j >/dev/null 2>/dev/null \
		||  /bin/sh ./libtool --mode=install /usr/bin/install -c $i /Users/chichunng/opt/gcc-5.3.0/x86_64-apple-darwin15.5.0/bin/$j; \
	    fi; \
	  else true; \
	  fi; \
	done
make[5]: Nothing to be done for `install-data-am'.
make[2]: Nothing to be done for `install'.
make[2]: Nothing to be done for `install'.
make[3]: Nothing to be done for `all'.
if test -n ""; then \
		/bin/sh ../../binutils-2.26/libiberty/../mkinstalldirs /Users/chichunng/opt/gcc-5.3.0/lib/`gcc -g -O2 -print-multi-os-directory`; \
		/usr/bin/install -c -m 644 ./libiberty.a /Users/chichunng/opt/gcc-5.3.0/lib/`gcc -g -O2 -print-multi-os-directory`/./libiberty.an; \
		( cd /Users/chichunng/opt/gcc-5.3.0/lib/`gcc -g -O2 -print-multi-os-directory` ; chmod 644 ./libiberty.an ;ranlib ./libiberty.an ); \
		mv -f /Users/chichunng/opt/gcc-5.3.0/lib/`gcc -g -O2 -print-multi-os-directory`/./libiberty.an /Users/chichunng/opt/gcc-5.3.0/lib/`gcc -g -O2 -print-multi-os-directory`/./libiberty.a; \
		case "" in \
		  /*)    thd=;; \
		  *)     thd=/Users/chichunng/opt/gcc-5.3.0/include/;; \
		esac; \
		/bin/sh ../../binutils-2.26/libiberty/../mkinstalldirs ${thd}; \
		for h in ../../binutils-2.26/libiberty/../include/ansidecl.h ../../binutils-2.26/libiberty/../include/demangle.h ../../binutils-2.26/libiberty/../include/dyn-string.h ../../binutils-2.26/libiberty/../include/fibheap.h ../../binutils-2.26/libiberty/../include/floatformat.h ../../binutils-2.26/libiberty/../include/hashtab.h ../../binutils-2.26/libiberty/../include/libiberty.h ../../binutils-2.26/libiberty/../include/objalloc.h ../../binutils-2.26/libiberty/../include/partition.h ../../binutils-2.26/libiberty/../include/safe-ctype.h ../../binutils-2.26/libiberty/../include/sort.h ../../binutils-2.26/libiberty/../include/splay-tree.h ../../binutils-2.26/libiberty/../include/timeval-utils.h; do \
		  /usr/bin/install -c -m 644 $h ${thd}; \
		done; \
	fi
make[3]: Nothing to be done for `install'.
make[1]: Nothing to be done for `install-target'.
Chis-MacBook-Pro:build-binutils chichunng$ 

No clues to proceed. I tried both gcc 6.1.0 and 5.3.0 vs binutils 2.26.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Trying to build latest GCC under mac os x el captain

Post by Combuster »

make: *** [all] Error 2
I.e. can't read instructions. Where does the tutorial tell you to "make" or "make all"?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Dng88
Posts: 16
Joined: Wed Oct 21, 2015 5:12 pm

Re: Trying to build latest GCC under mac os x el captain

Post by Dng88 »

Combuster wrote:
make: *** [all] Error 2
I.e. can't read instructions. Where does the tutorial tell you to "make" or "make all"?
I have followed this:

http://wiki.osdev.org/Building_GCC

in particular these:

Code: Select all


cd $HOME/src
 
# If you wish to build these packages as part of gcc:
mv libiconv-x.y.z gcc-x.y.z/libiconv # Mac OS X users
mv gmp-x.y.z gcc-x.y.z/gmp
mv mpfr-x.y.z gcc-x.y.z/mpfr
mv mpc-x.y.z gcc-x.y.z/mpc
 
mkdir build-gcc
cd build-gcc
../gcc-x.y.z/configure --prefix="$PREFIX" --disable-nls --enable-languages=c,c++
make
make install

I also noted that it is a different instruction to build cross compiler which does not do this i.e. it only does these:

Code: Select all


... cross compiler version is different and not the same as the building gcc in this web site page ...

make all-gcc
make all-target-libgcc
make install-gcc
make install-target-libgcc

Post Reply