crosstool-ng/scripts/build/libc/bionic.sh
Alexey Neyman 93be629f2b 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-11 00:47:51 -08:00

35 lines
1.5 KiB
Bash

# This file adds functions to extract the bionic C library from the Android NDK
# Copyright 2017 Howard Chu
# Licensed under the GPL v2. See COPYING in the root of this package
# Install Unified headers
bionic_headers()
{
CT_DoStep INFO "Installing C library headers"
CT_DoExecLog ALL cp -r "${CT_SRC_DIR}/android-ndk/sysroot/usr" "${CT_SYSROOT_DIR}"
}
bionic_main()
{
local arch="${CT_ARCH}"
if [ "${CT_ARCH_64}" = "y" ]; then
if [ "${CT_ARCH}" = "x86" ]; then
arch="${arch}_"
fi
arch="${arch}64"
fi
CT_DoStep INFO "Installing C library binaries"
CT_DoExecLog ALL cp -r "${CT_SRC_DIR}/android-ndk/platforms/android-${CT_ANDROID_API}/arch-${arch}/usr" "${CT_SYSROOT_DIR}"
# NB: Modifying both CT_TARGET_CFLAGS and CT_ALL_TARGET_CFLAGS: the __ANDROID_API__
# definition needs to be passed into GCC build, or the resulting libstdc++ gets
# miscompiled (attempt to link against it results in unresolved symbols to stdout/...).
# And since __ANDROID_API__ is a user config option, placing it with other user-supplied
# options isn't completely out of character.
# On the other hand, CT_ALL_TARGET_CFLAGS in non-multilib builds is already set and does
# not get recalculated after GCC build, so setting CT_TARGET_CFLAGS is not reflected
# on other libraries/apps, such as gdbserver.
CT_EnvModify CT_TARGET_CFLAGS "${CT_TARGET_CFLAGS} -D__ANDROID_API__=${CT_ANDROID_API}"
CT_EnvModify CT_ALL_TARGET_CFLAGS "${CT_ALL_TARGET_CFLAGS} -D__ANDROID_API__=${CT_ANDROID_API}"
}