Commit graph

1477 commits

Author SHA1 Message Date
Kalesh Singh
fa1ebf5943 soong: ldflags: Add separate-loadable-segments
To suport >4KB page sizes, the loader may extend LOAD segment mappings
to be contiguous in the virtual address space. This is done in order to
reduce the use of unreclaimable kernel slab memory for the otherwise
necessary gap VMAs (when the runtime-page-size < ELF-segment-p_align).

Such mappings may beyond the end of the backing file when extended;
which breaks the common userspace assumption that file memory maps are
entirely backed by the underlying file.

Existing apps (not yet updated for larger page size support) may
encounter breakages if they parse /proc/self/[s]maps and use the
[start, end] addresses to operate on system libraries that have
crt_pad_segment optimization (VMA extension) [1].

In order to avoid breaking exisiting apps, update the build system to
ensure the platform ELFs' segments are entirely backed by the file
even when the VMA is extended to be contiguous with the subsequent
segment's. This is achieved using the linker flag
-z separate-loadable-segments, which inserts enough padding (zeros)
to also align each segment's offset on file by it's p_align
(max-page-size).

Although laying out the ELF segments on disk to respect the p_align
causes an increase in the file's apparent size (i_size), on Android the
actual disk usage increase is not significant due to most of the padding
being zero blocks which don't get alloacted in the read-only partitions.

The following results were obtained on an ARM64 device on a recent
git_main build:

 No Separate     Separate     Delta         Delta %   Partition
   Loadable      Loadable
   Segments      Segments

   4208.90MB    4214.6MB       5.70MB       0.14%     All RO Partitions

Note: The overhead of -z separate-loadable-segments is minimized by the
fact that ARM64 android already builds with -z separate-code. [2]

[1] https://cs.android.com/android/platform/superproject/main/+/main:bionic/libc/arch-common/bionic/crt_pad_segment.S
[2] 733198152d:build/soong/cc/config/arm64_device.go;l=53

Bug: 328797737
Test: Manually test previously crashing application
Change-Id: Icb14ad10b5c9282855d54c7945b065b7b4184163
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
2024-03-12 17:04:50 -07:00
AdityaK
2c90a92d77 Update unaligned-vector-mem to -munaligned-access
Latest compiler has merged both unaligned access flags into one.

TODO:  This is needed until we change clang driver to enable -munaligned access by default.for Android b/327307773

Bug: 326790418
Change-Id: Ia8c29dc56104d2cffb8ac41aae6eeacccae68e61
2024-02-28 06:14:57 +00:00
AdityaK
a0ad736b91 Remove wtautological warnings added during toolchain update
Bug: b/301328082

Change-Id: I0bf10e4a9456dff1b3a521ca13cb5170e738f80a
2024-02-16 19:44:26 +00:00
Pirama Arumuga Nainar
7493929ff2 Enable -Wambiguous-reversed-operator
Bug: http://b/323152930
Bug: http://b/324323434

The ambiguity in frameworks/av/media/codec2 is resolved.

Test: build partner branch, and presubmit
Change-Id: Ie1aa0b6c965b1a9076333d7d25fd9f9664467a31
2024-02-09 22:45:58 +00:00
Treehugger Robot
c7c666a354 Merge "Remove macros that the Linux host no longer needs." into main 2024-02-09 19:39:06 +00:00
Elliott Hughes
49e8f25966 Remove macros that the Linux host no longer needs.
We patched our ancient glibc to match current glibc (and bionic/musl).

Test: treehugger
Change-Id: I6377b5dfb94d3a0e2209d4c2f0661ef81d362fc3
2024-02-09 16:43:34 +00:00
AdityaK
12f239fd37 Move Wno-ambiguous-reversed-operator to noOverrideGlobalCflags
Some builds were still failing when it was in noOverrideExternalGlobalCflags

Bug: b/324323434
Change-Id: Ibaaa611f085d94e7defac7f2a6aa70b9eef08552
2024-02-08 16:28:20 -08:00
AdityaK
94688b5a4f s/Wno-error=unused-variable/Wno-unused-variable
http://b/315246135

