[MLton-user] gcc 3.* does not work - use 2.95.3...

Anoq of the Sun anoq@HardcoreProcessing.com
Sat, 08 Nov 2003 15:49:56 +0200


This is a multi-part message in MIME format.
--------------10C82F272A5633E795DF7656
Content-Type: text/plain; charset=iso-8859-7
Content-Transfer-Encoding: 7bit

Hello again!


Sorry for the pestering with these GCC-scripts - but
gcc-3.2.3 cannot compile MLton. And I have not been
able to compile 3.3.1 - and I'm not very sure that it's
completely stable either. So I have reverted to 2.95.3.
The problems I have encountered with MLton are the
same as reported earlier by Brent and others.

Anyway - I have attached my complete collection
of scripts. The 2.95.3 ones are the ones that
can compile MLton. Both the 2.95.3 and the 3.2.3
ones work enough to compile Hello World on Linux
and Windows with gcc. The 3.3.1 script is how far
I came with that version - but I never got it to work.

Both the 3.3.1 and the 2.95.3 use version 2.14
of binutils, and 3.2.3 use version 2.13 of
binutils. I guess it's OK to just use the
latest binutils for gcc 2.95.3 now that
I got it to work.

Hopefully I can get my hands in the MLton source now :)


Cheers
-- 
http://www.HardcoreProcessing.com
--------------10C82F272A5633E795DF7656
Content-Type: text/plain; charset=iso-8859-7;
 name="build-cross-gcc-2.95.3"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="build-cross-gcc-2.95.3"

#!/usr/bin/env bash

# This script builds and installs a gcc cross compiler.

# It has been used to build cross compilers from Linux to Cygwin and
# from Linux to SunOS.  It is unlikely that this script will work
# out-of-the-box.  It is only intended as a template.  You should read
# through it and understand what it does, and make changes as
# necessary.  Feel free to add another targetType if you modify this
# script for another target.

# Notes from Anoq about the mingw target:
# I downloaded the following files from www.mingw.org:
# *) binutils-2.14.90-20030807-1-src.tar.gz which I unpacked to
#    binutils-2.14.90-20030807-1-src.tar
#    This script unpacks the .tar to binutils-2.14.90-20030807-1
# *) gcc-2.95.3-8-20020922-1-src.tar.gz which I unpacked to
#    gcc-2.95.3-8-20020922-1-src.tar
#    This script unpacks the .tar to gcc-2.95.3-8-20020922-1

set -e

die () {
	echo >&2 "$1"
	exit 1
}

root=`pwd`
name=`basename $0`

usage () {
	die "usage: $name {cygwin|mingw|sun}"
}

case "$#" in
1)
	case "$1" in
	cygwin|mingw|sun)
		targetType="$1"
	;;
	*)
		usage
	;;
	esac
;;
*)
	usage
esac

# You may want to change the installation prefix, which is where the
# script will install the cross-compiler tools.
prefix='/usr'

# You must have have the sources to binutils and gcc, and place the
# tarfiles in the current directory.  You can find ftp sites to
# download binutils and gcc-core at gnu.org.  You may need to change
# the version numbers below to match what you download.

# The .tar files end in -src but the unpacked directories do not
binutilsVers='2.14.90-20030807-1'
binutils="binutils-$binutilsVers"
binutilsTar="binutils-$binutilsVers-src.tar"
gccVers='2.95.3-8-20020922-1'
gccDir="gcc-$gccVers"
gccTar="gcc-$gccVers-src.tar"

# You may want to set the target.
case "$targetType" in
cygwin)
	target='i386-pc-cygwin'
	configureBintutilFlags=''
	configureGCCFlags=''
	# For Cygwin, we also need the cygwin and w32api packages,
	# which contain necessary header files and libraries.  I got
	# them by installing cygwin in a Windows machine (using #
	# Cygwin's setup.exe program) and then getting the bzip'ed tar
	# files out of their Cygwin packages dir.  I had problems with
	# cygwin-1.3.18-1, since its libcygwin.a contained a file,
	# pseudo-reloc.o, with some strangeness that binutils didn't
	# correctly handle.
	cygwin='cygwin-1.3.17-1'
	w32api='w32api-2.1-1'
