Commit graph

152 commits

Author SHA1 Message Date
Colin Cross
9cc59c1cbd Remove clang indirection, affects command line ordering
Move the last clang-specific list into the common global list.  This
affects the command line flag ordering due to the the -fdebug-prefix-map=
flag that is added by an init() function, which will force every native
rule to recompile.

Bug: 68947919
Test: m checkbuild
Change-Id: Ic2509e61e9555e9483b92a18d7e8d9913b7125cc
2021-07-14 20:55:25 -07:00
Colin Cross
c8bed31f56 Remove more clang indirection without affecting command lines
Squash the contents of some clang-specific ninja variables into
the main ninja variables.

Bug: 68947919
Test: no change to command lines used to build mmma bionic
Change-Id: I29bf144b03307a7893376e68d82f12f5c40e8e95
2021-07-14 20:55:02 -07:00
Colin Cross
33bac24bb9 Remove clang indirection without affecting build.ninja
Remove cflags that are not handled by clang from the global defaults,
and remove calls to ClangFilterUnknownCflags.

Squash lists of clang-specific default flags into the main default
flags lists.

Rename Toolchain.Clang*flags to Toolchain.*flags.

Rename Go variables with Clang in the name that have no non-Clang
equivalent.

Remove unused ninja variables.

Bug: 68947919
Test: no change to build.ninja for aosp_cf_x86_64_phone-userdebug or aosp_crosshatch-userdebug
Change-Id: Id287945315d53e5eaef197adbbb4f1302f2e3680
2021-07-14 20:54:22 -07:00
Jingwen Chen
51a1e1cf59 bp2build: generate arm toolchain flags into @soong_injection.
Other architectures will come later.

Bug: 187084665
Test: TH
Change-Id: Ifcc6773625e56b1fc20260d840380e7ee4ecee7f
2021-05-20 22:29:39 +00:00
Jingwen Chen
bf61afb7f7 bp2build: export some cc toolchain flags into Starlark.
This CL exports common/global/device/host clang/ld/ldd flags
from their Ninja variable initialization locations in
cc/config/global.go and cc/config/clang.go to make Bazel's cc_toolchain
and Soong's cc actions more consistent with each other.

This does not handle env-dependent or arch-specific toolchain flags
yet (logic in compiler.go and linker.go).

Test: TH
Bug: 187086342
Bug: 187084737
Bug: 186628704
Bug: 187857770
Change-Id: Ie403d7cd23f35160897b9dd902c799cbf1bd7f0c
2021-05-13 06:25:47 +00:00
Elliott Hughes
5a8c9531e4 __ANDROID_UNGUARDED_AVAILABILITY__ is gone now.
So no need to keep `-D`ing it.

Bug: http://b/179067538
Test: treehugger
Change-Id: If5bcead40d3bb355c241e363a8f1a956cb144438
2021-02-19 10:43:19 -08:00
Elliott Hughes
5add0c61d6 Rename __ANDROID_UNGUARDED_AVAILABILITY__ -> __ANDROID_UNAVAILABLE_SYMBOLS_ARE_WEAK__.
Bug: http://b/179067538
Test: treehugger
Change-Id: I5945ca6e767212280a1981e6f78ec3c50acfb3f3
2021-02-11 14:21:59 -08:00
Chih-Hung Hsieh
72e88767dc Disable gnu-folding-constant warning.
New clang compiler issue too many such warnings.

Bug: 179065588
Bug: 179309338
Bug: 179278370
Test: make, presubmit
Change-Id: I9948a4b34ec75a01aa24c2fd753722b072ae5202
2021-02-04 11:46:40 -08:00
Jiyong Park
423e37873b API availability should be checked using __builtin_available
This change turns -Wunguarded-availability option which enforces calls
to APIs which are introduced after the min_sdk_version of the
compliation unit to be guarded with __builtin_available check. For
example, let's assume that we have foo() which was introduced with API
level 30.

void foo() __INTRODUCED_IN(30);

Then if foo() is called for a module whose min_sdk_version is less than
30, say 26, it should be called as below:

if (__builtin_available(android 30, *)) {
  foo();
} else {
  // fallback impl
}