Change-Id: I2086c644afc9a371732ccbe18d09fa078286ece0
2024-02-08 16:25:01 -08:00
Aditya Kumar
d18128fa12 Merge "Add Wno-ambiguous-reversed-operator to get around the operator== lookup issue in clang" into main 2024-02-08 12:17:05 +00:00
AdityaK
839eda517e Add Wno-ambiguous-reversed-operator to get around the operator== lookup issue in clang
Bug: b/323152930
Change-Id: Iee1bc4dd9db9a0fe38d7cf871c34abb638abc092
2024-02-07 20:30:55 -08:00
Elliott Hughes
5897fd6a5e Merge "Remove __STDC_FORMAT_MACROS." into main 2024-02-07 23:50:37 +00:00
Elliott Hughes
1c80585cd6 Remove __STDC_FORMAT_MACROS.
Our mingw doesn't use this. (It does however still use
__STDC_CONSTANT_MACROS and __STDC_LIMIT_MACROS.)

Test: treehugger
Change-Id: I415017093b9ccffd21fd41f17a2f4387839a0f53
2024-02-07 20:45:25 +00:00
Elliott Hughes
ac43c55656 Remove macros that Darwin never used.
Test: treehugger
Change-Id: I4b31c1f40142c0346ac2d2c9e9b831954c4d9468
2024-02-07 18:30:22 +00:00
Aditya Kumar
b2a56627a2 Merge "Revert^2 "Update clang version to clang-r510928"" into main 2024-02-03 12:54:13 +00:00
Treehugger Robot
fe423e39fb Merge "Reduce warning spam from "unused-" flags in //external, //vendor, //hardware" into main 2024-02-03 03:25:58 +00:00
Aditya Kumar
ef7c121a6b Revert^2 "Update clang version to clang-r510928"
22686bab04

Change-Id: I1117546bb71548e1146c6ae43419b6aef772f812
2024-02-02 14:32:47 -08:00
Kalesh Singh
f4ffe0a026 soong: Add crt_pad_segment to .so's
crt_pad_segment adds a NOTE to the ELF which is used by the binoic
loader to determine whether it should pad segments when mapping them
into the virtual address space, such that there are no gaps between
mappings of consecutive segments. This avoids an increase in
unreclaimable kernel slab memory usage for VMAs on devices where the
runtime-page-size > elf-segment-p_align.

Since -fandroid-pad-segment [1] respects -nostdlib used in android
platform builds, soong must link in crt_pad_segment to platform shared
libraries.

For simplicity, link crt_pad_segment everywhere that crtend_so is
applicable, ignoring nocrt property, as there is no other reason
to track these separately.

Example:

❯ readelf -WS /system/lib64/libc++.so [Output simplified]

...
Section Headers:
  [Nr] Name              Type            Address          Off    Size   ES Flg Lk Inf Al
...
  [ 2] .note.android.pad_segment NOTE            0000000000000288 000288 000018 00   A  0   0  4
...

[1] https://github.com/llvm/llvm-project/pull/77244

Bug: 316403210
Test: readelf -WS <lib>.so
Change-Id: Icc06611376cfd5ee4de7281b4134f9f8ffe7ca60
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
2024-01-31 19:42:31 -08:00
Pirama Arumuga Nainar
22686bab04 Revert "Update clang version to clang-r510928"
Revert submission 2804373-clang_r510928

Bug: http://b/301328082

Reason for revert: Broke aosp-main/aosp_x86-next-userdebug

Reverted changes: /q/submissionid:2804373-clang_r510928

Change-Id: I6802b329e8dbd9dce5a75aab76c43960765a8594
2024-01-31 06:51:49 +00:00
AdityaK
0790ce2e56 Update clang version to clang-r510928
Bug: b/301328082
Test: N/A
Change-Id: Ied250c42c33d9e2d8bd9b9161b9028874540addb
2024-01-30 15:09:29 -08:00
Prashanth Swaminathan
13b063730a Reduce warning spam from "unused-" flags in //external, //vendor, //hardware
Some clang unused-* warnings are not covered by "-Wno-unused". Add them
explicitly to avoid noise from these warnings, given that they don't
generally get fixed.

Test: Local clean builds.
Change-Id: I13f5089fd68f1a67a11be14fa41807688d803ba3
2024-01-30 20:31:25 +00:00
AdityaK
c4b7a18ffc Disable shrink-wrap optimization for arm32 devices
Bug: b/319464283
Bug: b/322359235