;;
mingw)
	target='i386-pc-mingw32'
	# These flags are from binutils-2.14-build.sh
	configureBintutilFlags='--disable-nls --with-gcc --with-gnu-as --with-gnu-ld --disable-shared'
	# These flags are from build-cross.sh from www.libsdl.org except:
	# I added --disable-nls because of undefined references to dcgettext__ 
	# I also added some flags like --enable-threads and others
	configureGCCFlags='--with-headers=$prefix/$target/include --with-gnu-as --with-gnu-ld --without-newlib --disable-multilib --disable-nls --enable-threads'
	# For MinGW, we also need the mingw-runtime and w32api packages,
	# which contain necessary header files and libraries.  I got
	# them from www.mingw.org.
	mingw='mingw-runtime-3.2'
	w32api='w32api-2.4'
;;
sun)
	target='sparc-sun-solaris'
	configureBintutilFlags=''
	configureGCCFlags=''
	# For sun, we assume that you have already copied the includes
	# and libraries from a SunOS machine to the host machine.
	if ! [ -d "$prefix/$target/include" -a -d "$prefix/$target/lib" ]; then
		die "Must create $prefix/$target/{include,lib}."
	fi
	# The GCC tools expect limits.h to be in sys-include, not include.
	( cd $prefix/$target && 
		mkdir -p sys-include &&
		mv include/limits.h sys-include )
;;
esac

exists () {
	if [ ! -r "$1" ]; then
		die "$1 does not exist"
	fi
}

echo 'Checking that needed files exist.'
exists $binutilsTar
exists $gccTar
case "$targetType" in
cygwin)
	exists $cygwin.tar
	exists $w32api.tar
	echo 'Copying include files and libraries needed by cross compiler.'
	cd $root
	mkdir -p cygwin
	cd cygwin
	tar x <../$cygwin.tar
	tar x <../$w32api.tar
	mkdir -p $prefix/$target || 
		die "Cannot create $prefix/$target."
	(cd usr && tar c include lib) | (cd $prefix/$target/ && tar x)
;;
mingw)
        exists $mingw.tar
        exists $w32api.tar
        echo 'Copying include files and libraries needed by cross compiler.'
        cd $root
        mkdir -p mingw   
        cd mingw
        tar x <../$mingw.tar
        tar x <../$w32api.tar
        mkdir -p $prefix/$target ||
                die "Cannot create $prefix/$target."
        (tar c include lib) | (cd $prefix/$target/ && tar x)
;;
*)
;;
esac

echo 'Building binutils.'
cd $root
if [ ! -d $binutils ]; then
	tar x <$binutilsTar
fi
mkdir -p build-binutils
cd build-binutils
../$binutils/configure --prefix=$prefix --target=$target $configureBintutilFlags \
	>$root/configure-binutils-log 2>&1 ||
	die "Configure of binutils failed."
eval make $makeBintutilFlags all install >$root/build-binutils-log 2>&1 ||
	die "Build of binutils failed."

echo 'Building gcc.'
cd $root
tar x <$gccTar
mkdir -p build-gcc
cd build-gcc
../$gccDir/configure -v $configureGCCFlags \
	--enable-languages=c \
	--prefix=$prefix \
	--target=$target \
	>$root/configure-gcc-log 2>&1 || 
	die "Configure of gcc failed."
make all install >$root/build-gcc-log 2>&1 || 
	die "Build of gcc failed."

echo 'Success.'

--------------10C82F272A5633E795DF7656
Content-Type: text/plain; charset=iso-8859-7;
 name="build-cross-gcc-3.2.3"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="build-cross-gcc-3.2.3"

#!/usr/bin/env bash

# This script builds and installs a gcc cross compiler.

# It has been used to build cross compilers from Linux to Cygwin and
# from Linux to SunOS.  It is unlikely that this script will work
# out-of-the-box.  It is only intended as a template.  You should read
# through it and understand what it does, and make changes as
# necessary.  Feel free to add another targetType if you modify this
# script for another target.