For modules whose min_sdk_version is >=30, the guard is not required.

Bug: 150860940
Bug: 134795810
Test: m

Change-Id: I084148b9a051350626a37cb394daa4398b7332d5
2021-01-15 09:43:35 +09:00
Yabin Cui
db7dda89f3 Switch to clang-r407598 (12.0.1).
Also suppress a clang-tidy warning and a ubsan check to pass compilation.

Bug: 171348143
Test: build.
Change-Id: Ie5162c15df172cefd7cff9776e54531fd620bc23
2021-01-05 19:43:45 -08:00
Yo Chiang
8aa4e3f99e Refactor cc/sabi.go
* Rename `vndk_deps` mutator to `sabi_deps` to better reflect its
  purpose.
* Eliminate duplication of ABI dump generation logic. sabiDepsMutator
  should call libraryDecorator.shouldCreateSourceAbiDump() to determine
  if a module needs to be marked with CreateSAbiDumps.
* Non-VNDK libraries that are opt-in to ABI check would have their
  dependencies correctly marked with CreateSAbiDumps.
* Refactor some lines to idiomatic syntax.
* Add comment strings.

Bug: 145608479
Bug: 173492236
Test: TH presubmit
Change-Id: I99e97787bdf2a4f0c970809161b64aa668ff3d1a
2020-12-14 03:04:58 +00:00
Stephen Hines
2210e720c9 Switch to clang-r399163.
Bug: http://b/155835175
Bug: http://b/151457797
Bug: http://b/165945989
Test: m with aosp_blueline
Change-Id: Id2c2932ccbc34fcbb19cd0b4da0d66ea92cc099a
2020-09-15 13:48:05 -07:00
Dan Albert
d12afec49c Allow globally disabling some clang-tidy checks.
Test: used for the upcoming compiler update
Bug: None
Change-Id: Id17db2c48fa3e165da81a1d084827bde142406dd
2020-08-18 13:28:03 -07:00
Yabin Cui
8ec05ff5f6 Switch to clang-r383902 (11.0.1).
Also suppress some warnings/flags globally to pass compilation.

Bug: 149839606
Test: build aosp_arm64-userdebug.
Change-Id: I0ed740e51b6b39c58842a58eabcf3cdf404e73fa
2020-04-27 01:17:12 -07:00
Stephen Hines
c1de1977a0 Clean up unused flags for LLD.
Since Android only uses LLD, we shouldn't be default adding flags that
just get stripped by a later pass such as:

-Wl,-m,aarch64_elf64_le_vec
-fuse-ld=gold

Remaining query for `-fuse-ld=gold`:
https://source.corp.google.com/search?q=%5C-fuse-ld%3Dgold%20file:.*%5C.(bp%7Cmk%7Cgo)&sq=package:%5Eandroid$
Remaining query for `elf64_le_vec`:
https://source.corp.google.com/search?q=elf64_le_vec%20file:.*%5C.(bp%7Cmk%7Cgo)&sq=package:%5Eandroid$

Bug: http://b/148819762
Test: Built aosp_blueline
Change-Id: I4e064a1e3e0c54721f3f08af8d717f28f6d348f8
2020-04-03 20:18:17 -07:00
Elliott Hughes
da3a071eaa Remove unused mips workarounds.
This was never really finished, and hasn't been supported for years.

Test: treehugger
Change-Id: I21d4c3112aa8cf0c56e59f0cc19ff8725ef714b9
2020-03-06 18:15:44 -08:00
Chih-Hung Hsieh
5f78d55a0a Enable bitwise-conditional-parentheses warning
Bug: 148286937
Test: make
Change-Id: Ib793e35e1f3098e2cce760bcbf0f115ae5764c7f
Merged-In: Ib793e35e1f3098e2cce760bcbf0f115ae5764c7f
2020-02-20 00:58:41 -08:00
Chih-Hung Hsieh
15631dce8a Enable tautological-bitwise-compare warning
Bug: 148831363
Test: make
Change-Id: I31285fec578a87e0d35c177cd599dcd6a66cf934
Merged-In: I9d1ba8ef50630e40d59e402c37ad1366a8e25ea6
2020-02-18 15:14:03 -08:00
Chih-Hung Hsieh
0e5bb2786f Enable bool-operation warning
Bug: 148287141
Test: make
Change-Id: Icec118284025d0631ad3db64e19c5efe3c21ce13
2020-02-14 10:34:44 -08:00
Chih-Hung Hsieh
9d9555e348 Switch from clang-r370808b to clang-r377782
Allow new clang compiler warnings until they are
fixed or suppressed in all branches.

