Commit graph

240 commits

Author SHA1 Message Date
Elliott Hughes
ff49a3c03a libm: sync with upstream FreeBSD.
Bug: http://b/143311272
Test: ran tests
Change-Id: I0fbf94fb5cd13e64a55957d0f951757746d0367a
2019-10-24 18:13:32 -07:00
Elliott Hughes
48da33389b Merge "Remove unused -D from libm build." 2019-10-09 15:09:59 +00:00
Elliott Hughes
2584b88469 Remove unused -D from libm build.
Test: treehugger
Change-Id: I3dd9625790f56b49fabd3fa7b58aab23bffa9dba
2019-10-08 17:53:58 -07:00
Jiyong Park
e87e0dcbae Restrict the availability of the bionic libs
The bionic libs are now restricted to be in the runtime APEX and the
platform (for bootstrapping). It can still be referenced from other
APEXes but can't be included there.

Bug: 139870423
Test: m
Change-Id: I7f99eef27ccf75844ca5c9a7ea866496841b738f
2019-10-07 13:52:32 +09:00
Elliott Hughes
3984a99742 libm: track arm-optimized-routines changes.
Test: builds
Change-Id: I194ba29a2cabbf2fb2ef5c14ac6ad6252b43c76d
2019-09-17 13:08:02 -07:00
Elliott Hughes
ef14a89f72 libm: remove unused x86/x86_64 assembler.
Test: treehugger
Change-Id: Icefa51fe2d204f0ad5700fd67649a1d4b1e6a38f
2019-08-27 09:16:12 -07:00
Elliott Hughes
8947972afd SSE4.1 is part of the Android x86/x86-64 ABI.
We shouldn't be treating this as a special variant.

Test: builds
Change-Id: I80722f941b5aefe34d777db329453cbedf249620
2019-07-15 10:17:16 -07:00
Mitch Phillips
dfde0eeee1 Change SANITIZE_TARGET refs from 'coverage' to 'fuzzer'.
Cleanup of references to 'coverage' in build files. Part of a larger
cleanup to make fuzzing work again in the Android build tree.

Also fixed a test issue with emulated TLS with the new changes, and
removed libc.so fuzzer support until a linked bug is fixed
(b/132640749).

Bug: 121042685
Test: With all patches in the bug merged: mmma bionic
Change-Id: I592352fe9210ff811a2660a88cbbfe48d70a1e57
Merged-In: I592352fe9210ff811a2660a88cbbfe48d70a1e57
2019-05-30 16:49:13 +00:00
dimitry
7f04880820 Enable native_bridge_support
Enable native bridge support for bionic libraries.
Makes it possible to use them in binaries for translated
architectures.

Bug: http://b/77159578
Test: make
Change-Id: Iccd4ad7aecfa5260cc15f09ca975d2e18987278a
2019-05-06 17:13:51 +02:00
Jiyong Park
036e09c36e Don't install *.mountpoint targets
The *.mountpoint targets that installs /bionic/lib/lib*.so and
/bionic/bin/linker* are no longer needed.

Now, /system/lib/lib*.so and /system/bin/linker* are simply symlinks to
the corresponding files in the runtime apex. For example,

/system/lib/libc.so -> /apex/com.android.runtime/lib/bionic/libc.so

This is made possible because we now activate APEXes even before the
data partition is mounted. Before the data partition mounting, the
APEXes from the system partition are ativated. After the data partition
is mounted, updated APEXes in the partition (if any) are activated. As a
result, the symlink always points to the valid path regardless of
whether /data is mounted or not.

Bug: 125549215
Test: device boots
Change-Id: Ie7d83686abe00b3c436f9f9db75d4244200a0fc9
2019-03-14 07:35:52 +09:00
Yi Kong
1ac113dc6b Turn on XOM for libm
Test: bionic-unit-tests
Bug: 122993571
Bug: 123241361
Change-Id: I070d3a2627ee64124ff415a646ddfbcc767b54d1
2019-02-22 14:03:15 -08:00
Yi Kong
e3d90de50b Switch libm to libcrt.builtins
After switching libm from libgcc to libcrt.builtins, some of the symbols
are no longer getting included in libm, causing the compiler to complain
about missing symbols from the version script. Explicitly export them in
libc (since libm depends on libc).