# Notes from Anoq about the mingw target:
# I downloaded the following files from www.mingw.org:
# *) binutils-2.13.90-20030111-1-src.tar.gz which I unpacked to
#    binutils-2.13.90-20030111-1-src.tar
#    This script unpacks the .tar to binutils-2.13.90-20030111-1-src
# *) gcc-3.2.3-20030504-1-src.tar.gz which I unpacked to
#    gcc-3.2.3-20030504-1-src.tar
#    This script unpacks the .tar to gcc-3.2.3-20030504-1
# This script works but gcc 3.2.3 cannot compile MLton

set -e

die () {
	echo >&2 "$1"
	exit 1
}

root=`pwd`
name=`basename $0`

usage () {
	die "usage: $name {cygwin|mingw|sun}"
}

case "$#" in
1)
	case "$1" in
	cygwin|mingw|sun)
		targetType="$1"
	;;
	*)
		usage
	;;
	esac
;;
*)
	usage
esac

# You may want to change the installation prefix, which is where the
# script will install the cross-compiler tools.
prefix='/usr'

# You must have have the sources to binutils and gcc, and place the
# tarfiles in the current directory.  You can find ftp sites to
# download binutils and gcc-core at gnu.org.  You may need to change
# the version numbers below to match what you download.
binutils='binutils-2.13.90-20030111-1-src'
binutilsTar="$binutils.tar"
gccVers='3.2.3-20030504-1'
# gccTar="gcc-core-$gccVers.tar"
# Annoying that the .tar file ends in -src and the unpacked directory does not
gccTar="gcc-$gccVers-src.tar"

# You may want to set the target.
case "$targetType" in
cygwin)
	target='i386-pc-cygwin'
	configureGCCFlags=''
	makeGCCFlags=''
	# For Cygwin, we also need the cygwin and w32api packages,
	# which contain necessary header files and libraries.  I got
	# them by installing cygwin in a Windows machine (using #
	# Cygwin's setup.exe program) and then getting the bzip'ed tar
	# files out of their Cygwin packages dir.  I had problems with
	# cygwin-1.3.18-1, since its libcygwin.a contained a file,
	# pseudo-reloc.o, with some strangeness that binutils didn't
	# correctly handle.
	cygwin='cygwin-1.3.17-1'
	w32api='w32api-2.1-1'
;;
mingw)
	target='i386-pc-mingw32'
	# These flags are from build-cross.sh from www.libsdl.org except:
	# I added --disable-nls because of undefined references to dcgettext__
	configureGCCFlags='--with-headers=$prefix/$target/include --with-gnu-as --with-gnu-ld --without-newlib --disable-multilib --disable-nls'
	makeGCCFlags='LANGUAGES=c'
	# For MinGW, we also need the mingw-runtime and w32api packages,
	# which contain necessary header files and libraries.  I got
	# them from www.mingw.org.
	mingw='mingw-runtime-3.2'
	w32api='w32api-2.4'
;;
sun)
	target='sparc-sun-solaris'
	configureGCCFlags=''
	makeGCCFlags=''
	# For sun, we assume that you have already copied the includes
	# and libraries from a SunOS machine to the host machine.
	if ! [ -d "$prefix/$target/include" -a -d "$prefix/$target/lib" ]; then
		die "Must create $prefix/$target/{include,lib}."
	fi
	# The GCC tools expect limits.h to be in sys-include, not include.
	( cd $prefix/$target && 
		mkdir -p sys-include &&
		mv include/limits.h sys-include )
;;
esac

exists () {
	if [ ! -r "$1" ]; then
		die "$1 does not exist"
	fi
}

echo 'Checking that needed files exist.'
exists $binutilsTar
exists $gccTar
case "$targetType" in
cygwin)
	exists $cygwin.tar
	exists $w32api.tar
	echo 'Copying include files and libraries needed by cross compiler.'
	cd $root
	mkdir -p cygwin
	cd cygwin
	tar x <../$cygwin.tar
	tar x <../$w32api.tar
	mkdir -p $prefix/$target || 
		die "Cannot create $prefix/$target."
	(cd usr && tar c include lib) | (cd $prefix/$target/ && tar x)
