2014-08-01 02:01:46 +00:00
|
|
|
# This file adds functions to build the musl C library
|
|
|
|
# Copyright 2013 Timo Teräs
|
|
|
|
# Licensed under the GPL v2. See COPYING in the root of this package
|
|
|
|
|
Fold libc_start_files into libc
After 557b9d4, libc_start_files and libc_main steps are performed one
after another. It doesn't make sense, especially since some of the libcs
(glibc, uClibc-ng) go to great lengths to first install start files in
the first step, libc_start_files, only to remove them immediately in the
second step, libc_main.
Current build steps also break in the xtensa newlib configurations, as
it needs to install the custom xtensa headers before building the libgcc
and after 557b9d4, the headers are not installed before libgcc is built
in pass-1.
Therefore, finish what 557b9d4 mentioned but did not do: move header
installation into a new step, libc_headers, and combine libc_start_files
and libc_main into a single step.
This also allows to combine the core pass-1/pass-2 steps, to be done in
a subsequent commit.
Signed-off-by: Alexey Neyman <stilor@att.net>
2022-02-08 23:52:48 +00:00
|
|
|
musl_post_cc()
|
2018-11-24 06:14:07 +00:00
|
|
|
{
|
2017-03-13 02:41:09 +00:00
|
|
|
# MUSL creates dynamic linker symlink with absolute path - which works on the
|
|
|
|
# target but not on the host. We want our cross-ldd tool to work.
|
|
|
|
CT_MultilibFixupLDSO
|
2016-03-01 01:20:28 +00:00
|
|
|
}
|
|
|
|
|
Fold libc_start_files into libc
After 557b9d4, libc_start_files and libc_main steps are performed one
after another. It doesn't make sense, especially since some of the libcs
(glibc, uClibc-ng) go to great lengths to first install start files in
the first step, libc_start_files, only to remove them immediately in the
second step, libc_main.
Current build steps also break in the xtensa newlib configurations, as
it needs to install the custom xtensa headers before building the libgcc
and after 557b9d4, the headers are not installed before libgcc is built
in pass-1.
Therefore, finish what 557b9d4 mentioned but did not do: move header
installation into a new step, libc_headers, and combine libc_start_files
and libc_main into a single step.
This also allows to combine the core pass-1/pass-2 steps, to be done in
a subsequent commit.
Signed-off-by: Alexey Neyman <stilor@att.net>
2022-02-08 23:52:48 +00:00
|
|
|
musl_main()
|
|
|
|
{
|
|
|
|
CT_DoStep INFO "Installing C library"
|
|
|
|
CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc"
|
|
|
|
CT_IterateMultilibs musl_backend_once multilib
|
2016-04-14 07:30:34 +00:00
|
|
|
CT_Popd
|
|
|
|
CT_EndStep
|
|
|
|
}
|
|
|
|
|
2016-03-01 01:20:28 +00:00
|
|
|
# This backend builds the C library
|
2018-11-24 06:14:07 +00:00
|
|
|
# Usage: musl_backend param=value [...]
|
2016-03-01 01:20:28 +00:00
|
|
|
# Parameter : Definition : Type : Default
|
Fold libc_start_files into libc
After 557b9d4, libc_start_files and libc_main steps are performed one
after another. It doesn't make sense, especially since some of the libcs
(glibc, uClibc-ng) go to great lengths to first install start files in
the first step, libc_start_files, only to remove them immediately in the
second step, libc_main.
Current build steps also break in the xtensa newlib configurations, as
it needs to install the custom xtensa headers before building the libgcc
and after 557b9d4, the headers are not installed before libgcc is built
in pass-1.
Therefore, finish what 557b9d4 mentioned but did not do: move header
installation into a new step, libc_headers, and combine libc_start_files
and libc_main into a single step.
This also allows to combine the core pass-1/pass-2 steps, to be done in
a subsequent commit.
Signed-off-by: Alexey Neyman <stilor@att.net>
2022-02-08 23:52:48 +00:00
|
|
|
# multi_* : as defined in CT_IterateMultilibs : (varies) :
|
|
|
|
musl_backend_once()
|
|
|
|
{
|
2014-08-01 02:01:46 +00:00
|
|
|
local -a extra_cflags
|
2014-09-05 06:34:00 +00:00
|
|
|
local -a extra_config
|
2017-05-30 05:32:38 +00:00
|
|
|
local src_dir="${CT_SRC_DIR}/musl"
|
2016-04-14 07:30:34 +00:00
|
|
|
local multi_dir multi_os_dir multi_root multi_flags multi_index multi_count
|
|
|
|
local multilib_dir
|
2019-10-18 22:09:01 +00:00
|
|
|
local musl_cflags
|
2016-04-14 07:30:34 +00:00
|
|
|
local hdr_install_subdir
|
|
|
|
local arg f l
|
2016-03-01 01:20:28 +00:00
|
|
|
|
|
|
|
for arg in "$@"; do
|
|
|
|
eval "${arg// /\\ }"
|
|
|
|
done
|
|
|
|
|
2016-04-14 07:30:34 +00:00
|
|
|
CT_DoStep INFO "Building for multilib ${multi_index}/${multi_count}: '${multi_flags}'"
|
2014-08-01 02:01:46 +00:00
|
|
|
|
2016-03-21 18:18:53 +00:00
|
|
|
multilib_dir="/usr/lib/${multi_os_dir}"
|
|
|
|
CT_SanitizeVarDir multilib_dir
|
|
|
|
CT_DoExecLog ALL mkdir -p "${multi_root}${multilib_dir}"
|
|
|
|
|
2019-10-18 22:09:01 +00:00
|
|
|
musl_cflags+=" ${CT_ALL_TARGET_CFLAGS}"
|
|
|
|
musl_cflags+=" ${CT_LIBC_MUSL_EXTRA_CFLAGS}"
|
|
|
|
musl_cflags+=" ${multi_flags}"
|
2016-04-14 07:30:34 +00:00
|
|
|
|
2014-09-05 06:34:01 +00:00
|
|
|
if [ "${CT_LIBC_MUSL_DEBUG}" = "y" ]; then
|
|
|
|
extra_config+=("--enable-debug")
|
|
|
|
fi
|
|
|
|
|
2014-09-05 06:34:02 +00:00
|
|
|
if [ "${CT_LIBC_MUSL_WARNINGS}" = "y" ]; then
|
|
|
|
extra_config+=("--enable-warnings")
|
|
|
|
fi
|
|
|
|
|
2019-02-24 07:36:46 +00:00
|
|
|
case "${CT_SHARED_LIBS}" in
|
|
|
|
y) extra_config+=("--enable-shared");;
|
|
|
|
*) extra_config+=("--disable-shared");;
|
|
|
|
esac
|
|
|
|
|
2014-09-05 06:34:00 +00:00
|
|
|
extra_config+=( "--enable-optimize=${CT_LIBC_MUSL_OPTIMIZE}" )
|
|
|
|
|
2016-04-14 07:30:34 +00:00
|
|
|
# Same problem as with uClibc: different variants sometimes have
|
|
|
|
# incompatible headers.
|
|
|
|
CT_DoArchMUSLHeaderDir hdr_install_subdir "${multi_flags}"
|
|
|
|
if [ -n "${hdr_install_subdir}" ]; then
|
|
|
|
extra_config+=( "--includedir=/usr/include/${hdr_install_subdir}" )
|
|
|
|
fi
|
2016-03-01 01:20:28 +00:00
|
|
|
|
2017-03-12 23:56:19 +00:00
|
|
|
CT_SymlinkToolsMultilib
|
|
|
|
|
2014-08-01 02:01:46 +00:00
|
|
|
# NOTE: musl handles the build/host/target a little bit differently
|
|
|
|
# then one would expect:
|
|
|
|
# build : not used
|
2016-03-21 18:18:53 +00:00
|
|
|
# host : same as --target
|
2014-08-01 02:01:46 +00:00
|
|
|
# target : the machine musl runs on
|
2016-04-14 07:30:34 +00:00
|
|
|
CT_DoExecLog CFG \
|
2019-10-18 22:09:01 +00:00
|
|
|
CFLAGS="${musl_cflags}" \
|
2019-12-04 14:44:49 +00:00
|
|
|
LDFLAGS="${CT_TARGET_LDFLAGS}" \
|
2016-04-14 07:30:34 +00:00
|
|
|
CROSS_COMPILE="${CT_TARGET}-" \
|
2017-01-25 08:06:28 +00:00
|
|
|
${CONFIG_SHELL} \
|
2016-04-14 07:30:34 +00:00
|
|
|
${src_dir}/configure \
|
|
|
|
--host="${multi_target}" \
|
|
|
|
--target="${multi_target}" \
|
|
|
|
--prefix="/usr" \
|
|
|
|
--libdir="${multilib_dir}" \
|
|
|
|
--disable-gcc-wrapper \
|
2014-09-05 06:34:00 +00:00
|
|
|
"${extra_config[@]}"
|
2014-08-01 02:01:46 +00:00
|
|
|
|
Fold libc_start_files into libc
After 557b9d4, libc_start_files and libc_main steps are performed one
after another. It doesn't make sense, especially since some of the libcs
(glibc, uClibc-ng) go to great lengths to first install start files in
the first step, libc_start_files, only to remove them immediately in the
second step, libc_main.
Current build steps also break in the xtensa newlib configurations, as
it needs to install the custom xtensa headers before building the libgcc
and after 557b9d4, the headers are not installed before libgcc is built
in pass-1.
Therefore, finish what 557b9d4 mentioned but did not do: move header
installation into a new step, libc_headers, and combine libc_start_files
and libc_main into a single step.
This also allows to combine the core pass-1/pass-2 steps, to be done in
a subsequent commit.
Signed-off-by: Alexey Neyman <stilor@att.net>
2022-02-08 23:52:48 +00:00
|
|
|
CT_DoLog EXTRA "Building C library"
|
|
|
|
CT_DoExecLog ALL make ${CT_JOBSFLAGS}
|
|
|
|
|
|
|
|
CT_DoLog EXTRA "Installing C library"
|
|
|
|
CT_DoExecLog ALL make DESTDIR="${multi_root}" install
|
|
|
|
|
|
|
|
# Convert /lib/ld-* symlinks to relative paths so that they are valid
|
|
|
|
# both on the host and on the target.
|
|
|
|
for f in ${multi_root}/ld-musl-*; do
|
|
|
|
[ -L "${f}" ] || continue
|
|
|
|
l=$( readlink ${f} )
|
|
|
|
case "${l}" in
|
|
|
|
${multilib_dir}/*)
|
|
|
|
CT_DoExecLog ALL ln -sf "../${l}" "${f}"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
# Any additional actions for this architecture
|
|
|
|
CT_DoArchMUSLPostInstall
|
2014-08-01 02:01:46 +00:00
|
|
|
|
|
|
|
CT_EndStep
|
|
|
|
}
|