Skip to content

Commit

Permalink
[ROSBE-Unix] Install amd64 gcc toolchain along with i386 one
Browse files Browse the repository at this point in the history
  • Loading branch information
zefklop committed Apr 9, 2021
1 parent ee9cf18 commit b035c67
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 87 deletions.
189 changes: 102 additions & 87 deletions RosBE-Unix/Base-i386/RosBE-Builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ rs_host_cxx="${CXX:-g++}"
rs_host_cxxflags="${CXXFLAGS:-$rs_host_cflags}"
rs_needed_tools="as bzip2 find $CC $CXX grep m4 makeinfo python tar" # GNU Make has a special check
rs_needed_libs="zlib"
rs_target="i686-w64-mingw32"
rs_target_cflags="-pipe -O2 -Wl,-S -g0 -march=pentium -mtune=i686"
rs_target_cxxflags="$rs_target_cflags"

# This is a cross-compiler with prefix.
rs_target_tool_prefix="${rs_target}-"
declare -A rs_targets
declare -A rs_targets_cflags
declare -A rs_targets_cxxflags
rs_targets=(["i386"]="i686-w64-mingw32" ["amd64"]="x86_64-w64-mingw32")
rs_targets_cflags=(["i386"]="-pipe -O2 -Wl,-S -g0 -march=pentium -mtune=i686" ["amd64"]="-pipe -O2 -Wl,-S -g0")
rs_targets_cxxflags=$rs_targets_cflags

export CC="$rs_host_cc"
export CFLAGS="$rs_host_cflags"
Expand All @@ -38,7 +38,7 @@ rs_sourcedir="$rs_scriptdir/sources"
# RosBE-Unix Constants
DEFAULT_INSTALL_DIR="/usr/local/RosBE"
ROSBE_VERSION="2.2.1"
TARGET_ARCH="i386"
TARGET_ARCHS=("i386" "amd64")

source "$rs_scriptdir/scripts/rosbelibrary.sh"
source "$rs_scriptdir/scripts/setuplibrary.sh"
Expand Down Expand Up @@ -158,13 +158,11 @@ rm -rf "$installdir" || exit 1
mkdir -p "$installdir" || exit 1

rs_prefixdir="$installdir"
rs_archprefixdir="$installdir/$TARGET_ARCH"

##### BEGIN almost shared buildtoolchain/RosBE-Unix building part #############
rs_boldmsg "Building..."

mkdir -p "$rs_prefixdir/bin"
mkdir -p "$rs_archprefixdir/$rs_target"

echo "Using CFLAGS=\"$CFLAGS\""
echo "Using CXXFLAGS=\"$CXXFLAGS\""
Expand Down Expand Up @@ -201,71 +199,83 @@ if rs_prepare_module "cmake"; then
rs_clean_module "cmake"
fi

if rs_prepare_module "binutils"; then
rs_do_command ../binutils/configure --prefix="$rs_archprefixdir" --target="$rs_target" --with-sysroot="$rs_archprefixdir" --disable-multilib --disable-werror --enable-lto --enable-plugins --with-zlib=yes --disable-nls
rs_do_command $rs_makecmd -j $rs_cpucount
rs_do_command $rs_makecmd install
rs_clean_module "binutils"
fi

if rs_prepare_module "mingw_w64"; then
rs_do_command ../mingw_w64/mingw-w64-headers/configure --prefix="$rs_archprefixdir/$rs_target" --host="$rs_target"
rs_do_command $rs_makecmd -j $rs_cpucount
rs_do_command $rs_makecmd install
rs_do_command ln -s -f $rs_archprefixdir/$rs_target $rs_archprefixdir/mingw
rs_clean_module "mingw_w64"
fi

if rs_prepare_module "gcc"; then
rs_extract_module gmp $PWD/../gcc
rs_extract_module mpc $PWD/../gcc
rs_extract_module mpfr $PWD/../gcc

cd ../gcc-build

export CFLAGS_FOR_TARGET="$rs_target_cflags"
export CXXFLAGS_FOR_TARGET="$rs_target_cxxflags"

rs_do_command ../gcc/configure --prefix="$rs_archprefixdir" --target="$rs_target" --with-sysroot="$rs_archprefixdir" --with-pkgversion="RosBE-Unix" --enable-languages=c,c++ --enable-fully-dynamic-string --enable-version-specific-runtime-libs --disable-shared --disable-multilib --disable-nls --disable-werror --disable-win32-registry --enable-sjlj-exceptions --disable-libstdcxx-verbose
rs_do_command $rs_makecmd -j $rs_cpucount all-gcc
rs_do_command $rs_makecmd install-gcc
rs_do_command $rs_makecmd install-lto-plugin

