Page 2 of 2

Re: Already 6 months cannot still cross compile one

Posted: Wed Jun 01, 2016 6:37 am
by Dng88
Combuster wrote:A fresh Gentoo install has no overlays yet. The reason it fails is that you obviously have ignored the error message or tried to hack your way around doing it properly.

I also just verified that a cross-compiler builds straightforwardly with brew's gmp and friends instead of ports. The only Mac OS creeps that came out under El Capitan is that sudo doesn't actually sudo and I had to use /usr/local/(...) because of directory locks.
I download both the minimal and kd4 version under dosbox : http://www.osboxes.org/gentoo/
I start again and can I ask a few silly questions. First the commands should be

Code: Select all


   (need to use root, otherwise pretend is pointless)

   emerge -av crossdev
   crossdev --help

   (Safari got one line more: PORTDIR_OVERLAY="/usr/local/crossdev" but it seems it is not working, ... need export? not trial use 

   crossdev --stage1 --binutils <binutils-version> --gcc <gcc-version> --target <target>
   crossdev --stage1  --binutils 2.24-r3 --gcc 4.8.3 --target i686-elf

   (not working)

   crossdev --stage1  --binutils 2.24-r3 --gcc 4.8.3 --target i686-elf --ov-output "/usr/local/crossdev"

   (got some output but no binary just ebuild files)
   (Now I have something in the /usr/local/crossdev ... how to use it? Need any stage2/3 ... )
   (finally decide to try again but use export command)

   export PORTDIR_OVERLAY="/usr/local/crossdev"
   crossdev --stage1  --binutils 2.24-r3 --gcc 4.8.3 --target i686-elf

   (seems got more and waiting but look promising as it get not only bitutils but also gcc stage 1)

Done

Re: Already 6 months cannot still cross compile one

Posted: Wed Jun 01, 2016 5:27 pm
by Dng88
Combuster wrote:A fresh Gentoo install has no overlays yet. The reason it fails is that you obviously have ignored the error message or tried to hack your way around doing it properly.

I also just verified that a cross-compiler builds straightforwardly with brew's gmp and friends instead of ports. The only Mac OS creeps that came out under El Capitan is that sudo doesn't actually sudo and I had to use /usr/local/(...) because of directory locks.
Trying brew again but as the directory is different, so far not sure I can follow the script on what to do.

Done ... and thanks.

Re: Already 6 months cannot still cross compile one

Posted: Wed Jun 01, 2016 7:33 pm
by Dng88
Final result as of 2016-06-02:

So far up to 2016.06.02, the script and using binutil 2.24 and gcc 4.8.3 i686

# see another post
# on 4-6 4.8.3 and 2.24 ok for x86_64
# on 4-6 6.1.0 and 2.26 ok for both i686 and x86_64
# (but generating a new gcc compiler is not, strip seems expect clang strip c option; see another topics)


-- to be tested --

MingW32 to be tested

MingW64 to be tested



--- OK below (for i686, for others next post) ---
--- mac osx el captain, ubuntu 16, cygwin 64, cygwin 32 (offline) ---
--- (except mac no bochs gui_debug but another issues) -------------
--- usually need to use tar xzvf ... but strangely one win10-32 cygwin cannot run this and has to use tar jf ! ---


cygwin win7-32 ok
- problem is cannot download the package using the script but using offline download and then trying step by step
- it is ok just make sure you do the contrib/download_prerequisite offline carefully.

Code: Select all


  only for offline mode
  assume under gcc-4.8.3/

  MPFR=mpfr-2.4.2  # seems not need to do export here 
  GMP=gmp-4.3.2
  MPC=mpc-0.8.1

  #wget ftp://gcc.gnu.org/pub/gcc/infrastructure/$MPFR.tar.bz2 || exit 1
  tar xjf $MPFR.tar.bz2 # do not do || exit 1
  ln -sf $MPFR mpfr     # || exit 1

  #wget ftp://gcc.gnu.org/pub/gcc/infrastructure/$GMP.tar.bz2 || exit 1
  tar xjf $GMP.tar.bz2   # || exit 1
  ln -sf $GMP gmp        # || exit 1

  #wget ftp://gcc.gnu.org/pub/gcc/infrastructure/$MPC.tar.gz || exit 1
  tar xzf $MPC.tar.gz     # || exit 1
  ln -sf $MPC mpc         # || exit 1

cygwin win10-64 testing
- ignore the 3 package list in the windows part, instead use the contrib/download_...
- then install, work ok


Mac OS X El Captain maports ok
- use macports not brew
- ignore libiconv part and any others, just use the 3 boxed commands (but not the export one)
- follow the script except use install the 3 libs via the mac os x macports part
and the two different configure commands for binutils and gcc
- not sure about why direct download of contrib/download_prerequisite not working
- not sure about the impact of no sysroot ...
- still issues :
bochs has only x11 working (via Quartz) and in particular not sure how to make sdl/sdl2 work or debug-gui ...


Mac OS X EL Captain homebrew ok
- strangely the direct method is not working i.e. instead of using brew/port just
use contrib/download_prerequisite does not go through, port install something
and not sure why it works (as the 3 libraries may not match with the gcc/binutils in general?!)
ports work and testing homebrew again now
- work



Ubuntu 16 under VM ok
- follow the script
- need to do contrib/download_prerequisites
(the discussion of those 3 "libraries" confusing,
do not download those source but instead run the contrib/d... script)


Gentoo under VM (the image from their site) ok
- need to use su (i.e. root)
- need to export the so call overlay ...

Code: Select all


   (need to use root, otherwise pretend is pointless)

   su
   emerge -av crossdev
   crossdev --help
   export PORTDIR_OVERLAY="/usr/local/crossdev"
   crossdev --stage1  --binutils 2.24-r3 --gcc 4.8.3 --target i686-elf
====================

For all the simple test code is

Code: Select all

   i686-elf-gcc --version
   i686-elf-ld --help
   i686-as --help
For some I would try the barebone later ...

Walk on once do documentation, really just a toolkit but it takes so long to get it.

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

To use it:

Code: Select all


export PREFIX="$HOME/opt/cross"
export TARGET=i686-elf
export PATH="$PREFIX/bin:$PATH"

gcc --dumpmachine
ld --help                # note the target support

i686-elf-gcc --dumpmachine
i686-elf-ld --help


Trying x86_64 seems ok under mac os x

Posted: Fri Jun 03, 2016 8:35 pm
by Dng88
#try x86_64-elf and i686 under mac os x

# seemes both gcc-4.8.3 binutil-2.24 and latest gcc-6.10 binutils-2.26 all ok

# all ok no need to generate a new gcc compiler under clang -- anyway the strip option is an issues preventing it

Code: Select all

	sudo port selfupdate
	sudo port upgrade outdated

    sudo port installed wget
    #(if not)
	sudo port wget

	cd $HOME
	
	mkdir src-g6b26-x86_64
	cd src-g6b26-x86_64
	#(assume 2 files, assume tar xvzf ...)
	
	wget https://ftp.gnu.org/gnu/gcc/gcc-6.1.0/gcc-6.1.0.tar.gz
	tar xzvf gcc-6.1.0.tar.gz
	
	wget https://ftp.gnu.org/gnu/binutils/binutils-2.26.tar.gz
	tar xzvf binutils-2.26.tar.gz
	
	sudo port installed gmp mpfr libmpc
	#(if not)
	sudo port install gmp mpfr libmpc
	
	export PREFIX="$HOME/opt/cross-g6b26-x86_64"
	export TARGET=x86_64-elf
	export PATH="$PREFIX/bin:$PATH"
	
	cd $HOME/src-g6b26-x86_64
 
	mkdir build-binutils
	cd build-binutils
	# not this ../binutils-x.y.z/configure --target=$TARGET --prefix="$PREFIX" --with-sysroot --disable-nls --disable-werror
	# mac use this:
	../binutils-2.26/configure --prefix=$PREFIX \
	--target=$TARGET \
	--enable-interwork --enable-multilib \	
	--disable-nls --disable-werror
	
	make
	make install
		
	cd $HOME/src-g6b26-x86_64
 
	mkdir build-gcc
	cd build-gcc
	# not this .. ../gcc-x.y.z/configure --target=$TARGET --prefix="$PREFIX" --disable-nls --enable-languages=c,c++ --without-headers
	# mac use this:
    ../gcc-6.1.0/configure --prefix=$PREFIX \
	--target=$TARGET \
	--disable-nls \
	--enable-languages=c,c++ --without-headers \
	--enable-interwork --enable-multilib \
	--with-gmp=/usr --with-mpc=/opt/local --with-mpfr=/opt/local

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


#=========================================

Code: Select all


	cd $HOME
 
	mkdir src-g6b26-i686
	cd src-g6b26-i686
	#(assume 2 files, assume tar xvzf ...)
	
	#manual ... 
	
	sudo port installed gmp mpfr libmpc
	#(if not)
	sudo port install gmp mpfr libmpc
	
	export PREFIX="$HOME/opt/cross-g6b26-i686"
	export TARGET=i686-elf
	export PATH="$PREFIX/bin:$PATH"
	
	cd $HOME/src-g6b26-i686
 
	mkdir build-binutils
	cd build-binutils
	# not this ../binutils-x.y.z/configure --target=$TARGET --prefix="$PREFIX" --with-sysroot --disable-nls --disable-werror
	# mac use this:
	../binutils-2.26/configure --prefix=$PREFIX \
	--target=$TARGET \
	--enable-interwork --enable-multilib \	
	--disable-nls --disable-werror
	
	make
	make install
		
	cd $HOME/src-g6b26-i686
 
	mkdir build-gcc
	cd build-gcc
	# not this .. ../gcc-x.y.z/configure --target=$TARGET --prefix="$PREFIX" --disable-nls --enable-languages=c,c++ --without-headers
	# mac use this:
    ../gcc-6.1.0/configure --prefix=$PREFIX \
	--target=$TARGET \
	--disable-nls \
	--enable-languages=c,c++ --without-headers \
	--enable-interwork --enable-multilib \
	--with-gmp=/usr --with-mpc=/opt/local --with-mpfr=/opt/local

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

#=========================================

Code: Select all


# new terminal

# just trying the clang

       gcc -dumpmachine
       gcc -v
       ld -v
       as -V --help


#to test the new i686


	
	export PREFIX="$HOME/opt/cross-g6b26-i686"
	export TARGET=i686-elf
	export PATH="$PREFIX/bin:$PATH"
	
	i686-elf-gcc -dumpmachine
        i686-elf-gcc -v #--help --version
	i686-elf-ld -V #--help
	i686-elf-as -V --help


#to test the new x86_64
	
	export PREFIX="$HOME/opt/cross-g6b26-x86_64"
	export TARGET=x86_64-elf
	export PATH="$PREFIX/bin:$PATH"
	
	x86_64-elf-gcc -dumpmachine
	x86_64-elf-gcc -v #--help --version
	x86_64-elf-ld -V #--help
	x86_64-elf-as -V --help

#Try back the older x86_64 use:

	export PREFIX="$HOME/opt/cross-x86_64"
	export TARGET=x86_64-elf
	export PATH="$PREFIX/bin:$PATH"
	
	x86_64-elf-gcc -dumpmachine
	x86_64-elf-gcc -v #--help --version
	x86_64-elf-ld -V #--help
	x86_64-elf-as -V --help


	
#Try back the older i686 use:

	export PREFIX="$HOME/opt/cross"
	export TARGET=i686-elf
	export PATH="$PREFIX/bin:$PATH"

	i686-elf-gcc -dumpmachine
	i686-elf-gcc -v #--help
	i686-elf-ld -V
	i686-elf-as -V --help