Bug: 145916209
Test: make checkbuild
Change-Id: Ic873b8d705dacd0d92f9031b3960e01283090363
2020-02-12 21:50:07 +00:00
Nick Desaulniers
eb20744361 Revert "Revert "soong: upgrade Android platform to clang-r370808""
This reverts commit 862eb4648a.

Re-upgrades the compiler to clang-r370808, after first dealing with
regressions in ndk_translate and execute only pages.

Bug: 139945549
Bug: 145807809
Bug: 145827049
Bug: 145825270
Test: atest \
  CtsSelinuxTargetSdk27TestCases:android.security.SELinuxTargetSdkTest#testNoExecuteOnly
Test: m ndk_translation_host_unit_tests && \
  ./out/host/linux-x86/nativetest/ndk_translation_host_unit_tests/ndk_translation_host_unit_tests
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Change-Id: I714b582faffa8c92384818a7b12338d621968548
2019-12-13 13:13:06 -08:00
Nick Desaulniers
862eb4648a Revert "soong: upgrade Android platform to clang-r370808"
This reverts commit 4f49e35902.

Causes test failures in ndk_translate.
Bug: 145807809
Bug: 145827049
Test: N/A
Change-Id: I8f42a15fec44475b74b1926c70bc98e03fe66f52
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
2019-12-09 19:16:08 +00:00
Nick Desaulniers
4f49e35902 soong: upgrade Android platform to clang-r370808
-Wc99-designators warns for the use of nested and array initializers in
C++20 code. Many internal projects have pushed back against this
warning.

Disables:
- -Wimplicit-int-float-conversion
- -Wpointer-compare
- -Wxor-used-as-pow
- -Wfinal-dtor-non-final-class
- -Wreorder-init-list

For projects under external/, vendor/, etc, but only if they use
Android.bp (not Android.mk) and -Wreorder-init-list may be re-enabled by
-Wall if set locally.

-Wno-incomplete-setjmp-declaration is needed for NDK stubs that get
generated (functions without full definitions of their parameters).

Sets
- -Wno-error=implicit-int-float-conversion
- -Wno-error=reorder-init-list
for all projects in order to unblock landing the compiler upgrade due to
internal projects not being able to disable or fix these before the
upgrade.

Bug: 139945549
Test: build (aosp_crosshatch, crosshatch, aosp_x86_64-eng,
  walleye), boot internal devices, bionic + RS atests, kernel builds.
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>

Change-Id: I18e3c0eb657fd59824526f36c6dd57bdcf0526ba
2019-11-26 10:09:15 -08:00
Yi Kong
950e0baf2a Expand ClangExtraExternalCflags to non-Google vendor projects
Some of the warnings are too common to fix/opt-out for non-Google
projects.

Also in the change, minor clean up of duplicated code.

Test: presubmit
Bug: 139945549
Change-Id: Ic176ef1f17133405851a79592b6bef5ccb403bd9
2019-11-11 13:24:39 -08:00
Nick Desaulniers
2d5ce8538b Merge "soong: move -Wimplicit-fallthrough from cflags to cxxflags" 2019-11-11 16:54:25 +00:00
Colin Cross
23d988d54a Remove -Wno-thread-safety-negative
-Wthread-safety-negative was disabled because it requires locks to
support an operator!(), and std::mutex in libc++ does not.  Disabling
it everywhere was preventing it being used for modules that want to
opt in to using it and provide their own lock that supports
operator!().  Modules that use -Weverything should either stop using
 -Weverything (preferred), or add -Wno-thread-safety-negative.

Bug: 143713277
Test: m native
Change-Id: I0b84679a806a21b16cabe7f739fde61c3efe2cbe
2019-11-08 18:27:40 +00:00
Nick Desaulniers
4e31fb87af soong: move -Wimplicit-fallthrough from cflags to cxxflags
The compiler upgrade to r370808 can now check C code for implicit
fallthrough. This is triggering a massive number of warnings throughout
external/ and the rest of the platform.