;;
mingw)
	exists $mingw.tar
	exists $w32api.tar
	echo 'Copying include files and libraries needed by cross compiler.'
	cd $root
	mkdir -p mingw
	cd mingw
	tar x <../$mingw.tar
	tar x <../$w32api.tar
	mkdir -p $prefix/$target || 
		die "Cannot create $prefix/$target."
	(tar c include lib) | (cd $prefix/$target/ && tar x)
;;
*)
;;
esac

echo 'Building binutils.'
cd $root
if [ ! -d $binutils ]; then
	tar x <$binutilsTar
fi
mkdir -p build-binutils
cd build-binutils
../$binutils/configure --prefix=$prefix --target=$target \
	>$root/configure-binutils-log 2>&1 ||
	die "Configure of binutils failed."
make all install >$root/build-binutils-log 2>&1 ||
	die "Build of binutils failed."

echo 'Building gcc.'
cd $root
tar x <$gccTar
mkdir -p build-gcc
cd build-gcc
eval ../gcc-$gccVers/configure -v $configureGCCFlags \
	--enable-languages=c \
	--prefix=$prefix \
	--target=$target \
	>$root/configure-gcc-log 2>&1 || 
	die "Configure of gcc failed."
eval make $makeGCCFlags all install >$root/build-gcc-log 2>&1 || 
	die "Build of gcc failed."

echo 'Success.'

--------------10C82F272A5633E795DF7656
Content-Type: text/plain; charset=iso-8859-7;
 name="build-cross-gcc-3.3.1"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="build-cross-gcc-3.3.1"

#!/usr/bin/env bash

# This script builds and installs a gcc cross compiler.

# It has been used to build cross compilers from Linux to Cygwin and
# from Linux to SunOS.  It is unlikely that this script will work
# out-of-the-box.  It is only intended as a template.  You should read
# through it and understand what it does, and make changes as
# necessary.  Feel free to add another targetType if you modify this
# script for another target.

# Notes from Anoq about the mingw target:
# I downloaded the following files from www.mingw.org:
# *) binutils-2.14.90-20030807-1-src.tar.gz which I unpacked to
#    binutils-2.14.90-20030807-1-src.tar
#    This script unpacks the .tar to binutils-2.14.90-20030807-1
# *) gcc-core-3.3.1-20030804-1-src.tar.gz which I unpacked to
#    gcc-core-3.3.1-20030804-1-src.tar
#    This script unpacks the .tar to gcc-3.3.1-20030804-1
# I cannot compile gcc 3.3.1 due to complaints about bug_report_url
# in gcc/diagnostic.c

set -e

die () {
	echo >&2 "$1"
	exit 1
}

root=`pwd`
name=`basename $0`

usage () {
	die "usage: $name {cygwin|mingw|sun}"
}

case "$#" in
1)
	case "$1" in
	cygwin|mingw|sun)
		targetType="$1"
	;;
	*)
		usage
	;;
	esac
;;
*)
	usage
esac

# You may want to change the installation prefix, which is where the
# script will install the cross-compiler tools.
prefix='/usr'

# You must have have the sources to binutils and gcc, and place the
# tarfiles in the current directory.  You can find ftp sites to
# download binutils and gcc-core at gnu.org.  You may need to change
# the version numbers below to match what you download.

# The .tar files end in -src but the unpacked directories do not
binutilsVers='2.14.90-20030807-1'
binutils="binutils-$binutilsVers"
binutilsTar="binutils-$binutilsVers-src.tar"
gccVers='3.3.1-20030804-1'
gccDir="gcc-$gccVers"
gccTar="gcc-core-$gccVers-src.tar"

