mirror of
https://github.com/crosstool-ng/crosstool-ng.git
synced 2024-12-21 05:43:09 +00:00
uclibc: merge startfiles/final into single backend.
In preparation for multilib support, use the same "backend" model that is already employed by glibc and musl. Also, the verbosity setting descriptions were swapped. V=2 is actually less verbose than V=1: V=1 prints full commands, while V=2 prints 'CC <file> <defines>'. Signed-off-by: Alexey Neyman <stilor@att.net>
This commit is contained in:
parent
28c24f5034
commit
4ee22d66a8
@ -129,13 +129,13 @@ config LIBC_UCLIBC_VERBOSITY_0
|
||||
|
||||
config LIBC_UCLIBC_VERBOSITY_1
|
||||
bool
|
||||
prompt "Brief build (show defines, ld flags)"
|
||||
prompt "Very verbose build"
|
||||
help
|
||||
Print simplified command lines.
|
||||
|
||||
config LIBC_UCLIBC_VERBOSITY_2
|
||||
bool
|
||||
prompt "Very verbose build"
|
||||
prompt "Brief build (show defines, ld flags)"
|
||||
help
|
||||
Print full command lines.
|
||||
|
||||
|
@ -73,180 +73,129 @@ do_libc_check_config() {
|
||||
|
||||
# Build and install headers and start files
|
||||
do_libc_start_files() {
|
||||
local multi_os_dir multi_root startfiles_dir
|
||||
# Start files and Headers should be configured the same way as the
|
||||
# final libc, but built and installed differently.
|
||||
do_libc_backend libc_mode=startfiles
|
||||
}
|
||||
|
||||
CT_DoStep INFO "Installing C library headers"
|
||||
# This function builds and install the full C library
|
||||
do_libc() {
|
||||
do_libc_backend libc_mode=final
|
||||
}
|
||||
|
||||
# Common backend for 1st and 2nd passes
|
||||
do_libc_backend() {
|
||||
local libc_mode
|
||||
local multi_os_dir multi_root multilib_dir startfiles_dir
|
||||
local jflag=${CT_LIBC_UCLIBC_PARALLEL:+${JOBSFLAGS}}
|
||||
local -a make_args
|
||||
|
||||
for arg in "$@"; do
|
||||
eval "${arg// /\\ }"
|
||||
done
|
||||
|
||||
case "${libc_mode}" in
|
||||
startfiles) CT_DoStep INFO "Installing C library headers & start files";;
|
||||
final) CT_DoStep INFO "Installing C library";;
|
||||
*) CT_Abort "Unsupported (or unset) libc_mode='${libc_mode}'";;
|
||||
esac
|
||||
|
||||
# Simply copy files until uClibc has the ability to build out-of-tree
|
||||
CT_DoLog EXTRA "Copying sources to build dir"
|
||||
CT_DoExecLog ALL cp -a "${CT_SRC_DIR}/${uclibc_name}-${CT_LIBC_VERSION}" \
|
||||
"${CT_BUILD_DIR}/build-libc-headers"
|
||||
cd "${CT_BUILD_DIR}/build-libc-headers"
|
||||
|
||||
# Retrieve the config file
|
||||
CT_DoExecLog ALL cp "${CT_CONFIG_DIR}/uClibc.config" .config
|
||||
"${CT_BUILD_DIR}/build-libc-${libc_mode}"
|
||||
cd "${CT_BUILD_DIR}/build-libc-${libc_mode}"
|
||||
|
||||
multi_os_dir=$( "${CT_TARGET}-gcc" -print-multi-os-directory )
|
||||
multi_root=$( "${CT_TARGET}-gcc" -print-sysroot )
|
||||
startfiles_dir="${multi_root}/usr/lib/${multi_os_dir}"
|
||||
CT_SanitizeVarDir startfiles_dir
|
||||
CT_DoExecLog ALL mkdir -p "${startfiles_dir}"
|
||||
multilib_dir="lib/${multi_os_dir}"
|
||||
startfiles_dir="${multi_root}/usr/${multilib_dir}"
|
||||
CT_SanitizeVarDir multilib_dir startfiles_dir
|
||||
|
||||
# Construct make arguments:
|
||||
# - uClibc uses the CROSS environment variable as a prefix to the compiler
|
||||
# tools to use. Since it requires core pass-1, thusly named compiler is
|
||||
# already available.
|
||||
# - Note about CFLAGS: In uClibc, CFLAGS are generated by Rules.mak,
|
||||
# depending on the configuration of the library. That is, they are tailored
|
||||
# to best fit the target. So it is useless and seems to be a bad thing to
|
||||
# use LIBC_EXTRA_CFLAGS here.
|
||||
# - We do _not_ want to strip anything for now, in case we specifically
|
||||
# asked for a debug toolchain, thus the STRIPTOOL= assignment.
|
||||
make_args=( CROSS_COMPILE="${CT_TARGET}-" \
|
||||
UCLIBC_EXTRA_CFLAGS="-pipe" \
|
||||
PREFIX="${multi_root}/" \
|
||||
MULTILIB_DIR="${multilib_dir}" \
|
||||
LOCALE_DATA_FILENAME="${uclibc_locale_tarball}.tgz" \
|
||||
STRIPTOOL=true \
|
||||
${CT_LIBC_UCLIBC_VERBOSITY} \
|
||||
)
|
||||
|
||||
# Retrieve the config file
|
||||
CT_DoExecLog ALL cp "${CT_CONFIG_DIR}/uClibc.config" .config
|
||||
|
||||
# Force the date of the pregen locale data, as the
|
||||
# newer ones that are referenced are not available
|
||||
CT_DoLog EXTRA "Applying configuration"
|
||||
CT_DoYes "" |CT_DoExecLog ALL \
|
||||
${make} CROSS_COMPILE="${CT_TARGET}-" \
|
||||
UCLIBC_EXTRA_CFLAGS="-pipe" \
|
||||
PREFIX="${multi_root}/" \
|
||||
LOCALE_DATA_FILENAME="${uclibc_locale_tarball}.tgz" \
|
||||
oldconfig
|
||||
CT_DoYes | CT_DoExecLog ALL ${make} "${make_args[@]}" oldconfig
|
||||
|
||||
CT_DoLog EXTRA "Building headers"
|
||||
CT_DoExecLog ALL \
|
||||
${make} ${CT_LIBC_UCLIBC_VERBOSITY} \
|
||||
CROSS_COMPILE="${CT_TARGET}-" \
|
||||
UCLIBC_EXTRA_CFLAGS="-pipe" \
|
||||
PREFIX="${multi_root}/" \
|
||||
LOCALE_DATA_FILENAME="${uclibc_locale_tarball}.tgz" \
|
||||
headers
|
||||
if [ "${libc_mode}" = "startfiles" ]; then
|
||||
CT_DoLog EXTRA "Building headers"
|
||||
CT_DoExecLog ALL ${make} "${make_args[@]}" headers
|
||||
|
||||
CT_DoLog EXTRA "Installing headers"
|
||||
CT_DoExecLog ALL \
|
||||
${make} ${CT_LIBC_UCLIBC_VERBOSITY} \
|
||||
CROSS_COMPILE="${CT_TARGET}-" \
|
||||
UCLIBC_EXTRA_CFLAGS="-pipe" \
|
||||
PREFIX="${multi_root}/" \
|
||||
LOCALE_DATA_FILENAME="${uclibc_locale_tarball}.tgz" \
|
||||
install_headers
|
||||
# Ensure the directory for installing multilib-specific binaries exists.
|
||||
CT_DoExecLog ALL mkdir -p "${startfiles_dir}"
|
||||
|
||||
# The check might look bogus, but it is the same condition as is used
|
||||
# by GCC build script to enable/disable shared library support.
|
||||
if [ "${CT_THREADS}" = "nptl" ]; then
|
||||
CT_DoLog EXTRA "Building start files"
|
||||
CT_DoExecLog ALL \
|
||||
${make} ${CT_LIBC_UCLIBC_PARALLEL:+${JOBSFLAGS}} \
|
||||
CROSS_COMPILE="${CT_TARGET}-" \
|
||||
UCLIBC_EXTRA_CFLAGS="-pipe" \
|
||||
PREFIX="${multi_root}/" \
|
||||
STRIPTOOL=true \
|
||||
${CT_LIBC_UCLIBC_VERBOSITY} \
|
||||
LOCALE_DATA_FILENAME="${uclibc_locale_tarball}.tgz" \
|
||||
lib/crt1.o lib/crti.o lib/crtn.o
|
||||
CT_DoLog EXTRA "Installing headers"
|
||||
CT_DoExecLog ALL ${make} "${make_args[@]}" install_headers
|
||||
|
||||
# From: http://git.openembedded.org/cgit.cgi/openembedded/commit/?id=ad5668a7ac7e0436db92e55caaf3fdf782b6ba3b
|
||||
# libm.so is needed for ppc, as libgcc is linked against libm.so
|
||||
# No problem to create it for other archs.
|
||||
CT_DoLog EXTRA "Building dummy shared libs"
|
||||
CT_DoExecLog ALL "${CT_TARGET}-gcc" -nostdlib \
|
||||
-nostartfiles \
|
||||
-shared \
|
||||
-x c /dev/null \
|
||||
-o libdummy.so
|
||||
# The check might look bogus, but it is the same condition as is used
|
||||
# by GCC build script to enable/disable shared library support.
|
||||
if [ "${CT_THREADS}" = "nptl" ]; then
|
||||
CT_DoLog EXTRA "Building start files"
|
||||
CT_DoExecLog ALL ${make} ${jflag} "${make_args[@]}" \
|
||||
lib/crt1.o lib/crti.o lib/crtn.o
|
||||
|
||||
CT_DoLog EXTRA "Installing start files"
|
||||
CT_DoExecLog ALL ${install} -m 0644 lib/crt1.o lib/crti.o lib/crtn.o \
|
||||
"${startfiles_dir}"
|
||||
# From: http://git.openembedded.org/cgit.cgi/openembedded/commit/?id=ad5668a7ac7e0436db92e55caaf3fdf782b6ba3b
|
||||
# libm.so is needed for ppc, as libgcc is linked against libm.so
|
||||
# No problem to create it for other archs.
|
||||
CT_DoLog EXTRA "Building dummy shared libs"
|
||||
CT_DoExecLog ALL "${CT_TARGET}-gcc" -nostdlib -nostartfiles \
|
||||
-shared -x c /dev/null -o libdummy.so
|
||||
|
||||
CT_DoLog EXTRA "Installing dummy shared libs"
|
||||
CT_DoExecLog ALL ${install} -m 0755 libdummy.so "${startfiles_dir}/libc.so"
|
||||
CT_DoExecLog ALL ${install} -m 0755 libdummy.so "${startfiles_dir}/libm.so"
|
||||
fi # CT_THREADS == nptl
|
||||
CT_DoLog EXTRA "Installing start files"
|
||||
CT_DoExecLog ALL ${install} -m 0644 lib/crt1.o lib/crti.o lib/crtn.o \
|
||||
"${startfiles_dir}"
|
||||
|
||||
CT_EndStep
|
||||
}
|
||||
CT_DoLog EXTRA "Installing dummy shared libs"
|
||||
CT_DoExecLog ALL ${install} -m 0755 libdummy.so "${startfiles_dir}/libc.so"
|
||||
CT_DoExecLog ALL ${install} -m 0755 libdummy.so "${startfiles_dir}/libm.so"
|
||||
fi # CT_THREADS == nptl
|
||||
fi # libc_mode == startfiles
|
||||
|
||||
# This function build and install the full uClibc
|
||||
do_libc() {
|
||||
local multi_os_dir multi_root multilib_dir startfiles_dir
|
||||
if [ "${libc_mode}" = "final" ]; then
|
||||
CT_DoLog EXTRA "Cleaning up startfiles"
|
||||
CT_DoExecLog ALL rm -f "${startfiles_dir}/crt1.o" \
|
||||
"${startfiles_dir}/crti.o" \
|
||||
"${startfiles_dir}/crtn.o" \
|
||||
"${startfiles_dir}/libc.so" \
|
||||
"${startfiles_dir}/libm.so"
|
||||
|
||||
CT_DoStep INFO "Installing C library"
|
||||
CT_DoLog EXTRA "Building C library"
|
||||
CT_DoExecLog ALL ${make} "${make_args[@]}" pregen
|
||||
CT_DoExecLog ALL ${make} ${jflag} "${make_args[@]}" all
|
||||
|
||||
# Simply copy files until uClibc has the ability to build out-of-tree
|
||||
CT_DoLog EXTRA "Copying sources to build dir"
|
||||
CT_DoExecLog ALL cp -av "${CT_SRC_DIR}/${uclibc_name}-${CT_LIBC_VERSION}" \
|
||||
"${CT_BUILD_DIR}/build-libc"
|
||||
cd "${CT_BUILD_DIR}/build-libc"
|
||||
|
||||
# Retrieve the config file
|
||||
CT_DoExecLog ALL cp "${CT_CONFIG_DIR}/uClibc.config" .config
|
||||
|
||||
multi_os_dir=$( "${CT_TARGET}-gcc" -print-multi-os-directory )
|
||||
multi_root=$( "${CT_TARGET}-gcc" -print-sysroot )
|
||||
startfiles_dir="${multi_root}/usr/lib/${multi_os_dir}"
|
||||
|
||||
CT_DoLog EXTRA "Cleaning up startfiles"
|
||||
CT_DoExecLog ALL rm -f "${startfiles_dir}/crt1.o" \
|
||||
"${startfiles_dir}/crti.o" \
|
||||
"${startfiles_dir}/crtn.o" \
|
||||
"${startfiles_dir}/libc.so" \
|
||||
"${startfiles_dir}/libm.so"
|
||||
|
||||
multilib_dir="lib/${multi_os_dir}"
|
||||
CT_SanitizeVarDir multilib_dir
|
||||
|
||||
# uClibc uses the CROSS environment variable as a prefix to the compiler
|
||||
# tools to use. The newly built tools should be in our path, so we need
|
||||
# only give the correct name for them.
|
||||
# Note about CFLAGS: In uClibc, CFLAGS are generated by Rules.mak,
|
||||
# depending on the configuration of the library. That is, they are tailored
|
||||
# to best fit the target. So it is useless and seems to be a bad thing to
|
||||
# use LIBC_EXTRA_CFLAGS here.
|
||||
CT_DoLog EXTRA "Applying configuration"
|
||||
CT_DoYes "" |CT_DoExecLog CFG \
|
||||
${make} CROSS_COMPILE=${CT_TARGET}- \
|
||||
UCLIBC_EXTRA_CFLAGS="-pipe" \
|
||||
PREFIX="${multi_root}/" \
|
||||
LOCALE_DATA_FILENAME="${uclibc_locale_tarball}.tgz" \
|
||||
oldconfig
|
||||
|
||||
# We do _not_ want to strip anything for now, in case we specifically
|
||||
# asked for a debug toolchain, thus the STRIPTOOL= assignment
|
||||
# /Old/ versions can not build in //
|
||||
CT_DoLog EXTRA "Building C library"
|
||||
CT_DoExecLog ALL \
|
||||
${make} -j1 \
|
||||
CROSS_COMPILE=${CT_TARGET}- \
|
||||
UCLIBC_EXTRA_CFLAGS="-pipe" \
|
||||
PREFIX="${multi_root}/" \
|
||||
STRIPTOOL=true \
|
||||
${CT_LIBC_UCLIBC_VERBOSITY} \
|
||||
LOCALE_DATA_FILENAME="${uclibc_locale_tarball}.tgz" \
|
||||
pregen
|
||||
CT_DoExecLog ALL \
|
||||
${make} ${CT_LIBC_UCLIBC_PARALLEL:+${JOBSFLAGS}} \
|
||||
CROSS_COMPILE=${CT_TARGET}- \
|
||||
UCLIBC_EXTRA_CFLAGS="-pipe" \
|
||||
PREFIX="${multi_root}/" \
|
||||
STRIPTOOL=true \
|
||||
${CT_LIBC_UCLIBC_VERBOSITY} \
|
||||
LOCALE_DATA_FILENAME="${uclibc_locale_tarball}.tgz" \
|
||||
all
|
||||
|
||||
# YEM-FIXME:
|
||||
# - we want to install 'runtime' files, eg. lib*.{a,so*}, crti.o and
|
||||
# such files, except the headers as they already are installed
|
||||
# - "make install_dev" installs the headers, the crti.o... and the
|
||||
# static libs, but not the dynamic libs
|
||||
# - "make install_runtime" installs the dynamic libs only
|
||||
# - "make install" calls install_runtime and install_dev
|
||||
# - so we're left with re-installing the headers... Sigh...
|
||||
#
|
||||
# We do _not_ want to strip anything for now, in case we specifically
|
||||
# asked for a debug toolchain, hence the STRIPTOOL= assignment
|
||||
#
|
||||
# Note: JOBSFLAGS is not useful for installation.
|
||||
#
|
||||
CT_DoLog EXTRA "Installing C library"
|
||||
CT_DoExecLog ALL \
|
||||
${make} CROSS_COMPILE=${CT_TARGET}- \
|
||||
UCLIBC_EXTRA_CFLAGS="-pipe" \
|
||||
PREFIX="${multi_root}/" \
|
||||
STRIPTOOL=true \
|
||||
${CT_LIBC_UCLIBC_VERBOSITY} \
|
||||
LOCALE_DATA_FILENAME="${uclibc_locale_tarball}.tgz" \
|
||||
MULTILIB_DIR="${multilib_dir}" \
|
||||
install
|
||||
# YEM-FIXME:
|
||||
# - we want to install 'runtime' files, eg. lib*.{a,so*}, crti.o and
|
||||
# such files, except the headers as they already are installed
|
||||
# - "make install_dev" installs the headers, the crti.o... and the
|
||||
# static libs, but not the dynamic libs
|
||||
# - "make install_runtime" installs the dynamic libs only
|
||||
# - "make install" calls install_runtime and install_dev
|
||||
# - so we're left with re-installing the headers... Sigh...
|
||||
CT_DoLog EXTRA "Installing C library"
|
||||
CT_DoExecLog ALL ${make} "${make_args[@]}" install
|
||||
fi # libc_mode == final
|
||||
|
||||
CT_EndStep
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user