mirror of
https://github.com/crosstool-ng/crosstool-ng.git
synced 2024-12-19 04:47:52 +00:00
binutils: split binutils to backend/frontend, a-la cc_core
Move the actual binutils code to a backend function that builds the required combo of build/host/target as requested by a frontend. This split is currently a no-op, but is required for the upcoming canadian-cross rework, where we'll be needing to build two binutils, one for build/build/target, and one for build/host/target. This applies to the three binutils: - GNU binutils - elf2flt - sstrip Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
This commit is contained in:
parent
08161250ed
commit
533e5c128c
@ -15,39 +15,92 @@ do_binutils_extract() {
|
||||
CT_Patch "binutils" "${CT_BINUTILS_VERSION}"
|
||||
}
|
||||
|
||||
# Build binutils
|
||||
do_binutils() {
|
||||
# Build binutils for host -> target
|
||||
do_binutils_for_host() {
|
||||
local -a binutils_tools
|
||||
local -a binutils_opts
|
||||
|
||||
CT_DoStep INFO "Installing binutils for host"
|
||||
CT_mkdir_pushd "${CT_BUILD_DIR}/build-binutils-host-${CT_HOST}"
|
||||
|
||||
binutils_opts+=( "host=${CT_HOST}" )
|
||||
binutils_opts+=( "prefix=${CT_PREFIX_DIR}" )
|
||||
binutils_opts+=( "static_build=${CT_STATIC_TOOLCHAIN}" )
|
||||
binutils_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
|
||||
binutils_opts+=( "build_manuals=${CT_BUILD_MANUALS}" )
|
||||
|
||||
do_binutils_backend "${binutils_opts[@]}"
|
||||
|
||||
# Make those new tools available to the core C compilers to come.
|
||||
# Note: some components want the ${TARGET}-{ar,as,ld,strip} commands as
|
||||
# well. Create that.
|
||||
# Don't do it for canadian or cross-native, because the binutils
|
||||
# are not executable on the build machine.
|
||||
case "${CT_TOOLCHAIN_TYPE}" in
|
||||
cross|native)
|
||||
binutils_tools=( ar as ld strip )
|
||||
case "${CT_BINUTILS_LINKERS_LIST}" in
|
||||
ld) binutils_tools+=( ld.bfd ) ;;
|
||||
gold) binutils_tools+=( ld.gold ) ;;
|
||||
ld,gold) binutils_tools+=( ld.bfd ld.gold ) ;;
|
||||
gold,ld) binutils_tools+=( ld.bfd ld.gold ) ;;
|
||||
esac
|
||||
mkdir -p "${CT_BUILDTOOLS_PREFIX_DIR}/${CT_TARGET}/bin"
|
||||
mkdir -p "${CT_BUILDTOOLS_PREFIX_DIR}/bin"
|
||||
for t in "${binutils_tools[@]}"; do
|
||||
CT_DoExecLog ALL ln -sv \
|
||||
"${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" \
|
||||
"${CT_BUILDTOOLS_PREFIX_DIR}/${CT_TARGET}/bin/${t}"
|
||||
CT_DoExecLog ALL ln -sv \
|
||||
"${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" \
|
||||
"${CT_BUILDTOOLS_PREFIX_DIR}/bin/${CT_TARGET}-${t}"
|
||||
done
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
|
||||
CT_Popd
|
||||
CT_EndStep
|
||||
}
|
||||
|
||||
# Build binutils for X -> target
|
||||
# Parameter : description : type : default
|
||||
# host : machine to run on : tuple : (none)
|
||||
# prefix : prefix to install into : dir : (none)
|
||||
# static_build : build statcially : bool : no
|
||||
# cflags : host cflags to use : string : (empty)
|
||||
# build_manuals : whether to build manuals : bool : no
|
||||
do_binutils_backend() {
|
||||
local host
|
||||
local prefix
|
||||
local static_build
|
||||
local cflags
|
||||
local build_manuals=no
|
||||
local -a extra_config
|
||||
local -a extra_make_flags
|
||||
local -a binutils_tools
|
||||
local -a manuals_for
|
||||
local -a manuals_install
|
||||
local arg
|
||||
|
||||
mkdir -p "${CT_BUILD_DIR}/build-binutils"
|
||||
cd "${CT_BUILD_DIR}/build-binutils"
|
||||
|
||||
CT_DoStep INFO "Installing binutils"
|
||||
for arg in "$@"; do
|
||||
eval "${arg// /\\ }"
|
||||
done
|
||||
|
||||
CT_DoLog EXTRA "Configuring binutils"
|
||||
|
||||
binutils_tools=( ar as ld strip )
|
||||
if [ "${CT_BINUTILS_HAS_GOLD}" = "y" ]; then
|
||||
case "${CT_BINUTILS_LINKERS_LIST}" in
|
||||
ld)
|
||||
extra_config+=( --enable-ld=yes --enable-gold=no )
|
||||
binutils_tools+=( ld.bfd )
|
||||
;;
|
||||
gold)
|
||||
extra_config+=( --enable-ld=no --enable-gold=yes )
|
||||
binutils_tools+=( ld.gold )
|
||||
;;
|
||||
ld,gold)
|
||||
extra_config+=( --enable-ld=default --enable-gold=yes )
|
||||
binutils_tools+=( ld.bfd ld.gold )
|
||||
;;
|
||||
gold,ld)
|
||||
extra_config+=( --enable-ld=yes --enable-gold=default )
|
||||
binutils_tools+=( ld.bfd ld.gold )
|
||||
;;
|
||||
esac
|
||||
if [ "${CT_BINUTILS_GOLD_THREADED}" = "y" ]; then
|
||||
@ -72,20 +125,20 @@ do_binutils() {
|
||||
CT_DoLog DEBUG "Extra config passed: '${extra_config[*]}'"
|
||||
|
||||
CT_DoExecLog CFG \
|
||||
CFLAGS="${CT_CFLAGS_FOR_HOST}" \
|
||||
CXXFLAGS="${CT_CFLAGS_FOR_HOST}" \
|
||||
CFLAGS="${cflags}" \
|
||||
CXXFLAGS="${cflags}" \
|
||||
"${CT_SRC_DIR}/binutils-${CT_BINUTILS_VERSION}/configure" \
|
||||
--build=${CT_BUILD} \
|
||||
--host=${CT_HOST} \
|
||||
--host=${host} \
|
||||
--target=${CT_TARGET} \
|
||||
--prefix=${CT_PREFIX_DIR} \
|
||||
--prefix=${prefix} \
|
||||
--disable-werror \
|
||||
"${extra_config[@]}" \
|
||||
${CT_ARCH_WITH_FLOAT} \
|
||||
${BINUTILS_SYSROOT_ARG} \
|
||||
"${CT_BINUTILS_EXTRA_CONFIG_ARRAY[@]}"
|
||||
|
||||
if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then
|
||||
if [ "${static_build}" = "y" ]; then
|
||||
extra_make_flags+=("LDFLAGS=-static -all-static")
|
||||
CT_DoLog EXTRA "Prepare binutils for static build"
|
||||
CT_DoExecLog ALL make ${JOBSFLAGS} configure-host
|
||||
@ -97,7 +150,7 @@ do_binutils() {
|
||||
CT_DoLog EXTRA "Installing binutils"
|
||||
CT_DoExecLog ALL make install
|
||||
|
||||
if [ "${CT_BUILD_MANUALS}" = "y" ]; then
|
||||
if [ "${build_manuals}" = "y" ]; then
|
||||
CT_DoLog EXTRA "Building and installing the binutils manuals"
|
||||
manuals_for=( gas binutils ld gprof )
|
||||
if [ "${CT_BINUTILS_LINKER_GOLD}" = "y" ]; then
|
||||
@ -112,39 +165,20 @@ do_binutils() {
|
||||
# Install the wrapper if needed
|
||||
if [ "${CT_BINUTILS_LD_WRAPPER}" = "y" ]; then
|
||||
CT_DoLog EXTRA "Installing ld wrapper"
|
||||
rm -f "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ld"
|
||||
rm -f "${CT_PREFIX_DIR}/${CT_TARGET}/bin/ld"
|
||||
rm -f "${prefix}/bin/${CT_TARGET}-ld"
|
||||
rm -f "${prefix}/${CT_TARGET}/bin/ld"
|
||||
sed -r -e "s/@@DEFAULT_LD@@/${CT_BINUTILS_LINKER_DEFAULT}/" \
|
||||
"${CT_LIB_DIR}/scripts/build/binutils/binutils-ld.in" \
|
||||
>"${CT_PREFIX_DIR}/bin/${CT_TARGET}-ld"
|
||||
chmod +x "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ld"
|
||||
cp -a "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ld" \
|
||||
"${CT_PREFIX_DIR}/${CT_TARGET}/bin/ld"
|
||||
>"${prefix}/bin/${CT_TARGET}-ld"
|
||||
chmod +x "${prefix}/bin/${CT_TARGET}-ld"
|
||||
cp -a "${prefix}/bin/${CT_TARGET}-ld" \
|
||||
"${prefix}/${CT_TARGET}/bin/ld"
|
||||
|
||||
# If needed, force using ld.bfd during the toolchain build
|
||||
if [ "${CT_BINUTILS_FORCE_LD_BFD}" = "y" ]; then
|
||||
export CTNG_LD_IS=bfd
|
||||
fi
|
||||
fi
|
||||
|
||||
# Make those new tools available to the core C compilers to come.
|
||||
# Note: some components want the ${TARGET}-{ar,as,ld,strip} commands as
|
||||
# well. Create that.
|
||||
# Don't do it for canadian or cross-native, because the binutils
|
||||
# are not executable on the build machine.
|
||||
case "${CT_TOOLCHAIN_TYPE}" in
|
||||
cross|native)
|
||||
mkdir -p "${CT_BUILDTOOLS_PREFIX_DIR}/${CT_TARGET}/bin"
|
||||
mkdir -p "${CT_BUILDTOOLS_PREFIX_DIR}/bin"
|
||||
for t in "${binutils_tools[@]}"; do
|
||||
ln -sv "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" "${CT_BUILDTOOLS_PREFIX_DIR}/${CT_TARGET}/bin/${t}"
|
||||
ln -sv "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" "${CT_BUILDTOOLS_PREFIX_DIR}/bin/${CT_TARGET}-${t}"
|
||||
done 2>&1 |CT_DoLog ALL
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
|
||||
CT_EndStep
|
||||
}
|
||||
|
||||
# Now on for the target libraries
|
||||
|
@ -6,7 +6,7 @@
|
||||
# Default: do nothing
|
||||
do_elf2flt_get() { :; }
|
||||
do_elf2flt_extract() { :; }
|
||||
do_elf2flt() { :; }
|
||||
do_elf2flt_for_host() { :; }
|
||||
|
||||
if [ -n "${CT_ARCH_BINFMT_FLAT}" ]; then
|
||||
|
||||
@ -25,25 +25,74 @@ do_elf2flt_extract() {
|
||||
CT_Patch "elf2flt-cvs" "${CT_ELF2FLT_VERSION}"
|
||||
}
|
||||
|
||||
# Build elf2flt
|
||||
do_elf2flt() {
|
||||
mkdir -p "${CT_BUILD_DIR}/build-elf2flt"
|
||||
cd "${CT_BUILD_DIR}/build-elf2flt"
|
||||
# Build elf2flt for host -> target
|
||||
do_elf2flt_for_host() {
|
||||
local -a elf2flt_opts
|
||||
|
||||
CT_DoStep INFO "Installing elf2flt"
|
||||
CT_DoStep INFO "Installing elf2flt for host"
|
||||
CT_mkdir_pushd "${CT_BUILD_DIR}/build-elf2flt-host-${CT_HOST}"
|
||||
|
||||
elf2flt_opts+=( "host=${CT_HOST}" )
|
||||
elf2flt_opts+=( "prefix=${CT_PREFIX_DIR}" )
|
||||
elf2flt_opts+=( "static_build=${CT_STATIC_TOOLCHAIN}" )
|
||||
elf2flt_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
|
||||
|
||||
do_elf2flt_backend "${elf2flt_opts[@]}"
|
||||
|
||||
# Make those new tools available to the core C compilers to come.
|
||||
# Note: some components want the ${TARGET}-{ar,as,ld,strip} commands as
|
||||
# well. Create that.
|
||||
# Don't do it for canadian or cross-native, because the binutils
|
||||
# are not executable on the build machine.
|
||||
case "${CT_TOOLCHAIN_TYPE}" in
|
||||
cross|native)
|
||||
mkdir -p "${CT_BUILDTOOLS_PREFIX_DIR}/${CT_TARGET}/bin"
|
||||
mkdir -p "${CT_BUILDTOOLS_PREFIX_DIR}/bin"
|
||||
for t in elf2flt flthdr; do
|
||||
CT_DoExecLog ALL ln -sv \
|
||||
"${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" \
|
||||
"${CT_BUILDTOOLS_PREFIX_DIR}/${CT_TARGET}/bin/${t}"
|
||||
CT_DoExecLog ALL ln -sv \
|
||||
"${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" \
|
||||
"${CT_BUILDTOOLS_PREFIX_DIR}/bin/${CT_TARGET}-${t}"
|
||||
done
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
|
||||
CT_Popd
|
||||
CT_EndStep
|
||||
}
|
||||
|
||||
# Build elf2flt for X -> target
|
||||
# Parameter : description : type : default
|
||||
# host : machine to run on : tuple : (none)
|
||||
# prefix : prefix to install into : dir : (none)
|
||||
# static_build : build statcially : bool : no
|
||||
# cflags : host cflags to use : string : (empty)
|
||||
do_elf2flt_backend() {
|
||||
local host
|
||||
local prefix
|
||||
local static_build
|
||||
local cflags
|
||||
local arg
|
||||
|
||||
for arg in "$@"; do
|
||||
eval "${arg// /\\ }"
|
||||
done
|
||||
|
||||
elf2flt_opts=
|
||||
binutils_bld=${CT_BUILD_DIR}/build-binutils
|
||||
binutils_src=${CT_SRC_DIR}/binutils-${CT_BINUTILS_VERSION}
|
||||
binutils_bld="${CT_BUILD_DIR}/build-binutils-host-${CT_HOST}"
|
||||
binutils_src="${CT_SRC_DIR}/binutils-${CT_BINUTILS_VERSION}"
|
||||
|
||||
CT_DoLog EXTRA "Configuring elf2flt"
|
||||
CT_DoExecLog CFG \
|
||||
CFLAGS="${CT_CFLAGS_FOR_HOST}" \
|
||||
CFLAGS="${host_cflags}" \
|
||||
"${CT_SRC_DIR}/elf2flt-cvs-${CT_ELF2FLT_VERSION}/configure" \
|
||||
--build=${CT_BUILD} \
|
||||
--host=${CT_HOST} \
|
||||
--host=${host} \
|
||||
--target=${CT_TARGET} \
|
||||
--prefix=${CT_PREFIX_DIR} \
|
||||
--prefix=${prefix} \
|
||||
--with-bfd-include-dir=${binutils_bld}/bfd \
|
||||
--with-binutils-include-dir=${binutils_src}/include \
|
||||
--with-libbfd=${binutils_bld}/bfd/libbfd.a \
|
||||
@ -56,25 +105,6 @@ do_elf2flt() {
|
||||
|
||||
CT_DoLog EXTRA "Installing elf2flt"
|
||||
CT_DoExecLog ALL make install
|
||||
|
||||
# Make those new tools available to the core C compilers to come.
|
||||
# Note: some components want the ${TARGET}-{ar,as,ld,strip} commands as
|
||||
# well. Create that.
|
||||
# Don't do it for canadian or cross-native, because the binutils
|
||||
# are not executable on the build machine.
|
||||
case "${CT_TOOLCHAIN_TYPE}" in
|
||||
cross|native)
|
||||
mkdir -p "${CT_BUILDTOOLS_PREFIX_DIR}/${CT_TARGET}/bin"
|
||||
mkdir -p "${CT_BUILDTOOLS_PREFIX_DIR}/bin"
|
||||
for t in elf2flt flthdr; do
|
||||
ln -sv "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" "${CT_BUILDTOOLS_PREFIX_DIR}/${CT_TARGET}/bin/${t}"
|
||||
ln -sv "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" "${CT_BUILDTOOLS_PREFIX_DIR}/bin/${CT_TARGET}-${t}"
|
||||
done 2>&1 |CT_DoLog ALL
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
|
||||
CT_EndStep
|
||||
}
|
||||
|
||||
fi # CT_ARCH_BINFMT_FLAT
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
do_sstrip_get() { :; }
|
||||
do_sstrip_extract() { :; }
|
||||
do_sstrip() { :; }
|
||||
do_sstrip_for_host() { :; }
|
||||
|
||||
if [ "${CT_SSTRIP}" = "y" ]; then
|
||||
do_sstrip_get() {
|
||||
@ -19,11 +19,13 @@ if [ "${CT_SSTRIP}" = "y" ]; then
|
||||
CT_DoExecLog DEBUG cp -v "${CT_TARBALLS_DIR}/sstrip.c" "${CT_SRC_DIR}/sstrip"
|
||||
}
|
||||
|
||||
do_sstrip() {
|
||||
# Build sstrip for host -> target
|
||||
# Note: we don't need sstrip to run on the build machine,
|
||||
# so we do not need the frontend/backend stuff...
|
||||
do_sstrip_for_host() {
|
||||
local sstrip_cflags
|
||||
CT_DoStep INFO "Installing sstrip"
|
||||
mkdir -p "${CT_BUILD_DIR}/build-sstrip"
|
||||
cd "${CT_BUILD_DIR}/build-sstrip"
|
||||
CT_DoStep INFO "Installing sstrip for host"
|
||||
CT_mkdir_pushd "${CT_BUILD_DIR}/build-sstrip-host"
|
||||
|
||||
if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then
|
||||
sstrip_cflags="-static"
|
||||
@ -35,6 +37,7 @@ if [ "${CT_SSTRIP}" = "y" ]; then
|
||||
CT_DoLog EXTRA "Installing sstrip"
|
||||
CT_DoExecLog ALL install -m 755 sstrip "${CT_PREFIX_DIR}/bin/${CT_TARGET}-sstrip"
|
||||
|
||||
CT_Popd
|
||||
CT_EndStep
|
||||
}
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user