if rs_prepare_module "mingw_w64"; then
export AR="$rs_archprefixdir/bin/${rs_target_tool_prefix}ar"
export AS="$rs_archprefixdir/bin/${rs_target_tool_prefix}as"
export CC="$rs_archprefixdir/bin/${rs_target_tool_prefix}gcc"
export CFLAGS="$rs_target_cflags"
export CXX="$rs_archprefixdir/bin/${rs_target_tool_prefix}g++"
export CXXFLAGS="$rs_target_cxxflags"
export DLLTOOL="$rs_archprefixdir/bin/${rs_target_tool_prefix}dlltool"
export RANLIB="$rs_archprefixdir/bin/${rs_target_tool_prefix}ranlib"
export STRIP="$rs_archprefixdir/bin/${rs_target_tool_prefix}strip"

rs_do_command ../mingw_w64/mingw-w64-crt/configure --prefix="$rs_archprefixdir/$rs_target" --host="$rs_target" --with-sysroot="$rs_archprefixdir"
rs_do_command $rs_makecmd -j $rs_cpucount
rs_do_command $rs_makecmd install
rs_clean_module "mingw_w64"

unset AR
unset AS
export CC="$rs_host_cc"
export CFLAGS="$rs_host_cflags"
export CXX="$rs_host_cxx"
export CXXFLAGS="$rs_host_cxxflags"
unset DLLTOOL
unset RANLIB
unset STRIP
fi

cd "$rs_workdir/gcc-build"
rs_do_command $rs_makecmd -j $rs_cpucount
rs_do_command $rs_makecmd install
rs_clean_module "gcc"

unset CFLAGS_FOR_TARGET
unset CXXFLAGS_FOR_TARGET
fi
for TARGET_ARCH in ${TARGET_ARCHS[@]}; do
rs_archprefixdir="$installdir/$TARGET_ARCH"
rs_target=${rs_targets[$TARGET_ARCH]}
rs_target_cflags=${rs_targets_cflags[$TARGET_ARCH]}
rs_target_cxxflags=${rs_targets_cxxflags[$TARGET_ARCH]}

# This is a cross-compiler with prefix.
rs_target_tool_prefix="${rs_target}-"

mkdir -p "$rs_archprefixdir/$rs_target"

if rs_prepare_module "binutils"; then
rs_do_command ../binutils/configure --prefix="$rs_archprefixdir" --target="$rs_target" --with-sysroot="$rs_archprefixdir" --disable-multilib --disable-werror --enable-lto --enable-plugins --with-zlib=yes --disable-nls
rs_do_command $rs_makecmd -j $rs_cpucount
rs_do_command $rs_makecmd install
rs_clean_module "binutils"
fi

if rs_prepare_module "mingw_w64"; then
rs_do_command ../mingw_w64/mingw-w64-headers/configure --prefix="$rs_archprefixdir/$rs_target" --host="$rs_target"
rs_do_command $rs_makecmd -j $rs_cpucount
rs_do_command $rs_makecmd install
rs_do_command ln -s -f $rs_archprefixdir/$rs_target $rs_archprefixdir/mingw
rs_clean_module "mingw_w64"
fi

if rs_prepare_module "gcc"; then
rs_extract_module gmp $PWD/../gcc
rs_extract_module mpc $PWD/../gcc
rs_extract_module mpfr $PWD/../gcc

cd ../gcc-build

export CFLAGS_FOR_TARGET="$rs_target_cflags"
export CXXFLAGS_FOR_TARGET="$rs_target_cxxflags"

rs_do_command ../gcc/configure --prefix="$rs_archprefixdir" --target="$rs_target" --with-sysroot="$rs_archprefixdir" --with-pkgversion="RosBE-Unix" --enable-languages=c,c++ --enable-fully-dynamic-string --enable-version-specific-runtime-libs --disable-shared --disable-multilib --disable-nls --disable-werror --disable-win32-registry --enable-sjlj-exceptions --disable-libstdcxx-verbose
rs_do_command $rs_makecmd -j $rs_cpucount all-gcc
rs_do_command $rs_makecmd install-gcc
rs_do_command $rs_makecmd install-lto-plugin

if rs_prepare_module "mingw_w64"; then
export AR="$rs_archprefixdir/bin/${rs_target_tool_prefix}ar"
export AS="$rs_archprefixdir/bin/${rs_target_tool_prefix}as"
export CC="$rs_archprefixdir/bin/${rs_target_tool_prefix}gcc"
export CFLAGS="$rs_target_cflags"
export CXX="$rs_archprefixdir/bin/${rs_target_tool_prefix}g++"
export CXXFLAGS="$rs_target_cxxflags"
export DLLTOOL="$rs_archprefixdir/bin/${rs_target_tool_prefix}dlltool"
export RANLIB="$rs_archprefixdir/bin/${rs_target_tool_prefix}ranlib"
export STRIP="$rs_archprefixdir/bin/${rs_target_tool_prefix}strip"