Revisit enabling this for C another day.

Bug: 139945549
Test: m
Change-Id: I8dfaedab78c6230b46e8a45a9e65106dec363380
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
2019-11-08 09:52:56 -08:00
Yi Kong
d0ce0fbfde Remove -Wno-c++98-compat-extra-semi warning flag
hidl/aidl actually does concern about this warning. After fixing their
codebase, this flag is no longer needed.

Test: presubmit
Change-Id: Id88abea88137be0f873c21db76644fe78b9045c8
2019-10-01 22:42:59 +00:00
Yi Kong
011aaa46c5 Remove -Wno-format-pedantic cflag
This is no longer needed.

Test: presubmit
Bug: 20148343
Change-Id: Ie377b3cd183ae89bc159c3b31c64960bce3bc753
2019-09-20 17:24:21 -07:00
Yi Kong
751569192c Remove '-Wno-return-std-move-in-c++11' flag
This flag is no longer needed.

Test: presubmit
Change-Id: I9718ea1d448a6f598e6da61c3b30a0c9470d9c08
2019-09-09 18:48:15 +00:00
Yi Kong
38e5eacedc Merge "Re-enable tautological-unsigned-enum-zero-compare"
am: 47236f13fc

Change-Id: I4def4ff498f48dfff56709b1f8dd28fbe4fad408
2019-09-03 14:50:24 -07:00
Yi Kong
8ca12bd837 Re-enable tautological-unsigned-enum-zero-compare
Clang is smarter at producing this new warning now, producing far
fewer false positives. Re-enable the diagnostic for Android.

Test: build
Bug: 72331526
Change-Id: Ide827791c51587bceb977ae4116894a8cd620eb1
2019-09-01 14:11:01 -07:00
Yi Kong
09c3304fe4 Merge "Re-enable tautological-unsigned-zero-compare"
am: 73e2125894

Change-Id: I12b004231a9f19a85f8afb9d0ac1d78bf6a50cac
2019-08-29 19:05:03 -07:00
Yi Kong
30a3c7faca Re-enable tautological-unsigned-zero-compare
Clang is smarter at producing this new warning now, producing far
fewer false positives. Re-enable the diagnostic for Android.

Test: build
Bug: 72331526
Change-Id: I2020b887fbeb3cd833462e50df835a6cd104920d
2019-08-28 09:48:30 +00:00
Yi Kong
8973bd7683 Merge "Enable the experimental LLVM new pass manager" am: 2adb7eec9a
am: c0377c2a12

Change-Id: Ia4af6b0c9be34bea2aff6d7c536a38420ebb567d
2019-05-24 11:17:33 -07:00
Yi Kong
2adb7eec9a Merge "Enable the experimental LLVM new pass manager" 2019-05-24 17:33:26 +00:00
Yi Kong
2fc3248b6b Enable the experimental LLVM new pass manager
For walleye, the overall binary size is decreased by ~1.1%.

For Googlers, http://go/android-llvm-newpm

Test: build
Bug: 131855431
Change-Id: I6726cd3de0d528b773fb23eae1a7c5c360e29807
2019-05-23 07:17:27 +00:00
Yi Kong
ee2a987501 Merge "Move -Wno-inconsistent-missing-override to ClangExtraCflags" am: 2e03bb7296 am: 16bb6c063d
am: b82e51d36e

Change-Id: I5d528f6121701394ff26a7cd040a6ea40bc94106
2019-03-28 16:05:29 -07:00
Yi Kong
b82e51d36e Merge "Move -Wno-inconsistent-missing-override to ClangExtraCflags" am: 2e03bb7296
am: 16bb6c063d

Change-Id: I857212fc41601d918f57809eb2855316c8a8d640
2019-03-28 15:53:18 -07:00
Yi Kong
16bb6c063d Merge "Move -Wno-inconsistent-missing-override to ClangExtraCflags"
am: 2e03bb7296

