Merge "Create per-API versions of the CRT objects."
diff --git a/build/coverage.sh b/build/coverage.sh
old mode 100644
new mode 100755
index 5f305ce..13fabc5
--- a/build/coverage.sh
+++ b/build/coverage.sh
@@ -3,35 +3,48 @@
# This script generates coverage for bionic.
#
# Prereqs: Coverage-enabled build.
+#
# $ lunch <target>
# $ m NATIVE_COVERAGE_PATHS="bionic" CLANG_COVERAGE=true
# $ m NATIVE_COVERAGE_PATHS="bionic" CLANG_COVERAGE=true bionic-unit-tests
-# Flash image and set $ANDROID_SERIAL
+#
+# Do *NOT* then rebuild at the top level, or you'll clobber the
+# coverage-enabled libc!
+#
+# Flash image and set $ANDROID_SERIAL.
#
# Usage: $ bionic/build/coverage.sh
# Output: HTML report is generated to /tmp/bionic-coverage/html/index.html
#
-eval "$(cd ${ANDROID_BUILD_TOP}; build/soong/soong_ui.bash --dumpvars-mode --vars="TARGET_ARCH")"
+eval "$(cd ${ANDROID_BUILD_TOP}; build/soong/soong_ui.bash --dumpvars-mode --vars="TARGET_ARCH TARGET_ARCH_VARIANT")"
LLVM_PROFDATA=${ANDROID_BUILD_TOP}/prebuilts/clang/host/linux-x86/llvm-binutils-stable/llvm-profdata
LLVM_COV=${ANDROID_BUILD_TOP}/prebuilts/clang/host/linux-x86/llvm-binutils-stable/llvm-cov
-DEVICE_TEST_DIR=/data/local/tmp/bionic-coverage
+DEVICE_TEST_DIR32=/data/local/tmp/bionic-coverage32
+DEVICE_TEST_DIR64=/data/local/tmp/bionic-coverage64
+DEVICE_PROF_DIR=/data/local/tmp/bionic-profraw
HOST_PROFDATA_DIR=/tmp/bionic-coverage
# Run bionic-unit-tests
-adb shell rm -rf ${DEVICE_TEST_DIR}
-adb shell mkdir ${DEVICE_TEST_DIR}
-adb push $OUT/data/nativetest/bionic-loader-test-libs ${DEVICE_TEST_DIR}
-adb push $OUT/data/nativetest/bionic-unit-tests ${DEVICE_TEST_DIR}
-adb shell LLVM_PROFILE_FILE=${DEVICE_TEST_DIR}/profraws/bionic-%p-%m.profraw LD_LIBRARY_PATH=${DEVICE_TEST_DIR}/bionic-loader-test-libs ${DEVICE_TEST_DIR}/bionic-unit-tests/bionic-unit-tests
+adb shell rm -rf ${DEVICE_TEST_DIR32} ${DEVICE_TEST_DIR64} ${DEVICE_PROF_DIR}
+adb shell mkdir ${DEVICE_TEST_DIR32} ${DEVICE_TEST_DIR64} ${DEVICE_PROF_DIR}
+adb push $OUT/data/nativetest/bionic-loader-test-libs ${DEVICE_TEST_DIR32}
+adb push $OUT/data/nativetest/bionic-unit-tests ${DEVICE_TEST_DIR32}
+adb push $OUT/data/nativetest64/bionic-loader-test-libs ${DEVICE_TEST_DIR64}
+adb push $OUT/data/nativetest64/bionic-unit-tests ${DEVICE_TEST_DIR64}
+adb shell LLVM_PROFILE_FILE=${DEVICE_PROF_DIR}/bionic-%p-%m.profraw \
+ LD_LIBRARY_PATH=${DEVICE_TEST_DIR32}/bionic-loader-test-libs \
+ ${DEVICE_TEST_DIR32}/bionic-unit-tests/bionic-unit-tests
+adb shell LLVM_PROFILE_FILE=${DEVICE_PROF_DIR}/bionic-%p-%m.profraw \
+ LD_LIBRARY_PATH=${DEVICE_TEST_DIR64}/bionic-loader-test-libs \
+ ${DEVICE_TEST_DIR64}/bionic-unit-tests/bionic-unit-tests
# Pull coverage files and post-process
rm -rf ${HOST_PROFDATA_DIR}
mkdir ${HOST_PROFDATA_DIR}
-adb pull ${DEVICE_TEST_DIR}/profraws ${HOST_PROFDATA_DIR}/profraws
-
+adb pull ${DEVICE_PROF_DIR} ${HOST_PROFDATA_DIR}/profraws
${LLVM_PROFDATA} merge \
--output=${HOST_PROFDATA_DIR}/bionic.profdata \
@@ -40,8 +53,13 @@
${LLVM_COV} show \
--instr-profile=${HOST_PROFDATA_DIR}/bionic.profdata \
--format=html \
- out/soong/.intermediates/bionic/libc/libc/android_${TARGET_ARCH}_shared_cov/unstripped/libc.so \
- --object=out/soong/.intermediates/bionic/tests/bionic-unit-tests/android_${TARGET_ARCH}_cov/unstripped/bionic-unit-tests \
+ $OUT/symbols/apex/com.android.runtime/lib64/bionic/libc.so \
+ --object=$OUT/symbols/apex/com.android.runtime/lib64/bionic/libm.so \
+ --object=$OUT/symbols/data/nativetest64/bionic-unit-tests/bionic-unit-tests \
+ --object=$OUT/symbols/apex/com.android.runtime/lib/bionic/libc.so \
+ --object=$OUT/symbols/apex/com.android.runtime/lib/bionic/libm.so \
+ --object=$OUT/symbols/data/nativetest/bionic-unit-tests/bionic-unit-tests \
/proc/self/cwd/bionic/libc \
+ /proc/self/cwd/bionic/libm \
--output-dir=${HOST_PROFDATA_DIR}/html \
--show-region-summary=false
diff --git a/libc/include/android/api-level.h b/libc/include/android/api-level.h
index 50cb61a..bcddddd 100644
--- a/libc/include/android/api-level.h
+++ b/libc/include/android/api-level.h
@@ -29,6 +29,13 @@
#pragma once
/**
+ * @defgroup apilevels API Levels
+ *
+ * Defines functions and constants for working with Android API levels.
+ * @{
+ */
+
+/**
* @file android/api-level.h
* @brief Functions and constants for dealing with multiple API levels.
*
@@ -50,9 +57,40 @@
/* This #ifndef should never be true except when doxygen is generating docs. */
#ifndef __ANDROID_API__
/**
- * `__ANDROID_API__` is the API level being targeted. For the OS,
- * this is `__ANDROID_API_FUTURE__`. For the NDK, this is set by the
- * compiler system based on the API level you claimed to target. See
+ * `__ANDROID_API__` is the [API
+ * level](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)
+ * this code is being built for. The resulting binaries are only guaranteed to
+ * be compatible with devices which have an API level greater than or equal to
+ * `__ANDROID_API__`.
+ *
+ * For NDK and APEX builds, this macro will always be defined. It is set
+ * automatically by Clang using the version suffix that is a part of the target
+ * name. For example, `__ANDROID_API__` will be 24 when Clang is given the
+ * argument `-target aarch64-linux-android24`.
+ *
+ * For non-APEX OS code, this defaults to __ANDROID_API_FUTURE__.
+ *
+ * The value of `__ANDROID_API__` can be compared to the named constants in
+ * `<android/api-level.h>`.
+ *
+ * The interpretation of `__ANDROID_API__` is similar to the AndroidManifest.xml
+ * `minSdkVersion`. In most cases `__ANDROID_API__` will be identical to
+ * `minSdkVersion`, but as it is a build time constant it is possible for
+ * library code to use a different value than the app it will be included in.
+ * When libraries and applications build for different API levels, the
+ * `minSdkVersion` of the application must be at least as high as the highest
+ * API level used by any of its libraries which are loaded unconditionally.
+ *
+ * Note that in some cases the resulting binaries may load successfully on
+ * devices with an older API level. That behavior should not be relied upon,
+ * even if you are careful to avoid using new APIs, as the toolchain may make
+ * use of new features by default. For example, additional FORTIFY features may
+ * implicitly make use of new APIs, SysV hashes may be omitted in favor of GNU
+ * hashes to improve library load times, or relocation packing may be enabled to
+ * reduce binary size.
+ *
+ * See android_get_device_api_level(),
+ * android_get_application_target_sdk_version() and
* https://android.googlesource.com/platform/bionic/+/master/docs/defines.md.
*/
#define __ANDROID_API__ __ANDROID_API_FUTURE__
@@ -114,9 +152,9 @@
#define __ANDROID_API_S__ 31
/**
- * Returns the `targetSdkVersion` of the caller, or `__ANDROID_API_FUTURE__`
- * if there is no known target SDK version (for code not running in the
- * context of an app).
+ * Returns the `targetSdkVersion` of the caller, or `__ANDROID_API_FUTURE__` if
+ * there is no known target SDK version (for code not running in the context of
+ * an app).
*
* The returned values correspond to the named constants in `<android/api-level.h>`,
* and is equivalent to the AndroidManifest.xml `targetSdkVersion`.
@@ -148,3 +186,5 @@
#endif
__END_DECLS
+
+/** @} */
diff --git a/libm/Android.bp b/libm/Android.bp
index 1c4fe55..6a348e1 100644
--- a/libm/Android.bp
+++ b/libm/Android.bp
@@ -1,5 +1,3 @@
-bionic_coverage = false
-
//
// libm.so and libm.a for target.
//
@@ -488,7 +486,6 @@
include_dirs: ["bionic/libc"],
system_shared_libs: ["libc"],
- native_coverage: bionic_coverage,
sanitize: {
address: false,
fuzzer: false,