rs_do_command ../mingw_w64/mingw-w64-crt/configure --prefix="$rs_archprefixdir/$rs_target" --host="$rs_target" --with-sysroot="$rs_archprefixdir"
rs_do_command $rs_makecmd -j $rs_cpucount
rs_do_command $rs_makecmd install
rs_clean_module "mingw_w64"

unset AR
unset AS
export CC="$rs_host_cc"
export CFLAGS="$rs_host_cflags"
export CXX="$rs_host_cxx"
export CXXFLAGS="$rs_host_cxxflags"
unset DLLTOOL
unset RANLIB
unset STRIP
fi

cd "$rs_workdir/gcc-build"
rs_do_command $rs_makecmd -j $rs_cpucount
rs_do_command $rs_makecmd install
rs_clean_module "gcc"

unset CFLAGS_FOR_TARGET
unset CXXFLAGS_FOR_TARGET
fi
done

if rs_prepare_module "ninja"; then
rs_do_command ../ninja/configure.py --bootstrap
Expand All @@ -281,9 +291,11 @@ echo "Removing unneeded files..."
cd "$rs_prefixdir"
rm -rf doc man share/info share/man

cd "$rs_archprefixdir"
rm -rf $rs_target/doc $rs_target/share include info man mingw share
rm -f lib/* >& /dev/null
for TARGET_ARCH in ${TARGET_ARCHS[@]}; do
cd "$installdir/$TARGET_ARCH"
rm -rf ${rs_targets[$TARGET_ARCH]}/doc ${rs_targets[$TARGET_ARCH]}/share include info man mingw share
rm -f lib/* >& /dev/null
done
##### END almost shared buildtoolchain/RosBE-Unix building part ###############

# See: https://jira.reactos.org/browse/ROSBE-35
Expand All @@ -298,16 +310,19 @@ if [ "$osname" != "Darwin" ]; then
done

# Executables are created for the host system while most libraries are linked to target components
for exe in `find -name "*.a" -type f -print`; do
$rs_archprefixdir/bin/${rs_target_tool_prefix}objcopy --only-keep-debug $exe $exe.dbg 2>/dev/null
$rs_archprefixdir/bin/${rs_target_tool_prefix}objcopy --strip-debug $exe 2>/dev/null
$rs_archprefixdir/bin/${rs_target_tool_prefix}objcopy --add-gnu-debuglink=$exe.dbg $exe 2>/dev/null
done

for exe in `find -name "*.o" -type f -print`; do
$rs_archprefixdir/bin/${rs_target_tool_prefix}objcopy --only-keep-debug $exe $exe.dbg 2>/dev/null
$rs_archprefixdir/bin/${rs_target_tool_prefix}objcopy --strip-debug $exe 2>/dev/null
$rs_archprefixdir/bin/${rs_target_tool_prefix}objcopy --add-gnu-debuglink=$exe.dbg $exe 2>/dev/null
for TARGET_ARCH in ${TARGET_ARCHS[@]}; do
cd "$installdir/$TARGET_ARCH"
for exe in `find -name "*.a" -type f -print`; do
./bin/${rs_targets[$TARGET_ARCH]}-objcopy --only-keep-debug $exe $exe.dbg 2>/dev/null
./bin/${rs_targets[$TARGET_ARCH]}-objcopy --strip-debug $exe 2>/dev/null
./bin/${rs_targets[$TARGET_ARCH]}-objcopy --add-gnu-debuglink=$exe.dbg $exe 2>/dev/null
done

for exe in `find -name "*.o" -type f -print`; do
./bin/${rs_targets[$TARGET_ARCH]}-objcopy --only-keep-debug $exe $exe.dbg 2>/dev/null
./bin/${rs_targets[$TARGET_ARCH]}-objcopy --strip-debug $exe 2>/dev/null
./bin/${rs_targets[$TARGET_ARCH]}-objcopy --add-gnu-debuglink=$exe.dbg $exe 2>/dev/null
done
done
fi

Expand Down
8 changes: 8 additions & 0 deletions RosBE-Unix/Base-i386/scripts/amd64/version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Show the i386 tool versions
# Part of RosBE for Unix-based Operating Systems
# Copyright 2009 Colin Finck <[email protected]>
#
# Released under GNU GPL v2 or any later version.

x86_64-w64-mingw32-gcc -v 2>&1 | grep "gcc version"
x86_64-w64-mingw32-ld -v

0 comments on commit b035c67

Please sign in to comment.