We want to build things in CTS (things built against the NDK) with
integer overflow checks. Some projects in the tree also make explicit
calls to the overflow checked builtins, and those projects need to be
built with the NDK (external/dng_sdk is the specific example that
brought this up).
Test: make checkbuild tests
Bug: None
Change-Id: Iab27dd0d931f723140de242049fa72f3b1ce0fb8
BUILD_HOST_static has been broken because I was stripping
-Wl,--start-group/-Wl,--end-group into a separate set of ldflags instead
of keeping them wrapped around some of the ldlibs. So don't pass some of
the build system flags through the ldlibs checker.
Bug: 30898128
Change-Id: I332b42679695cdc5da3cb0036290b6a3544699c0
Native coverage is enabled by setting NATIVE_COVERAGE to true
and specifying a list of paths in the COVERAGE_PATHS
environment variable. Files are exported to a zip file in the
target out directory.
Change-Id: I66a2ddd88e849bec1cc0cdae1b51fe18a007e2c3
Let clang-tidy report warnings in header files in the
system and current directories but not the external
and vendor directories.
Test: build with WITH_TIDY=1
Change-Id: I1723b8eb95948961fb7164a19989e0a926e5bf8a
The output will be in the `m dist` results as soong_to_convert.txt, or
can be built using:
$ m $OUT/soong_to_convert.txt
The output is a list of modules that are probably ready to convert to
Soong:
# Blocked on Module (potential problems)
283 libEGL (srcs_dotarm)
246 libicuuc (dotdot_incs dotdot_srcs)
221 libspeexresampler
215 libcamera_metadata
...
0 zram-perf (dotdot_incs)
The number at the beginning of the line shows how many native modules
depend on that module.
All of their dependencies have been satisfied, and any potential
problems that Make can detect are listed in parenthesis after the
module:
dotdot_srcs: LOCAL_SRC_FILES contains paths outside $(LOCAL_PATH)
dotdot_incs: LOCAL_C_INCLUDES contains paths include '..'
srcs_dotarm: LOCAL_SRC_FILES contains source files like <...>.c.arm
aidl: LOCAL_SRC_FILES contains .aidl sources
dbus: LOCAL_SRC_FILES contains .dbus-xml sources
objc: LOCAL_SRC_FILES contains Objective-C sources
proto: LOCAL_SRC_FILES contains .proto sources
rs: LOCAL_SRC_FILES contains renderscript sources
vts: LOCAL_SRC_FILES contains .vts sources
Not all problems can be discovered, but this is a starting point.
Change-Id: I45674fe93fd267d4d1fb0bc3bc9aa025e20c5ac6
Traditionally this has come from android/api-level.h, but with the
libc headers unified it must be set by the build system since we don't
have per-API level copies of that header now.
Test: make checkbuild with other libc ndk_library patches
Change-Id: Idf6cbba131f065b048b1b412e992c55e3d17e701
Only projects in LOCAL_CLANG_EXCEPTION_PROJECTS can set LOCAL_CLANG to false.
Add external/gentoo/integration to this white list.
Bug: 30575506
Change-Id: Icd508686bc2eb8b9d400200166df80115af20da1
Test: build and find new warning in build.log
Any NDK shared libraries not in LOCAL_SYSTEM_SHARED_LIBRARIES weren't
being pulled from the generated libs before since we were only
filtering my_system_shared_libraries and even if we had filtered
my_shared_libraries they would have been rewritten to my_ldlibs.
* Filter my_shared_libraries for NDK generated libs as well.
* Stop rewriting NDK LOCAL_SHARED_LIBRARIES to my_ldlibs. Instead,
rewrite in the opposite direction just like we do for the platform.
* Move shared libs/ldlibs rewriting to before we filter NDK
libraries out of shared libs/system shared libs.
Test: make checkbuild
Bug: http://b/27533932
Change-Id: If1860d9638de77089a46884f406766edaf362216
* LOCAL_CLANG_EXCEPTION_PROJECTS is the list of project prefixes.
* New warning message is detected by warn.py as high severity.
Bug: 30575506
Change-Id: I87a38b2ba6bab1d2e5e7a9d5ec9557f0e609727c
Test: build and find new warning in build.log
AUX is a new class, similar to TARGET
While TARGET defines toolchain for Application Processors
AUX is defining toolchains for arbitrary utility cores (DSPs, GPUs,
MCUs, etc). This allows building of non-android sources as part
of Android tree and avoid using prebuilts if source code is avaliable
Bug: 29635686
Change-Id: Ie755ea054b16c3e86369f5fb2ba6eb0b384af77f
Signed-off-by: Alexey Polyudov <apolyudov@google.com>
introduce LOCAL_NO_LIBCOMPILER_RT
embedded targets do not necessarily want to have it
Bug: 29635686
Change-Id: Ieb04f7ea7237ae01a067dedfa2fb13571e9a789c
Signed-off-by: Alexey Polyudov <apolyudov@google.com>
When overriding toolchain with LOCAL_CC, LOCAL_CXX
build system shall not assume that this custom toolchain
is CLANG.
Bug: 29635686
Change-Id: I9712d098216740c4ff20bd2a4749f489af85b50e
Signed-off-by: Alexey Polyudov <apolyudov@google.com>
on some toolchains and architectures building non-PIC
code renders more efficient assembly
Bug: 29635686
Change-Id: I6274f40d24e1bb43f03b45c60b5487abed02b7fc
Signed-off-by: Alexey Polyudov <apolyudov@google.com>
The list of libraries is currently empty. Will add migrated libraries
in a follow up patch.
Test: Still builds.
Bug: http://b/27533932
Change-Id: Ibd9750620ca2ae86fe888a8a993bd26493bc1c8a
Split the variables that contain header directories into ones that
should be prefixed with -isystem and ones that should be prefixed with
-I in preparation for moving some headers from -isystem to -I.
Add $(wildcard) around SRC_HEADERS to match the soong behavior, and move
users of SRC_HEADERS from config.mk to binary.mk so that the exported
soong value is present.
Test: no changes to build.ninja compile rules
Change-Id: Iadecbbf4351a01e53cb57e721d31f4f836bb82d9
Refactor includes in transform-*-to-o to simplify future changes to the
default include paths.
Test: whitespace-only changes to the compile rules in build.ninja
Change-Id: I766af1f22a4838d933691b6df37530db3ba4e21d
All instances of this have been removed from the downstream trees. The
APK->JNI_SHARED_LIBRARY and Java->Java checks remain as warnings.
Change-Id: I3eaee284500deee0f26a4f9cdd96497e99ec533e
All instances have disappeared from the build server, so switch this to
error before more turn up.
Change-Id: Iac07526a6e77ebf33733033249f2a108aae3fa7d
Modules built against the NDK should only link against modules also
built against the NDK (or link to the NDK prebuilts). This patch
attempts to catch these cases, and prints a large warning when this is
violated. Once the tree is cleaned up, this will change to an error.
Change-Id: Ib6ffcc38d9161abdbe45a58af26ba429fb6f1876
LOCAL_LDLIBS was the only correct way to use NDK libraries, but few used
it correctly. It also often got confused with LOCAL_LDFLAGS, so move the
flags to the correct variable.
For binaries that weren't using the NDK (empty LOCAL_SDK_VERSION), it
was never valid to use LOCAL_LDLIBS, as dependencies would not be
properly set up, and could lead to random build failures. So convert any
-l linker flags to using LOCAL_SHARED_LIBRARIES automatically.
For binaries built using the NDK (LOCAL_SDK_VERSION set), they were
required to use LOCAL_LDLIBS for prebuilt NDK libraries, otherwise they
would get headers and dependencies to the platform versions. Any
non-prebuilt LOCAL_LDLIBS would miss dependencies. So move the NDK
prebuilt libraries to LDLIBS from SHARED_LIBRARIES, and move everything
else to SHARED_LIBRARIES.
So now, for device modules, LOCAL_SHARED_LIBRARIES should always be
used, and we'll do the right thing. LOCAL_LDLIBS should only be used for
host libraries from the system.
Change-Id: Ide34c7afdcfb6507a378d45a42471729e489a9e0
To make the build hermetic, all include files should be located within
the source tree (or generated as output).
There was an Android.mk that was adding /usr/include to its include
path.
Change-Id: I4c40b908314239c8239c7835d592e409248a3150
Host native tests have been getting installed into
out/host/linux-x86/bin/..., but this pollutes the bin directory with a
lot of poorly named tests. Also, to support 32-bit and 64-bit tests, we
need to have different names with different suffixes. This causes
problems when tests expect to be named something specific (like gtest).
It's also convenient to store test data next to the test itself.
So with this change, native tests will be installed in
out/host/linux-x86/nativetest[64]/$(LOCAL_MODULE)/$(LOCAL_MODULE_STEM)
just like target tests get installed into /data/nativetest[64].
Implement this using a new NATIVE_TESTS class, which is like
EXECUTABLES, but sets up the install path differently, and configures
the rpath to load shared libraries with the proper relative path.
LOCAL_MODULE_RELATIVE_PATH can be used to control the directory name, it
will default to $(LOCAL_MODULE). This way multiple related tests can be
grouped together.
Target native tests also use NATIVE_TESTS now, but nothing should change
other than LOCAL_MODULE_RELATIVE_PATH can be used.
Change-Id: I535e42b1a6b21c5b8d6a580aa2f944d2be35e27d
am: 315621eee0
* commit '315621eee0a1199b175ab4d251ea617fdb018fd5':
Move to a single clang unknown flags list
Change-Id: I209bf8b868da7b11d55fc6cf701976ff914a2160
Soong is using a single list of unknown clang flags for all
architectures, instead of the per-architecture list here. Collapse this
down to a single list as well so that it can be verified against the
Soong list, and eventually replaced by the Soong version.
Change-Id: If43cd892105da5155907c05965a74b835920a369
We never use it for host modules, and all the target configurations use
the same linker argument. This matches Soong.
Change-Id: Ibcba9a4ce340c7a12306d1fee620a04027c0e292
Instead, use the libgcc/libatomic/libgcov from the static libraries dir,
which is provided by Soong. Copy the libraries using the Soong script if
Soong is disabled - this can be removed once USE_SOONG is removed.
Change-Id: Iad2ad20ad5c3cfc48bf1e46e594a482609098d7a
Previously if a library has custom generated headers in
LOCAL_GENERATED_SOURCES and export its include path with
LOCAL_EXPORT_C_INCLUDE_DIRS, there is almost no way for the users of the
library to set up dependency of their object files on the generated
headers.
This change makes the generated sources dependency of the library's
export_includes, which is guaranteed generated before client code gets
compiled.
Also we added proto-generated cpp files to my_generated_sources so that
we can deal solely with $(my_generated_sources). Because many
Android.mks assume the generted .pb.hs are in $(generated_sources_dir)
instead of $(intermediates), we have to generate the source files in
$(generated_sources_dir) and make a copy in $(intermediates).
Bug: 28622149
Change-Id: I73b21443fa706f3735faf16356ed8c08fbfecca6
am: 6014381
* commit '60143818969a97ee6827b9de3b56670b0ff774df':
Add tidy.mk to set up global default checks.
Change-Id: I4f678930148ee6a0a3bccce899275af07cc4a738
* Default checks include only google* minus google-readability*.
* Some google-* checks are disabled for external projects.
* Each project can add more or disable checks through LOCAL_TIDY_CHECKS.
Bug: http://b/27779618
Change-Id: I83eed73bd2bddaace565a6dde532fb2036b4fac4
The NDK doesn't support mips32r6, and the update of prebuilts/ndk to
r11 doesn't have the hack that r10 did. Revert back to r10, until we
decide on a more appropriate solution.
Change-Id: I7891603d8ccbb20398aad893b62c1debf353ef41
* Call clang-tidy before every C/C++ compilation if
(1) clang-tidy is found at $(PATH_TO_CLANG_TIDY)
(2) $(my_clang) is true
(3) LOCAL_TIDY is 1 or true, or
LOCAL_TIDY is undefined and WITH_TIDY is 1 or true.
* clang-tidy is called with -checks=$(my_tidy_checks),
which has default '-*,google*,-google-readability*'
and can be overwritten by WITH_TIDY_CHECKS.
* LOCAL_TIDY_CHECKS is appended to $(my_tidy_checks)
* Extra flags are passed to clang-tidy through
WITH_TIDY_FLAGS or LOCAL_TIDY_FLAGS.
* To quickly find and fix clang-tidy warnings, set $(WITH_TIDY_ONLY)
to 1 or true to skip compilation of C/C++ files.
* Add a PHONY tidy_only target,
which includes all $(cpp_objects) and $(c_objects).
* The 'mm' and 'mmm' functions are changed to call make with
the 'tidy_only' target when WITH_TIDY_ONLY is true or 1.
In that case, only clang-tidy is called for C and C++ files.
Bug: http://b/27779618
Change-Id: I8adcfff217d68af49849b79aacee7d7654cafb1b
Listing a library in any of:
LOCAL_EXPORT_SHARED_LIBRARY_HEADERS
LOCAL_EXPORT_STATIC_LIBRARY_HEADERS
will cause the headers exported by that library to be exported from
the current library target as well.
This means that when library A's public headers include headers from
library B, library C which consumes A no longer has to explicitly list
A and B in its LOCAL_SHARED_LIBRARIES for the purpose of picking up B's
headers.
Bug: 27804373
Test: Introduced dependency on libbase to libbinder at the header level.
Libraries that consume libbinder do not need to explicitly depend
on libbase.
Change-Id: If69079f058a4a182c5ef5a3c5ba15035570da22d
am: 06af80f
* commit '06af80f6c4c1702b1aebea8cec56b49f43e88d4f':
Add Bison binary and its data to prerequisite
Change-Id: I5039150bcb4d06677bd6d5fd4acea8e643fccb89
Used to select between releases of the NDK (r10, r11, etc).
Some of the libraries we use in Android come as prebuilts from
google3, which are most likely built against an older NDK than what
we have in the platform. Since things may not be ABI compatible
release to release, we need to keep legacy versions accessible for
those to keep building.
Change-Id: Ia3df42fa6f3a7bd5108ff6bbb0f2ca06239c3be9
Clang and MinGW are not expected to work together currently, and you get
strange errors when this is attempted. Instead, error out with a clear
error message.
Before the windows build rewrite, we'd just explicitly set my_clang to
false without checking what the module asked for. Now, error out if the
module explicitly asked for clang, since by default they'd have it
already if it wasn't for windows. That way when Clang+Windows does
become possible, it can gradually be tested by setting LOCAL_CLANG to
true.
Change-Id: I9e0b0dca30946d94894119443f2fd0593cee1793
There was a typo in binary.mk. compile-dotdot-XXX-file in
definitions.mk was also using -include.
Bug: 26839129
Bug: 27886012
Change-Id: I4a0145fb70413998cc65d30d2efcd68af07b4800
(cherry picked from commit 72904774a3)
Also specify "-d keepdepfile" to ninja so .P files won't be
deleted by ninja.
-include for .s files are removed because GCC doesn't
generate .d files for .s files.
Bug: 26839129
Bug: 27886012
Change-Id: If00e93c7a33449ec314a5cdba438475a32979f4e
(cherry picked from commit 4037c4225a)
On Darwin ar would fail if there is no object file to add.
We work around by adding a dummy.o to the .a and then deleting it.
Bug: 27800477
Change-Id: I68bbebea2726058c25863d7026a645a520d05167
Why? For one, libgcc's unwinder makes use of `dl_iterate_phdr`. Also,
libgabi++ (the home grown C++ RT we use for stlport) uses
`dlopen` for liblog when reporting fatal errors. The LLVM unwinder
which is used by libc++ also uses libdl.
Requiring a dependency on libdl seems less objectionable than
requiring one on liblog. We could always change libgabi++ to use
syslog instead, but that will only reach logcat for newer devices
(possibly L+, definitely M+).
Requiring libdl seems like the best option here, especially given
that libgcc needs it anyway.
Change-Id: I4acfaf38145c39fc15a76fbb282a46786e5322f1
There was a typo in binary.mk. compile-dotdot-XXX-file in
definitions.mk was also using -include.
Bug: 26839129
Change-Id: I4a0145fb70413998cc65d30d2efcd68af07b4800
When a static library uses LOCAL_EXPORT_C_INCLUDE_DIRS, then is included
entirely in another library with LOCAL_WHOLE_STATIC_LIBRARIES, all the
symbols are reexported, so reexport the headers too.
Change-Id: I92cf17894fc991a5b5ecb59ca5e095e407c98de4
Also specify "-d keepdepfile" to ninja so .P files won't be
deleted by ninja.
-include for .s files are removed because GCC doesn't
generate .d files for .s files.
Bug: 26839129
Change-Id: If00e93c7a33449ec314a5cdba438475a32979f4e
And everything special-cased on that. Add a warning if USE_NINJA is
set to let users know that it no longer changes anything.
Change-Id: Ib8739151fe26ea6bf8f76b7ac2b8f4097dab0b47
* When WITH_STATIC_ANALYZER is set and non-zero, and clang compiler is used,
call new clang ccc-analyzer or c++-analyzer.
* Otherwise, if WITH_SYNTAX_CHECK is set and non-zero,
call compiler with -fsyntax-only.
* Replace "--sysroot=path" with "--sysroot path", to work with ccc-analyzer.
* ccc-analyzer executes the original compilation command to generate
object files before calling clang with --analyze to do static analysis.
* When clang is called with --analyze, macro __clang_analyzer__ is defined.
BUG: 13287788
(cherry picked from commit 765c1ea6d7)
Change-Id: I6e51e51ff4ed3ce514f60d090494dcdf6e520b04
There are some code policies we want to enforce more strictly, but
it's hard to do so for third party code because we have to either
carry the diff burden or upstream the patch, and in the latter case
the turnaround time for fixes can be problematic, and sometimes
upstream won't accept changes (sometimes people just need to win the
obfuscated C contest).
We define ANDROID_STRICT for any code that we expect to be able to
make these policy fixes as we change policies.
Change-Id: I15faf62cec1932dd859a082f66942b2606d0ff45
* When WITH_STATIC_ANALYZER is set and non-zero, and clang compiler is used,
call new clang ccc-analyzer or c++-analyzer.
* Otherwise, if WITH_SYNTAX_CHECK is set and non-zero,
call compiler with -fsyntax-only.
* Replace "--sysroot=path" with "--sysroot path", to work with ccc-analyzer.
* ccc-analyzer executes the original compilation command to generate
object files before calling clang with --analyze to do static analysis.
* When clang is called with --analyze, macro __clang_analyzer__ is defined.
BUG: 13287788
Change-Id: I5edb25b52998d871385dd000778db2ce83224078
*.o files that are passed in via LOCAL_GENERATED_SOURCES are added
directly to all_objects, they are not mixed with the normal_objects that
we track. So omit them from they my_gen_src_files list so that we don't
warn that they're unused.
Change-Id: I94b85504032e70fbcc00207d6200557700dd0a89
Objective-C .m/.mm files were not being tracked, so they were showing
up as unused source files (on Darwin). They were also triggering an
internal build system warning because the new object list did not
match the current list.
Change-Id: I01fff8c5587fe168106c60782080d60744311f6f
We have been reordering objects to the linker based on how they were
generated. In soong, they're ordered based on the order listed in the
src_files.
Keep track of which source files created which object files so that we
can create the ordered list. Optionally change the order, based on
BINARY_OBJECTS_ORDER. That way we can compare make and soong builds.
Since we're keeping track of the used source files, warn when an entry
in LOCAL_SRC_FILES is not used. (whether it is an unused file like a
header, or a typo)
LOCAL_GENERATED_SOURCES is not verified, since it is valid to add
headers and other files in that list (to set up dependencies).
Change-Id: I1dfbbb3aa570c11c1db3b7133e46ed0b8c3b8989
This was a regression since kati has been introduced. This CL
introduces include-depfile function to make it easier to write
Makefiles which work with both make and kati.
As ninja can handle only a single dependency file per a build
rule, now we merge multiple .d files generated by llvm-rs-cc
into a .d file.
Change-Id: Iaf64a8f0523ab98115837e6e06abd50f06620363
Both aidl and clang/gcc were putting their dependencies in the same
place. Move aidl's dependencies to a file ending with .aidl.P rather
than the compiler's .P.
While here, inform kati that we have these special dep files.
Bug:26409006
Test: Rebuild, note both files being generated
Change-Id: I29d2eea822235d60713c2059f3a314e475eb5aa3
Transform ../ to dotdot/ for C++ generateds from .aidl source files.
This forces us to use one layer of indirection to calculate the build
rules for .aidl files, since we can no longer use a pattern rule.
This was tested by modifying system/tools/aidl's Android.mk to refer to
its .aidl files by going up two directories and then repeating the
directories again. When I print the build rules with $(info) I see that
dotdot/ appears in appropriate places (C++ paths, but not .aidl paths).
Bug: 26407018
Test: Described above.
Change-Id: I397c9d10408c0c66d8b5a247a1f34eb4bf4f74ce
This effectively changes the default instruction set of assembly files
from arm to thumb in order to match the default for C/C++.
Change-Id: I8684f144a1195b53b3e0fdd04cacf77f6a131c7e
- For .l/.y source files, generate .c files; for .ll/.yy source files,
generate c++ files.
- Simplified the rules by adding the generated sources to
my_generated_sources.
- Simplified generated header file naming by always using .h extension
with bison's "--defines=" option.
- Removed the unnecesarry conditional inclusion to the generated
headers. Bison already automatically generates such things.
Bug: 26492989
Change-Id: I9ab6dc149c258f7642bc36c3fa32f90ff7ee51a4
- For .l/.y source files, generate .c files; for .ll/.yy source files,
generate c++ files.
- Simplified the rules by adding the generated sources to
my_generated_sources.
- Simplified generated header file naming by always using .h extension
with bison's "--defines=" option.
- Removed the unnecesarry conditional inclusion to the generated
headers. Bison already automatically generates such things.
Bug: 26492989
Change-Id: I9ab6dc149c258f7642bc36c3fa32f90ff7ee51a4
When USE_CLANG_PLATFORM_BUILD is not set, default will be clang/llvm.
USE_CLANG_PLATFORM_BUILD=false can be used to select gcc as default.
Bug: 23163853
Bug: 26102335
Change-Id: I434176732fa4a382be9d8d8642a1c705b023cf84
Host binaries may be run during the build process and the internal
implementation of the shared libraries makes a difference for the build
result. This change makes sure host tools get re-linked and re-run when
any of its dependency libraries gets updated.
DEX2OAT is such a host tool. We also changed DEX2OAT as full dependency
of dex-preoptimization, so we rebuild the odex files if DEX2OAT itself,
or any dependency libraries changed.
Bug: 24597504
Change-Id: Idf0d9be82ccebd826d9c5b405a39cff437e0af29