Change-Id: Ia720f88a8967d00c7fc3ac7d690d4d37123818f1
2024-01-26 21:55:19 +00:00
Satoshi Niwa
b6d818dbf0 Replace goldmont-without-xsaves build with goldmont-without-sha-xsaves
For chromebooks, we need a new build variant whose target arch is
goldmont, but without SHA and XSAVES support (b/314243939#comment21)

Bug: 314243939
Test: Build an image with TARGET_ARCH_VARIANT:=goldmont-without-sha-xsaves
Change-Id: If73660b515b443d5c138ca367fa3d1c6f18485b5
2024-01-24 16:27:56 +09:00
Treehugger Robot
1e33a311c6 Merge "Really disable auto-vectorization." into main 2024-01-23 17:46:58 +00:00
Elliott Hughes
2ced4b5c66 Greatly reduce build warning spam.
No-one ever fixes unused-* or deprecated-* warnings in external/ (nor should they!).

-Wno-deprecated-enum-enum-conversion should probably have been added
next to -Wno-deprecated-anon-enum-enum-conversion when it was added,
since it's a major spam contributor, and equally unlikely that anyone
will clean them up.

-Wno-deprecated-dynamic-exception-spec is a weird special case because
it should be irrelevant after our next libc++ update, but in the
meantime -- because libc++ is used everywhere -- this is a massive spam
contributor that no-one on Android cares about because we don't use
exceptions (and the people seeing this can't fix libc++ anyway).

Test: local clean builds
Change-Id: I098202337e9e5026c4c5215dbf5a2abf1fbbdca8
2024-01-22 18:34:10 -08:00
Elliott Hughes
6c93f6953f Really disable auto-vectorization.
The previous patch was insufficient. Craig Topper explains:

  -fno-vectorize only disables the loop vectorizer

  -fno-slp-vectorize only disables the SLP vectorizer

  The backend can also use vector instructions for memcpy/memset or
  combining multiple scalar loads and/or stores. That is independent
  of -fno-vectorize.

  -mllvm -vector-bits-min=0 will disable any use of fixed vectors. And
  will make attribute(vector_size) get scalarized.

  -mno-implicit-float will disable both vectorizers and
  prevent the backend for using vectors for memcpy/memset
  oor multiple scalar loads/stores. It will not affect
  attribute(vector_size). -mno-implicit-float also prevents scalar
  floating point instructions from being used for anything that didn’t
  use float/double/_Float16/etc. type in source, but I don’t think that
  happens on RISC-V today. 32-bit X86 can use a 64-bit x87 FP load as an
  atomic load for uint64_t, for example. Basically -mno-implicit-float
  is supposed to prevent the compiler from using FP or vectors when the
  source doesn’t explicitly use FP or vectors.

So -mno-implicit-float was what we were actually looking for here. I've
done a clean build with this change, and see only the expected
(hand-written assembler) vector code in bionic, and the ART
ClassLinker::LoadClass() issue is gone too. As far as I can tell, the
remaining vector code is all deliberate in that sense.

We may still end up back here again, to change "gcv" to "gc", but that
still requires some code changes just to build, and still makes it less
obvious that this is just a temporary workaround for a qemu bug
(specifically https://gitlab.com/qemu-project/qemu/-/issues/1976).

Bug: http://b/320416684
Test: objdump
Change-Id: Ibd104e4289d6d1aaf441efa0440fedc90e3da29a
2024-01-22 15:00:21 -08:00
Pirama Arumuga Nainar
5376892762 [riscv64] disable vectorizer during LTO
With LTO, vectorization needs to be disabled separately in the linker flags as well.

Change-Id: I71d813974a9b7a40954d3dab5b1704baed610fd0
2024-01-19 23:02:01 +00:00
AdityaK
431c0b9c8e Pass jump-is-expensive flag both to compiler and linker
Change-Id: I89e30f98188aed4c5076a34f150e80386fc63f48
2024-01-19 07:32:59 -08:00
Colin Cross
1b1b9a937b Merge changes from topic "soong-tests-presubmit" into main
* changes:
  Add script to run Soong tests with go tools
  Disable TestVariantSingletonModule when go test -short is used
  Fix data race in propagateRROEnforcementMutator
  Fix data race in finder_test.go
  Fix data race in dex_bootjars
  Fix race CommonGlobalCflags when running tests in parallel.
  Fix data race in snapshot singletons when running parallel tests
2024-01-18 23:58:45 +00:00
Elliott Hughes
c0ea850bfb Disable auto-vectorization.
Until https://gitlab.com/qemu-project/qemu/-/issues/1976 is fixed, this
is just causing too much confusion and wasted time.

Removing V from the architecture string has the same effect, but
requires some code changes (to be able to compile code that's
_explicitly_ using V), and makes it less obvious that this is just a
temporary workaround for a qemu bug.

Bug: http://b/320416684
Test: objdump
Change-Id: Iec7d63ab227b31f82f530dabbdc4f3aa54277f04
2024-01-17 14:24:53 -08:00
Colin Cross
bcf53701b7 Fix race CommonGlobalCflags when running tests in parallel.
Clone the commonGlobalCflags global variable when modifying it so that
it gets a unique object per context.

Test: go test -race ./...
Change-Id: Ia4b91c40939d4b4d338bd11e4d4f523521874548
2024-01-17 11:11:03 -08:00
Satoshi Niwa
c41f21121c Add a new x86(_64) arch variant "goldmont-without-xsaves"
Its target arch is goldmont, but without xsaves support.
This ensures efficient execution on a broad range of Intel/AMD CPUs used
in Chromebooks, including those lacking xsaves support.
(e.g. Kaby Lake, Gemini Lake, Alder Lake and AMD Zen series)

Bug: 314243939
Test: Build an image with TARGET_ARCH_VARIANT:=goldmont-without-xsaves
Change-Id: I9963cc3356394815f068fc998a9708bdb30c8266
2023-12-15 14:25:55 +09:00
Colin Cross
8ff105860d Remove ConvertWithBp2build implementations
Remove the ConvertWithBp2build implementations from all the module
types, along with the related code.

Bug: 315353489
Test: m blueprint_tests
Change-Id: I212672286686a318893bc7348ddd5a5ec51e77a7
2023-12-08 13:51:05 -08:00
Vilas Bhat
b3d2d22a5d 16k: soong: Update DevicePageSizeAgnostic to DeviceNoBionicPageSizeMacro
This is part of a larger change to update the flag
PRODUCT_PAGE_SIZE_AGNOSTIC to PRODUCT_NO_BIONIC_PAGE_SIZE_MACRO.
This is to help clarify that this flag doesn't mean the device
will actually work end-to-end with any page size.

Bug: 312541564
Test:
```
source build/envsetup.sh
lunch aosp_cf_arm64_phone_pgagnostic-trunk-userdebug
m
cat out/soong/build.aosp_cf_arm64_phone_pgagnostic.ninja | grep __BIONIC_NO_PAGE_SIZE_MACRO
```

Change-Id: I33033876d0d4a276d1bb962d40315b71a3968c66
2023-12-05 23:49:50 +00:00
Elliott Hughes
bee01f7d62 riscv64: disable a weird option.
By default clang assumes that on riscv64 jumps are really expensive.
That's probably not true for the kind of SoCs we're dealing with, but
more importantly (see the bug) it causes clang to do loads from the
right hand side of a `&&` before the left hand side has been evaluated.
This found one latent bug in libcore, and it doesn't seem like the best
use of anyone's time to have to chase similar issues if they're going
to be similarly latent for riscv64 when we get clang's default fixed.

Bug: https://github.com/google/android-riscv64/issues/124
Test: treehugger
Change-Id: I640f1b43ea3d2452366ab86e97a9189fa9f5326c
2023-12-01 17:39:20 -08:00
Elliott Hughes
198583ed20 Merge "riscv64: stop explicitly disabling emutls." into main 2023-12-01 20:28:09 +00:00
Tomasz Wasilczyk
a1d45b8ec1 Merge "Bump default experimental from gnu++2a to gnu++2b." into main 2023-12-01 17:21:01 +00:00
Elliott Hughes
74780e61dc riscv64: stop explicitly disabling emutls.
riscv64 has always had ELF TLS (and the emutls bugs have been fixed now
too).

Test: treehugger
Change-Id: I8dd1d28d4f28a442130e4cf536166ea733f16a96
2023-12-01 02:08:05 +00:00
Tomasz Wasilczyk
37d6943f37 Merge "Bump the default from gnu++17 to gnu++20." into main 2023-11-30 15:15:12 +00:00
Pirama Arumuga Nainar
6c771e7d29 Revert "Remove flags rejected by RBE input processor"
This reverts commit a4724a0c4e.

Reason for revert: reclient has an updated deps scanner now.
Bug: http://b/248371171
Test: enable RBE; RBE_CLANG_TIDY_EXEC_STRATEGY=remote; make tidy-soong_subset


(cherry picked from https://android-review.googlesource.com/q/commit:2c36e5efceae94424b513878cf6dc4e9640651ab)
Merged-In: Id876bd7eee1e5606f8dc05903f77f135b47da360
Change-Id: Id876bd7eee1e5606f8dc05903f77f135b47da360
2023-11-21 19:54:27 +00:00
Tomasz Wasilczyk
e14961626c Bump default experimental from gnu++2a to gnu++2b.
Bug: 311052584
Test: treehugger
Test: m checkbuild
Change-Id: I5e9d479dd4c14e21fe7d29ea6894f1149fd15e50
2023-11-15 11:46:26 -08:00
Elliott Hughes
c79d9e3053 Bump the default from gnu++17 to gnu++20.
We should update gnu++2a to gnu++2b too, but not in this CL.

Bug: 311052584
Test: treehugger
Test: m checkbuild
Change-Id: I3637444d74868b3a29b425fd749ecbbe1a45fbf7
2023-11-15 11:46:03 -08:00
Juan Yescas
a74b22e8e6 16k: soong: Add the C flag -D__BIONIC_NO_PAGE_SIZE_MACRO flag to x86-64
To simulate 16k page size in x86-64 cuttefish, it is necessary
to compile the shared libraries and binaries with max-page-size greater
than 4096.

Bug: 309816695
Test: source build/envsetup.sh
      lunch aosp_cf_x86_64_phone_pgagnostic-trunk-userdebug
      m
Change-Id: I32670ef2c25fdcefec11bd07ba41cd0ea96c92bd
2023-11-09 16:58:29 -08:00
Juan Yescas
3db51d2500 16k: soong: Add linker flag -Wl,-z,max-page-size for x86-84 to align binaries and .so
To simulate 16k page size in x86-64 cuttefish, it is necessary
to compile the shared libraries and binaries with max-page-size greater
than 4096.

Bug: 309816695
Test: source build/envsetup.sh
      lunch aosp_cf_x86_64_phone_pgagnostic-trunk-userdebug
      m
      readelf -l out/target/product/vsoc_x86_64_only/system/bin/toybox
Change-Id: I38e4449a7826a2eca0c1a1cccc916af21f0b3a93
2023-11-09 13:29:22 -08:00
Dan Willemsen
f051ec6de2 Merge "Update the minimum macos deployment version to 10.14" into main 2023-11-08 18:46:51 +00:00
Dan Willemsen
876b12ffdd Update the minimum macos deployment version to 10.14
Bug: 191879468
Test: Build aosp-build-tools on Mac
Change-Id: I21c3d0482ba9a23b2b54849eccb18c7958559d93
2023-11-08 02:11:27 +00:00
Yi Kong
0fa503da2e Only enable MLGO for ARM64 ThinLTO targets
The MLGO model we embed in the Android Clang is trained on ARM64
ThinLTO artefacts. Applying the model across architectures does not
necessarily translate to performance improvement. Therefore only enable
the optimisation on ARM64 ThinLTO for now.

Test: presubmit
Bug: 293827654
Change-Id: Ie64a65c11191cf700a463637a0746c8470d3aa3c
2023-11-07 14:12:51 +09:00
Aditya Kumar
e19a173a48 Merge "Discard IllegalFlags when testing a new compiler" into main 2023-10-29 00:50:33 +00:00
AdityaK
e7b606717a Discard IllegalFlags when testing a new compiler
Also add -Wno-everything as suggested by Pirama

Bug: b/308179696

Follow up: https://b.corp.google.com/issues/308179380

Change-Id: Iaa73f2b52363562b2391346d8b2e5dc73bab4f2d
2023-10-27 18:54:58 +00:00
Krzysztof Kosiński
14e25a504c Merge "Revert "Revert "Enable -Werror=incompatible-function-pointer-types""" into main 2023-10-26 21:46:35 +00:00
Krzysztof Kosiński
83199b5e4d Revert "Revert "Enable -Werror=incompatible-function-pointer-types""
This reverts commit 5e75975e04.

Reason for revert: breakages fixed

Change-Id: Id54499eabaca649bee5ea6452a3a4134d8773e2d
2023-10-26 07:16:29 +00:00