Change-Id: I293a0167fcbdb240b31a9a53d9cc29c8acc20cf5
2019-03-28 15:49:14 -07:00
Yi Kong
4d048d5972 Move -Wno-inconsistent-missing-override to ClangExtraCflags
So that projects can override the flag through cflag (CPPFlags are
appended after CFlags).

Test: m checkbuild
Change-Id: Ib72f4ed4731f41982a0eb8a90c782c09810aa8c9
2019-03-27 18:26:22 -07:00
Yi Kong
7b504bf500 Merge "Turn on string-plus-int warning" am: 5a3f31b284 am: abc025924a
am: ca71f33520

Change-Id: Ifd8a14ac5e971e20a85eda86e1aec1ee16c357ae
2019-03-20 15:01:04 -07:00
Yi Kong
ca71f33520 Merge "Turn on string-plus-int warning" am: 5a3f31b284
am: abc025924a

Change-Id: If6f3356809774ab51db1315556fb0f3f07e8c79d
2019-03-20 14:56:00 -07:00
Yi Kong
abc025924a Merge "Turn on string-plus-int warning"
am: 5a3f31b284

Change-Id: I6e0e6a5a5d57a257edd3a62e89bf173b935abb4b
2019-03-20 14:47:14 -07:00
Yi Kong
7e8b47b313 Add -faddrsig to ClangExtraCflags
Emit address-significance table which allows linker to perform safe ICF.
Clang does not emit the table by default on Android since NDK still uses
GNU binutils.

With the flag, binary size is decreased. For Marlin:
               -fno-addrsig  -faddrsig  diff
/system/bin    28012K        27108K     -3.33%
/system/lib    88220K        86964K     -1.44%
/system/lib64  151936K       148108K    -2.58%

Test: m checkbuild
Bug: 128940110
Change-Id: I99511f038a6d4b88b5c849a0f8943c24731ab6ea
Merged-In: I99511f038a6d4b88b5c849a0f8943c24731ab6ea
(cherry picked from commit a32b5e6a6b)
2019-03-20 10:40:44 -07:00
Yi Kong
1b0ba94e5d Add -faddrsig to ClangExtraCflags
Emit address-significance table which allows linker to perform safe ICF.
Clang does not emit the table by default on Android since NDK still uses
GNU binutils.

With the flag, binary size is decreased. For Marlin:
               -fno-addrsig  -faddrsig  diff
/system/bin    28012K        27108K     -3.33%
/system/lib    88220K        86964K     -1.44%
/system/lib64  151936K       148108K    -2.58%

Test: m checkbuild
Bug: 128940110
Change-Id: I99511f038a6d4b88b5c849a0f8943c24731ab6ea
(cherry picked from commit a32b5e6a6b)
2019-03-20 10:35:40 -07:00
Yi Kong
2a51b3fe00 Turn on string-plus-int warning
All instances for the warning are fixed/suppressed, turn the warning
back on.

Test: m checkbuild
Bug: 128878287
Change-Id: Ifd5f9a64cb7ff1ce47f498ed38436056b493ee92
2019-03-20 00:58:46 -07:00
Yi Kong
a32b5e6a6b Add -faddrsig to ClangExtraCflags
Emit address-significance table which allows linker to perform safe ICF.
Clang does not emit the table by default on Android since NDK still uses
GNU binutils.

With the flag, binary size is decreased. For Marlin:
               -fno-addrsig  -faddrsig  diff
/system/bin    28012K        27108K     -3.33%
/system/lib    88220K        86964K     -1.44%
/system/lib64  151936K       148108K    -2.58%

Test: m checkbuild
Bug: 128940110
Change-Id: I99511f038a6d4b88b5c849a0f8943c24731ab6ea
2019-03-20 03:21:10 +00:00
Yi Kong
35badd74bf Merge "Switch clang to r353983" am: bdb1ed828d am: cc6ac6647f
am: d182fd4f26

Change-Id: I0daabff1c4ed0045115fb8fd2c7ef6542742518a
2019-03-18 21:37:39 -07:00
Yi Kong
cc6ac6647f Merge "Switch clang to r353983"
am: bdb1ed828d

Change-Id: I1852d1b722211a2bb2ba8425e4e91fe19ad66811
2019-03-18 21:29:33 -07:00