Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ROSBE-Unix] Install amd64 gcc toolchain along with i386 one #12

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions Patches/binutils-seh_pushframe-jgardou.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
diff --git a/gas/config/obj-coff-seh.c b/gas/config/obj-coff-seh.c
index 964fe87e0ac..f907e729bcf 100644
--- a/gas/config/obj-coff-seh.c
+++ b/gas/config/obj-coff-seh.c
@@ -582,12 +582,31 @@ obj_coff_seh_pushreg (int what ATTRIBUTE_UNUSED)
static void
obj_coff_seh_pushframe (int what ATTRIBUTE_UNUSED)
{
+ int code = 0;
+
if (!verify_context_and_target (".seh_pushframe", seh_kind_x64)
|| !seh_validate_seg (".seh_pushframe"))
return;
+
+ SKIP_WHITESPACE();
+
+ if (is_name_beginner (*input_line_pointer))
+ {
+ char* identifier;
+
+ get_symbol_name (&identifier);
+ if (strcmp (identifier, "code") != 0)
+ {
+ as_bad(_("invalid argument \"%s\" for .seh_pushframe. Expected \"code\" or nothing"),
+ identifier);
+ return;
+ }
+ code = 1;
+ }
+
demand_empty_rest_of_line ();

- seh_x64_make_prologue_element (UWOP_PUSH_MACHFRAME, 0, 0);
+ seh_x64_make_prologue_element (UWOP_PUSH_MACHFRAME, code, 0);
}

/* Add a register save-unwind token to current context. */
--
2.27.0

202 changes: 115 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,17 @@ 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
declare -A rs_gcc_configures_flags
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=(["i386"]="-pipe -O2 -Wl,-S -g0 -march=pentium -mtune=i686" ["amd64"]="-pipe -O2 -Wl,-S -g0")
rs_gcc_configures_flags=(
["i386"]="--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"
["amd64"]="--enable-fully-dynamic-string --enable-version-specific-runtime-libs --disable-shared --disable-multilib --disable-nls --disable-werror --disable-win32-registry --disable-libstdcxx-verbose"
)

export CC="$rs_host_cc"
export CFLAGS="$rs_host_cflags"
Expand All @@ -38,7 +43,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 +163,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 +204,91 @@ 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]}
rs_gcc_configure_flags=${rs_gcc_configures_flags[$TARGET_ARCH]}

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

mkdir -p "$rs_archprefixdir/$rs_target"

echo "Building toolchain for ${TARGET_ARCH}"
echo "Prefix: $rs_archprefixdir"
echo "Target: $rs_target"
echo "Target C flags: $rs_target_cflags"
echo "Target C++ flags: $rs_target_cxxflags"
echo "GCC configure flags: $rs_gcc_configure_flags"

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++ $rs_gcc_configure_flags
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 +304,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 +323,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 amd64 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