Bug: 122993571
Test: m checkbuild
Test: bionic-unit-tests
Change-Id: Ie91765874d20df605f557b1a8c4236619553c549
2019-02-22 13:33:15 -08:00
Yi Kong
16f947281f Use no_libcrt property instead of hard coding projects to exclude
Test: m checkbuild
Change-Id: If34c72d37dc4077ca3e83135391256bc53d295b5
2019-02-12 09:49:23 -08:00
Elliott Hughes
2d1a2aa13d libm: sync with upstream FreeBSD.
Test: ran tests
Change-Id: I16b5930b0dc652ceac60d8ed1d57c6126c74699c
2019-02-04 13:43:48 -08:00
Jiyong Park
a5f914aef1 Add bionic mount points under /bionic
This change adds following files and symlinks:

Files:
/bionic/lib[64]/lib{c|dl|m}.so
/bionic/bin/linker[64]

Symlinks:
/system/lib[64]/lib{c|dl|m}.so -> /bionic/lib[64]/lib{c|dl|m}.so
/system/bin/linker[64] -> /bionic/bin/linker[64]
/system/bin/linker_asan[64] -> /bionic/bin/linker[64]

The files serve as mount points for either the bootstrap Bionic or the
default Bionic from the runtime APEX. init does the bind-mounting during
booting.

The symlinks are there to not change the ordinary paths to the bionic
files; there are many places that the paths are implied or hard-coded,
e.g., dlopen("/system/lib/libc.so") or DT_INTERP pointing to
/system/bin/linker in the vendor prebuilts.

Bug: 120266448
Test: m blueline, cf_x86, aosp_arm
The aforementioned files and symlinks are found

Change-Id: I97e38c29409ac0610dde285db8df6e94a7930094
2019-01-31 13:44:20 +09:00
Jiyong Park
c45fe9f7bd Add stubs variants for bionic libs
Bionic libs are part of the runtime APEX (com.android.runtime). In order
to be able to update the runtime APEX independetly from the platform, we
have to prevent things outside of the APEX from using bionic symbols
that are not guaranteed to be stable. Otherwise, platform could break
when a symbol is removed from the libs via the APEX update.

To achive this goal, this change adds stubs variant to the bionic libs.
With this, things outside of the runtime APEX (i.e. other APEXes and the
platform) are built with the stubs variants that provide only the
symbols that are guaranteed to be stable.

The set of symbols are basically the same as the symbols available to
NDK clients. However, there are a few additional symbols that are not
available for NDK but should be made available for platform components.
They are marked with "# apex" tag. Symbols with that tag are not exposed
to apps (via NDK stubs) or vendors (via LLNDK stubs).

Note that the stubs is a build-time only artifact. It is used just to
break the build when private symbols are used outside of the runtime
APEX. At runtime, the real library in the APEX is used.

Bug: 120266448
Test: m
Test: m bionic-unit-tests
Change-Id: I7b8d75830c81d7d7d54e2fca21a85b3417531b47
2019-01-04 22:29:36 +09:00
Elliott Hughes
d19b3c5274 Generate the per-arch .map files at build time.
We shouldn't be checking in these generated files...

Bug: N/A
Test: ran tests
Change-Id: Ib67c1ba839eacd7acebd713e1dcd4dd2c25d67f0
2018-12-17 12:26:42 -08:00
Chih-Hung Hsieh
37a2e61133 Suppress cert-dcl16-c clang-tidy warnings
Bug: 120614316
Test: make with WITH_TIDY=1 DEFAULT_GLOBAL_TIDY_CHECKS=-*,cert-dcl16-c
Change-Id: Iab21f41806d81268ebc13bb9605920b4b8e825c9
2018-12-13 11:49:34 -08:00
Ivan Lozano
f17fd1d68a Disable XOM in linker, libc, and libm.
These modules have issues running with execute-only memory. Disable it
in them until we can resolve the issues.

Bug: 77958880
Test: No more XOM-related crashes in these binaries

Change-Id: Ie6c957731155566c2bbe7dbb7a91b9583d9aff93
2018-11-27 07:56:17 -08:00
Elliott Hughes
7208139406 Merge "Use builtins for ceil/floor/rint/trunc on arm64" 2018-09-27 20:24:28 +00:00
Elliott Hughes
b75cc027ff Revert "arm64: Use builtin for nearbyintf/nearbyint"
This reverts commit 35d8ba303b.

Reason for revert: caused test failures...