# You may want to set the target.
case "$targetType" in
cygwin)
	target='i386-pc-cygwin'
	configureGCCFlags=''
	makeGCCFlags=''
	# For Cygwin, we also need the cygwin and w32api packages,
	# which contain necessary header files and libraries.  I got
	# them by installing cygwin in a Windows machine (using #
	# Cygwin's setup.exe program) and then getting the bzip'ed tar
	# files out of their Cygwin packages dir.  I had problems with
	# cygwin-1.3.18-1, since its libcygwin.a contained a file,
	# pseudo-reloc.o, with some strangeness that binutils didn't
	# correctly handle.
	cygwin='cygwin-1.3.17-1'
	w32api='w32api-2.1-1'
;;
mingw)
	target='i386-pc-mingw32'
	# These flags are from build-cross.sh from www.libsdl.org except:
	# I added --disable-nls because of undefined references to dcgettext__
	configureGCCFlags='--with-headers=$prefix/$target/include --with-gnu-as --with-gnu-ld --without-newlib --disable-multilib --disable-nls --enable-threads'
	makeGCCFlags='LANGUAGES=c'
	# For MinGW, we also need the mingw-runtime and w32api packages,
	# which contain necessary header files and libraries.  I got
	# them from www.mingw.org.
	mingw='mingw-runtime-3.2'
	w32api='w32api-2.4'
;;
sun)
	target='sparc-sun-solaris'
	configureGCCFlags=''
	makeGCCFlags=''
	# For sun, we assume that you have already copied the includes
	# and libraries from a SunOS machine to the host machine.
	if ! [ -d "$prefix/$target/include" -a -d "$prefix/$target/lib" ]; then
		die "Must create $prefix/$target/{include,lib}."
	fi
	# The GCC tools expect limits.h to be in sys-include, not include.
	( cd $prefix/$target && 
		mkdir -p sys-include &&
		mv include/limits.h sys-include )
;;
esac

exists () {
	if [ ! -r "$1" ]; then
		die "$1 does not exist"
	fi
}

echo 'Checking that needed files exist.'
exists $binutilsTar
exists $gccTar
case "$targetType" in
cygwin)
	exists $cygwin.tar
	exists $w32api.tar
	echo 'Copying include files and libraries needed by cross compiler.'
	cd $root
	mkdir -p cygwin
	cd cygwin
	tar x <../$cygwin.tar
	tar x <../$w32api.tar
	mkdir -p $prefix/$target || 
		die "Cannot create $prefix/$target."
	(cd usr && tar c include lib) | (cd $prefix/$target/ && tar x)
;;
mingw)
	exists $mingw.tar
	exists $w32api.tar
	echo 'Copying include files and libraries needed by cross compiler.'
	cd $root
	mkdir -p mingw
	cd mingw
	tar x <../$mingw.tar
	tar x <../$w32api.tar
	mkdir -p $prefix/$target || 
		die "Cannot create $prefix/$target."
	(tar c include lib) | (cd $prefix/$target/ && tar x)
;;
*)
;;
esac

echo 'Building binutils.'
cd $root
if [ ! -d $binutils ]; then
	tar x <$binutilsTar
fi
mkdir -p build-binutils
cd build-binutils
../$binutils/configure --prefix=$prefix --target=$target \
	--disable-nls --with-gcc --with-gnu-as --with-gnu-ld --disable-shared \
	>$root/configure-binutils-log 2>&1 ||
	die "Configure of binutils failed."
make all install >$root/build-binutils-log 2>&1 ||
	die "Build of binutils failed."

echo 'Building gcc.'
cd $root
tar x <$gccTar

# A small patch by Anoq - otherwise GCC won't build!
cp $gccDir/gcc/diagnostic.c $gccDir/gcc/diagnostic.c~
echo '#include "version.h"' | cat - $gccDir/gcc/diagnostic.c~ > $gccDir/gcc/diagnostic.c
rm $gccDir/gcc/diagnostic.c~

mkdir -p build-gcc
cd build-gcc
eval ../$gccDir/configure -v $configureGCCFlags \
	--enable-languages=c \
	--prefix=$prefix \
	--target=$target \
	>$root/configure-gcc-log 2>&1 || 
	die "Configure of gcc failed."
eval make $makeGCCFlags all install >$root/build-gcc-log 2>&1 || 
	die "Build of gcc failed."