[  FAILED  ] math_h_force_long_double.nearbyint (15 ms)
bionic/tests/math_test.cpp:(1080) Failure in test math_h_force_long_double.nearbyint
Value of: (fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0
  Actual: false
Expected: true
math_h_force_long_double.nearbyint exited with exitcode 1.

Change-Id: If8e3a3dfbd0e7ee071e5187f96749b6acbb5fc05
2018-09-05 22:29:28 +00:00
Adhemerval Zanella
35d8ba303b arm64: Use builtin for nearbyintf/nearbyint
This allows compiler optimize both calls to a single frinti.

Test: Builds, ran unit tests on arm64.

Change-Id: Ie59ac11a419281836a8051ecda26a5c7b72f3dea
2018-09-04 16:27:16 -03:00
Elliott Hughes
222ce95c8a Remove ARM/MIPS fenv duplication.
Bug: http://b/32709207
Test: ran tests
Change-Id: I58d354e9f8b1e6023427ba271bf39e4e24b7f8ab
2018-08-30 09:26:43 -07:00
Adhemerval Zanella
ab42e6fcbf Use --Bsymbolic-functions on libm
This option removes mostly of the PLT calls for internal symbol, they
are routed to internal entrypoint instead.  It should be safe for libm,
since symbol interposing is not supported.

For arm64 the remaining PLTs are __cxa_finalize, ldexp, __stack_chk_fail,
isnanf, memset, and isxdigit.  All of them are expected (clang (r339432)
does not have optimization for isnan/isinf inline expansion and these
symbols are defined on libc.so).

Test: Builds, ran unit tests on arm and x86.

Change-Id: I1eb1a9f2b30f21788d9ad8639b4a0a15f6d0566a
2018-08-21 14:51:59 -03:00
Adhemerval Zanella
bd58729085 Use -fno-math-errno for libm
This option allows inline calls of single intructions if target,
supports it.  Currently it optimizes internal sqrt calls on
armeabi-v7a, arm64-v8a, and x86_64 (by removing internal calls
to sqrt).

Test: Builds, ran unit tests on arm and x86.

Change-Id: I8a7621a55aae82ff5b80e886c9ed49d480ef6263
2018-08-21 14:51:59 -03:00
Adhemerval Zanella
f6b101d3ec Use double-precision routines from arm-optimized-routines
This patch ues exp, exp2, log, log2, and pow from arm optimized
routines.  For pow on x86_64, although slight slower it simplifies
the code required on both bionic and arm-optimized-routines (so
there is no need to select and export the symbol based on
architecture).

Performance-wise the improvements are:

  x86_64    throughput    latency
  exp            1.16x      1.16x
  log            1.08x      0.95x
  exp2           1.27x      1.55x
  log2           1.40x      1.43x
  pow            0.77x      0.89x *

  * I tried to check if AVX2/FMA but without success.

  aarch64   throughput     latency
  exp            2.33x      2.16x
  exp2           1.99x      1.50x
  log            1.79x      1.43x
  log2           2.15x      1.80x
  pow            3.81x      3.07x

Test: ran bionic tests on static mode.
Change-Id: Ib16bf3280c5329fd257a3b3f0b6c4f2f3cb34deb
2018-08-09 11:22:24 -03:00
Elliott Hughes
bc46fb86d0 Start using libarm-optimized-routines in libm.
Bug: N/A
Test: ran tests
Change-Id: I4a7a6e1c0d8b23741b4e9a15b181a430af47d8f5
2018-08-01 13:27:00 -07:00
Elliott Hughes
ab52807685 Update to FreeBSD libm r336665.
This reverts commit 253a830631 and moves
us forward to a revision that contains fixes for the problem with the
previous attempt.

This also makes sincos(3)/sincosf(3)/sincosl(3) available to `_BSD_SOURCE`
as well as `_GNU_SOURCE`.

The new FreeBSD libm code requires the FreeBSD `__CONCAT` macro, and all
our existing callers are FreeBSD too, so update that.

There's also an assumption that <complex.h> drags in <math.h> which isn't
true for us, so work around that with `-include` in the makefile. This
then causes clang to recognize a bug -- returning from a void function --
in our fake (LP32) sincosl(3), so fix that too.

Bug: http://b/111710419
Change-Id: I84703ad844f8afde6ec6b11604ab3c096ccb62c3
Test: ran tests
2018-07-24 10:36:00 -07:00
Andreas Gampe
253a830631 Revert "Update to FreeBSD libm r336523."
This reverts commit f86ee10278.

Incorrect result for fmodf(3.0f, 0f) = 1.0f breaks ART tests.

Bug: 111710419
Test: art/test/testrunner/testrunner.py -b -t 436-rem-float --target
Change-Id: I7eae68fb92740db33415d16418447bcbbd98ecba
2018-07-21 12:23:03 -07:00
Elliott Hughes
f86ee10278 Update to FreeBSD libm r336523.
This includes an ld128 powl, plus the clog* and cpow* families.

Also teach the NOTICE generator to strip SPDX-License-Identifier lines.

Bug: N/A
Test: ran tests
Change-Id: Ic8289d1253666a19468a4088884cf7540f1ec66d
2018-07-19 16:17:06 -07:00
Chih-Hung Hsieh
ecbff8382d Work around b/24465209, do not pack relocation table.
Global flag --pack-dyn-relocs=android is used with clang lld.
For b/24465209, we need to override that with --pack-dyn-relocs=none.

Bug: 80093890
Bug: 24465209
Test: build with USE_CLANG_LLD=true and run dlext.compat_elf_hash_and_relocation_tables
Change-Id: Ic3837446ff0deccf4e66425b39d3b062abcacc5e
2018-05-23 18:45:53 -07:00
Chih-Hung Hsieh
0fc5df0fde Work around b/24465209, do not use clang lld
See longer explanation in b/80093890.
Clang lld does not generate expected DT_REL and DT_RELA tags
with --hash-style=both and --pack-dyn-relocs=android.
I am not sure about the extent of b/24465209, so
I would rather not to use lld for these .so files for now.

Bug: 80093890
Bug: 24465209
Test: build with USE_CLANG_LLD=true and run dlext.compat_elf_hash_and_relocation_tables
Change-Id: I94e9fe8d687daeadb0182ae26596ca11d3f8bd9b
2018-05-23 17:14:22 +00:00
Jiyong Park
5603c6e6b9 Mark as recovery_available: true
Libraries that are direct or indirect dependencies of modules installed
to recovery partition (e.g. toybox) are marked as recovery_available:
true. This allows a recovery variant of the lib is created when it is
depended by other recovery or recovery_available modules.

Bug: 67916654
Bug: 64960723
Bug: 63673171
Bug: 29921292
Test: m -j
Change-Id: I59bf859a10a218af6591025a0fe7d1853e328405
2018-05-14 18:08:01 +09:00
Elliott Hughes
e332f658e0 Switch to FreeBSD's actual sincos.
Before:
  BM_math_sin_fast                48 ns         48 ns   14693053
  BM_math_sincos                  61 ns         61 ns   11470219

After:
  BM_math_sin_fast                48 ns         48 ns   14725120
  BM_math_sincos                  43 ns         43 ns   16329843

Bug: N/A
Test: ran tests, benchmarks
Change-Id: I8693c64135233c0641af5302c38748f47ac76737
2018-05-09 12:25:12 -07:00
Elliott Hughes
0364a4b446 Switch to FreeBSD catrigl.c for complex arc trig functions.
Bug: N/A
Test: ran tests
Change-Id: I9efbc23bc101fcf04a01334748461f5467dcf85e
2018-05-09 12:24:28 -07:00
Elliott Hughes
8da8ca4528 Update libm from upstream.
Bug: N/A
Test: ran tests
Change-Id: Ifa03eb36d412a2776208cd2921936be4724e5547
2018-05-09 12:24:21 -07:00
Elliott Hughes
589592cb7c Remove -Wno-uninitialized from libm Android.bp.
We can turn on -Wall too, if we turn off const-unused-variable and
unused-variable.

Bug: N/A
Test: builds
Change-Id: I8d889ea0acd334fbacbf7e707bcc2d0be633e4d5
2018-03-15 13:52:22 -07:00
Elliott Hughes
cbc80ba9d8 Switch the rest of our internal headers to #pragma once.
We've been using #pragma once for new internal files, but let's be more bold.

Bug: N/A
Test: builds
Change-Id: I7e2ee2730043bd884f9571cdbd8b524043030c07
2018-02-13 14:27:17 -08:00
Dan Albert
40f15ec4b1 Package bionic static libraries in the NDK.
Test: build/soong/scripts/build-ndk-prebuilts.sh
Bug: https://github.com/android-ndk/ndk/issues/272
Change-Id: Ibb21d799fdcf230ed45db0b809e20dd86d2d8e52
2018-01-22 12:40:56 -08:00
Ian Pedowitz
b6310c2aa7 Fixing app compat issue b/72143978
This is a squash revert of a4a4854 and 1b0f2b4

  Revert "Remove a test for backwards compatibility we no longer support."

  This reverts commit a4a485454a.

  # This is the commit message #2:

  Revert "Remove obsolete workaround."

  This reverts commit 1b0f2b49d5.

Bug: 72143978
Bug: 24465209
Test: Tested failing case on sailfish, reverted back all CL's since
Test: 3471433 for b/24465209 and apps open
2018-01-18 16:26:45 -08:00
Elliott Hughes
1b0f2b49d5 Remove obsolete workaround.
Bug: http://b/24465209
Test: manually ran the app.
Change-Id: I1e2a498864c74ff3a9886b97f7dc60ad7f6dfa44
2018-01-10 11:05:19 -08:00
Jake Weinstein
1e108e3432 Use builtins for ceil/floor/rint/trunc on arm64
Change-Id: I5c8be32b4d5a136690a496cddfec7d1fc2b25ee1
2017-12-11 02:50:54 -05:00
Elliott Hughes
9a1bb70ba0 Use builtins for fma/fmax/fmin/round on arm64.
Bug: http://b/27829506
Change-Id: Id243e3ba0041d5efce496f0760815e591a2c00a0
Test: ran tests and inspected arm64 assembler
2017-11-09 15:57:34 -08:00
Elliott Hughes
3b583f6330 Revert "Use builtins for fma/fmax/fmin/round on arm/arm64."
Apparently we still build non-NEON variants of bionic!

This reverts commit e57d772353.

Change-Id: I5436d913b1dc9b7d8f5e6afaea9b45002be7e825
2017-11-09 17:47:49 +00:00
Elliott Hughes
e57d772353 Use builtins for fma/fmax/fmin/round on arm/arm64.
Bug: http://b/27829506
Test: ran tests and inspected arm/arm64/x86/x86-64 assembler
Change-Id: I8af60b44c75dddbb11949f208a8a70ed3cff12c8
2017-11-08 15:13:58 -08:00
Elliott Hughes
b6c7f6e595 Fix arm/arm64 <fenv.h> to match current reality.
ARM stopped supporting enabling of FP exceptions years ago.

Bug: http://b/68832485
Test: ran tests
Change-Id: I8450baa78e04d994c352180975b0a1ecd5a9f662
2017-11-03 16:46:32 -07:00
Elliott Hughes
5c6a7bf0dc Remove some legacy declarations from <math.h>.
These are still needed for backwards compatibility with code built by old
versions of the NDK, but we don't need to pollute the headers with them.

Also lose the hand-written code for these. The compiler-generated code
is either the same or better, and no new code is calling these functions
anyway.

Bug: N/A
Test: ran tests
Change-Id: Ib01ad9805034433e0105aec882608cc8e6526f78
2017-10-19 14:15:31 -07:00
Elliott Hughes
f1c568d1ea Add <glob.h>.
This is the FreeBSD implementation, plus some tests. The FreeBSD
implementation includes the GNU extensions and seems to be what
iOS is using too, which should provide bug compatibility for app
developers.

The code unfortunately uses a lot of stack, and uses FreeBSD locale
implementation that we don't have, but it does seem better maintained
than the other BSDs.

Bug: http://b/29251134
Test: ran tests
Change-Id: Ie477b45e42a6df1319b25712098519d2b33adf67
2017-09-26 18:46:09 -07:00
Elliott Hughes
50cda38f1d Use __RENAME for long double functions.
We can cut a lot of stuff out of the NDK's libandroid_support with this,
and reduce unnecessary relocations for all LP32 code. LP64 code should
be unaffected.

Bug: https://issuetracker.google.com/64450768
Bug: https://github.com/android-ndk/ndk/issues/507
Test: ran tests, plus manual readelf on the _test.o files
Change-Id: I3de6015921195304ea9c829ef31665cd34664066
2017-09-14 16:10:43 -07:00
Isaac Chen
e719ceb35b Enable 32-bit armv8 NEON for libm
Since ARM neon instructions were only used on armv7-a-neon architecture
variant, the default implementation for 32-bit armv8-a cores doesn't
use these advanced SIMD instructions. By using "neon" key in the
Android.bp, both arch variants (armv7-a-neon and armv8-a) are covered.

Bug: 65569003
Test: lunch aosp_arm64; emulator # on oc-mr1-dev; boot to home screen
      Also checked if sqrt.o and floor.o are actually built and linked
      in the resulted libm.a for both armv7-a-neon/cortex-a15 and
      armv8-a/generic (2nd) arch/cpu variant.
Change-Id: I2084dbdb12e252b06bba5adc65adb59e97a99332
2017-09-13 19:31:08 +08:00