echo 'Success.'

--------------10C82F272A5633E795DF7656
Content-Type: application/x-sh;
 name="gcc-2.95.3-8-build-native.sh"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="gcc-2.95.3-8-build-native.sh"

#!/usr/bin/env bash

# Variables with filenames etc.
# The .tar files end in -src but the unpacked directories do not
binutilsVers='2.14.90-20030807-1'
binutils="binutils-$binutilsVers"
binutilsTar="binutils-$binutilsVers-src.tar"
gccVers='2.95.3-8-20020922-1'
gccDir="gcc-$gccVers"
gccTar="gcc-$gccVers-src.tar"

prefix='/usr'

root=`pwd`

# Utility functions
exists () {
        if [ ! -r "$1" ]; then
                die "$1 does not exist"
        fi
}

# Unpack and build binutils
echo 'Unpacking binutils.'
cd $root
exists $binutilsTar
tar x <$binutilsTar

echo 'Building binutils.'
mkdir -p build-binutils-native
cd build-binutils-native
../$binutils/configure --prefix=$prefix \
	--disable-nls --with-gcc --with-gnu-as --with-gnu-ld --disable-shared \
	>$root/configure-binutils-native-log 2>&1 ||
	die "Configure of binutils failed."
make all install >$root/build-binutils-native-log 2>&1 ||
	die "Build of binutils failed."

# Unpack the gcc tar-file
echo 'Unpacking gcc.'
cd $root
exists $gccTar
tar x <$gccTar

# build it
echo 'Building gcc.'
mkdir -p build-native
cd build-native
../gcc-$gccVers/configure  --with-gcc --with-gnu-ld --with-gnu-as --prefix=$prefix  --enable-threads --disable-nls --enable-languages=c --disable-multilib --without-newlib \
	>$root/configure-gcc-native-log 2>&1 ||
	die "Configure of gcc failed."
make "CFLAGS=-O2" "LDFLAGS=-s" bootstrap >$root/build-gcc-native-log 2>&1 ||
	die "Build of gcc failed."

# install it
make install || die "Install of gcc failed."

echo 'Success.'

--------------10C82F272A5633E795DF7656
Content-Type: application/x-sh;
 name="gcc-3.2.3-build-native.sh"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="gcc-3.2.3-build-native.sh"

#!/usr/bin/env bash

# Variables with filenames etc.
gccVers='3.2.3-20030504-1'
# gccTar="gcc-core-$gccVers.tar"
# Annoying that the .tar file ends in -src and the unpacked directory does not
gccTar="gcc-$gccVers-src.tar"
binutils='binutils-2.13.90-20030111-1-src'
binutilsTar="$binutils.tar"

prefix='/usr'

root=`pwd`

# Utility functions
exists () {
        if [ ! -r "$1" ]; then
                die "$1 does not exist"
        fi
}

# Unpack and build binutils
echo 'Unpacking binutils.'
cd $root
exists $binutilsTar
tar x <$binutilsTar

echo 'Building binutils.'
mkdir -p build-binutils-native
cd build-binutils-native
../$binutils/configure --prefix=$prefix \
        >$root/configure-binutils-native-log 2>&1 ||
        die "Configure of binutils failed."
make all install >$root/build-binutils-native-log 2>&1 ||
        die "Build of binutils failed."

# Unpack the gcc tar-file
echo 'Unpacking gcc.'
cd $root
exists $gccTar
tar x <$gccTar

# build it
echo 'Building gcc.'
mkdir -p build-native
cd build-native
../gcc-$gccVers/configure  --with-gcc --with-gnu-ld --with-gnu-as --prefix=$prefix  --enable-threads --disable-nls --enable-languages=c,c++ --disable-multilib \
	>$root/configure-gcc-native-log 2>&1 ||
	die "Configure of gcc failed."
make "CFLAGS=-O2" "LDFLAGS=-s" bootstrap >$root/build-gcc-native-log 2>&1 ||
	die "Build of gcc failed."

# install it
make install

echo 'Success.'

--------------10C82F272A5633E795DF7656--