Commit Graph

192 Commits

Author SHA1 Message Date
Dan Willemsen 724ab5d5f7 Fix missing deps found through RBE
Bug: 130111713
Test: run with RBE, no longer see error about file not found
Change-Id: Ib6192f2a537f49efdb69b3f3bf28aef1660dec01
2019-09-19 10:51:03 -07:00
Yi Kong ee96a7956a Add back the llvm-ar P flag
The P flag is supported as of llvm r354044, add back the flag to reduce
the size of intermediate archieve files. This does not affect the final
binaries.

Test: built
Bug: 71618641
Change-Id: I017780e4dcaa31c7fbe10b5e7482db1bba83e716
2019-09-06 15:11:57 -07:00
Dan Willemsen 98ab311767 Save deps when asflags contains -xassembler-with-cpp
Usually, ".S" files are processes with the c preprocessor, and ".s"
files are not, so they don't have any dependency information, since it
is generated by the preprocessor.

But with the -xassembler-with-cpp flag, ".s" files are processed with
the preprocessor, so we should ask for dependency information from them.

Test: NINJA_ARGS="-t deps out/soong/.intermediates/external/sonivox/arm-wt-22k/libsonivox/android_arm_armv7-a-neon_core_static/obj/external/sonivox/arm-wt-22k/lib_src/ARM-E_filter_gnu.o" m
Test: treehugger
Change-Id: Iee7baeebc2b205b5a2f33e7c1705ea4a5b4fc95a
2019-08-27 21:20:40 -07:00
Treehugger Robot 792942de47 Merge changes I75b4a761,I779f28c6,If1422372,I26307dd1
* changes:
  Introduce inject_bssl_hash library property.
  BoringSSL FIPS build - introduce extraLibFlags and use for STL libs.
  Allow linker scripts when building objects.
  Allow .o files as srcs.
2019-08-23 00:15:08 +00:00
Pete Bentley 99f2fc27e6 BoringSSL FIPS build - introduce extraLibFlags and use for STL libs.
Rationale: On non-bionic, stl.go currently adds system libraries to
ldFlags, this causes problems for partialLd rules.  However adding the
same libraries to libFlags breaks some existing modules due to symbol
conflicts as the system libraries are linked before some module code.

Introduced a general mechanism for adding libraries to be linked
last rather than making this STL-specific.

Bug: 134581881
Bug: 137267623
Test: TH
Change-Id: I779f28c6586b3fea85cc6299b686e4fde95262d3
2019-08-22 13:21:37 -07:00
Pete Bentley fcf55bf656 Allow .o files as srcs.
Test: m nothing
Test: TreeHugger
Bug: 134581881
Bug: 137267623

Change-Id: I26307dd1129e58878f0468da3b61c53f074bd674
2019-08-22 13:21:37 -07:00
Hsin-Yi Chen eef3366ab3 Merge "Add tags to the list of lsdump paths" 2019-08-15 02:20:30 +00:00
Dan Willemsen 6b4419ccc7 Include dependencies for clang-tidy and header-abi-dumper
We've been getting these dependencies transitively through the
dependency on the object itself (which is a workaround for the lack of
dep file support in these tools). But for remote builds to work, we need
to know about these dependencies like any other object compilation.

For regular builds, this increases the size of the ninja file by a few
tens of megabytes (~1-2%).

WITH_TIDY builds were already larger (~40-50%), but are now about 90%
larger than a normal build.

Test: treehugger
Change-Id: Icdb4ca3d4d08d5706593d96d5c627149fa14fed8
2019-08-09 13:03:07 -07:00
Hsin-Yi Chen 5348964723 Add tags to the list of lsdump paths
This commit adds tags, such as NDK, VNDK-core, and PLATFORM, to
LSDUMP_PATHS. The script updating the reference ABI dumps uses the tags
to determine the directories where the dumps should be created.

Test: make findlsdumps
Bug: 133176785
Change-Id: I8540286238cf0ec55c65e1c4f60cb9c12e5e57a1
2019-08-07 13:40:11 +08:00
Sasha Smundak 2a4549ec98 Support source code cross-referencing for C++ and Java
Use Kythe (https://kythe.io) to build cross reference for the Android
source code. ~generate the input for it during the build. This is done
on demand: if XREF_CORPUS environment variable is set, build emits a
Ninja rule to generate Kythe input for each compilation rule. It
also emits two consolidation rules (`xref_cxx` and `xref_java`),
that depend on all Kythe input generation rules for C++ and Java.

The value of the XREF_CORPUS environment variable is recorded in the
generated files and thus passed to Kythe. For the AOSP master branch it is
`android.googlesource.com/platform/superproject`, so the command to build
all input for Kythe on that branch is:
```
XREF_CORPUS=android.googlesource.com/platform/superproject m xref_cxx xref_java
```

Each Kythe input generation rule generates a single file with .kzip
extension. Individual .kzip files have a lot of common information, so
there will be a post-build consolidation step run to combine them.
The consolidated .kzip file is then passed to Kythe backend.

The tools to generate .kzip files are provided by Kythe (it calls them
'extractors'). We are going to build them in toolbuilding branches
(clang-tools and build-tools) and check them in as binaries into master
and other PDK branches:
For C++,  `prebuilts/clang-tools/linux-x86/bin/cxx_extractor`
for Java, `prebuilts/build-tools/common/framework/javac_extractor.jar`

Bug: 121267023
Test: 1) When XREF_CORPUS is set, build generates Ninja rules to create
.kzip files; 2) When XREF_CORPUS is set, building
`xref_cxx`/`xref_java` creates .kzip files; 3) Unless XREF_CORPUS is
set, build generates the same Ninja rules as before

Change-Id: If957b35d7abc82dbfbb3665980e7c34afe7c789e
2019-07-26 09:16:47 -07:00
Peter Collingbourne 84d8385ae1 Use LLD for partialLd.
Clang will soon start using relocations that are currently unsupported by
the version of ld.bfd that Android uses when HWASAN is enabled. This will
cause partialLd to fail since the clang driver defaults to ld.bfd.

Switch to using LLD, since it will support those relocations.

Change-Id: I0964f53dc63773f3b52bb377f863df9c39961a07
2019-07-16 14:14:36 -07:00
Colin Cross d34ab7c6b2 Treat .cxx files as c++
Fixes: 135749365
Fixes: 135667566
Test: m checkbuild
Change-Id: If47274812dfe781ebbb9f8a60a395650573727d5
2019-06-27 14:46:10 -07:00
Yi Kong 823532df31 Move darwin to llvm-ar
Test: build
Bug: 71618641
Change-Id: Ib45963bc9e295afe39752a270f7b5a1197335c69
2019-06-12 19:16:25 -07:00
Treehugger Robot 7268fd494d Merge "Package coverage files as a zip." 2019-06-12 02:00:01 +00:00
Oliver Nguyen c743414d42 Package coverage files as a zip.
Test: make NATIVE_COVERAGE=true COVERAGE_PATHS="*"
Change-Id: I955212a20ea19c854ebc88635252a1d174ea8f7f
2019-06-11 16:04:11 -07:00
Josh Gao 75a50a2c15 Revert "Revert "Revert "Revert "Enable lld for windows""""
This reverts commit b20200b3f5.

Bug: http://b/110800681
Test: manual
Change-Id: Id3eb45ed29f3977fef3da241ec2c43755116d60c
2019-06-10 12:59:11 -07:00
Josh Gao b20200b3f5 Revert "Revert "Revert "Enable lld for windows"""
This reverts commit 6d8c0a50bc.

The switchover to lld appears to be making adb crash on exit for unclear
reasons. Revert it as a quick fix pending further investigation.

Bug: http://b/134613180
Test: adb.exe under windbg
Change-Id: Ibdf5981c3c6828b3684974b7c30a7c96449c64c5
2019-06-07 12:34:18 -07:00
Colin Cross badf8d691f Cut darwinStripPool from 10 to 5
Failures in strip.sh are still occurring with darwinStripPool set to
10, try 5.

Bug: 132822437
Test: none
Change-Id: I2df247c89b6d8f6e741d4e17057b06ff9ec72b40
2019-05-23 02:09:07 +00:00
Christopher Ferris 8a7469a0d7 Merge "Add an option to preserve symbols and debug_frame." 2019-05-21 18:09:08 +00:00
Christopher Ferris b43fe7a838 Add an option to preserve symbols and debug_frame.
New strip option named keep_symbols_and_debug_frame, that will keep the
symbols and the .debug_frame. This is meant for use by libc.so only on
arm32. Other libraries might want to use it to keep better unwinding
information on device.

Bug: 132992102

Test: Built libc.so with this option and verified that it contains
Test: the .debug_frame section.
Change-Id: I823a28199dec8316e8b26fe31ff9f17e6b11d406
2019-05-17 17:52:18 -07:00
Colin Cross ee3ea31a24 Limit calls to strip.sh on darwin
strip.sh can use a file descriptor per .o file when run on .a files,
which can hit the system file descriptor limit on darwin.  This
causes failures when manay variants of libgcc_stripped are built
simultaneously.  Put all strip rules on darwin into a pool that
limits them to 10 concurrent processes, which will limit the file
descriptor usage to ~7500.

Fixes: 132822437
Test: no mention of darwinStripPool in out/soong/build.ninja on linux
Test: m libgcc_stripped on darwin
Change-Id: I3d4fbbd8d44d2e9059a79df113ab95336ec2c658
2019-05-17 22:51:00 +00:00
Yi Kong acee27cd72 Strip libgcc to only keep fallback symbols
We use libgcc as fallback for symbols not present in libclang_rt
builtins, however we didn't know what exact symbols were being used,
some may not be intended to fallback.

Create libgcc_stripped, which only contains unwind symbols from libgcc.

Bug: 29275768
Test: bionic-unit-tests
Change-Id: I5b349fa6138e51663bf3b67109b880b4356da8e8
2019-04-30 10:07:00 -07:00
Pirama Arumuga Nainar 6d8c0a50bc Revert "Revert "Enable lld for windows""
This reverts commit 61166dc047.

One difference from the earlier change is that import libraries are now
using the '.lib' extension instead of '.a' to prevent clash with
AdbWinApi.a.

Bug: http://b/110800681

The following flags that the binutils linkers support are not
available in lld for Windows:
  -soname
  --no-undefined
  -rpath

Windows also uses "import libraries", which are stub libraries used only
for linking.  The binutils linkers accepted a DLL and treated them as an
import library.  But lld issues the following error:

  lld-link: error: ...DLL: bad file type. Did you specify a DLL instead
  of an import library?

To resolve this, pass '-out-implib=libFoo.lib' to lld when linking
libFoo.dll to get lld to generate an import library.  Add libFoo.lib as
an implicit output to the 'ld' build rule.

Rewrite the shared libraries when building a library/binary to use the
import library instead of the DLL.  As a side-effect, this also uses the
newly-created AdbWinApi.lib that's alongside
development/host/windows/prebuilt/usb/AdbWinApi.dll

Test: Run Windows tests (go/android-llvm-windows-testing) and check
absence of regressions.  Also check that the following commands pass:
      $ adb.exe devices
      $ fastboot.exe devices

Change-Id: I34e07d345e0207086ac8e8ea12525d8c322b20fd
2019-04-16 16:22:03 -07:00
Dan Willemsen 4e0aa23dd3 Convert yacc to a single RuleBuilder rule
So that <module>/gen/yacc/... is (re)created by a single rule, previous
files are removed, and location.hh is in the build graph when it is
produced.

Test: treehugger
Change-Id: I2f6e47ea07f315e10ae1cb8ad50697e7123d0285
2019-04-15 14:52:05 -07:00
Logan Chien 62f1f9488e Add --llndk for NDK libs as well
This commit add `--llndk` to the command line option for
`create_reference_dumps.py` as well.

Bug: 124620774
Bug: 130324828
Test: lunch aosp_arm64-userdebug && make
Change-Id: I117864209b8cf8c934fd3aa1086b7691c1c449e3
2019-04-11 05:40:57 +00:00
George Burgess IV c4624c0189 Remove our clang-tidy wrapper
Looks like the reason for it existing has been fixed. It should probably
just be removed.

Bug: None
Test: WITH_TIDY=1 m

Change-Id: I770b2fec4ac44f265ff31731c9c0bd4da14d5b0f
2019-04-04 17:58:00 -07:00
Josh Gao 61166dc047 Revert "Enable lld for windows"
This reverts commit 3c21c0b1d9.

Reason for revert: appears to break AdbWinUsb.dll usage by fastboot (and adb?)

Bug: http://b/129420419
Bug: http://b/110800681
Change-Id: I36d6d87f2e830e08e257ab42d470e49cdbb95819
2019-04-03 00:59:14 +00:00
Colin Cross fe17f6f0e8 Add support for protoc plugins
Add a proto.plugin property to allow specifying a custom protoc
plugin to generate the code.

Fixes: 70706119
Test: m am StreamingProtoTest
Change-Id: I1ecdd346284b42bbcc8297019d98d2cd564eb94c
2019-04-02 16:38:55 +00:00
Colin Cross 19878da6a0 Move proto compilation to RuleBuilder
Using blueprint.Rule for protoc commands was causing code duplication
because there was no good way to run the same protoc for cc, java and
python but then run custom source packaging steps for java and python.
Move most of the code into a common function that returns a
RuleBuilder, and then let java and python add their own commands at
the end of the rule.

Bug: 70706119
Test: All Soong tests
Test: m checkbuild
Change-Id: Ic692136775d273bcc4f4de99620ab4878667c83a
2019-04-02 16:38:47 +00:00
Colin Cross 36ae135434 Restat clang linker outputs
clang -Wl,--out-implib doesn't update its output file if it hasn't
changed, always restat the outputs.

Fixes: 129553377
Test: m checkbuild && m checkbuild
Change-Id: I2cb19e1b8280fd69c8a9b2143f55760ec05630f8
2019-03-30 00:03:24 +00:00
Pirama Arumuga Nainar 3c21c0b1d9 Enable lld for windows
Bug: http://b/110800681

The following flags that the binutils linkers support are not available
in lld for Windows:
  -soname
  --no-undefined
  -rpath

Windows also uses "import libraries", which are stub libraries used only
for linking.  The binutils linkers accepted a DLL and treated them as an
import library.  But lld issues the following error:

  lld-link: error: ...DLL: bad file type. Did you specify a DLL instead
  of an import library?

To resolve this, pass '-out-implib=libFoo.a' to lld when linking
libFoo.dll.  Add libFoo.a as an implicit output to the 'ld' build rule.

Rewrite the shared libraries for a library/binary to use the import
library instead of the DLL.  As a side-effect, this also (correctly)
uses the AdbWinApi.a that's alongside
development/host/windows/prebuilt/usb/AdbWinApi.dll

Test: Run Windows tests (go/android-llvm-windows-testing) and check
absence of regressions.

Change-Id: I15a178589aa6882caa6e7e38650cc6ef48109764
2019-03-20 21:07:47 +00:00
Logan Chien 6227fed029 Print --llndk to create_reference_dumps command
This commands adds `--llndk` to `create_reference_dump.py` command if
the module with incompatible ABI changes is an LLNDK or a NDK lib. This
prevents people from uploading a CL that simply removes ABI dumps (the
result even when the uploader runs the command).

Bug: 124620774
Test: Make an incompatible ABI changes in libaaudio and see the flag.
Change-Id: I9f07f879193bd4d73f5924baff298d28d6fe1506
2019-02-18 13:35:36 +08:00
Yi Kong b5c34d7f40 Use llvm-{strip,objcopy} by default
... except for Darwin Mach-O, as it is not supported by llvm-strip.

Test: m checkbuild
Bug: 119221035
Change-Id: I021637b6dd3530bff1f563f2ec7c2168e1083b7e
2019-02-04 18:20:28 +08:00
Logan Chien e3d7a0d062 Add a header_abi_checker section
This commit adds a header_abi_checker section so that the library owner
can have a fine-grained control over the ABIs that must be checked.

For example, a library "libexample" may have following configurations:

    cc_library {
        name: "libexample",
        header_abi_checker: {
            symbol_file: "libexample.map.txt",
            exclude_symbol_versions: ["LIBEXAMPLE_PRIVATE"],
            exclude_symbol_tags: ["platform", "apex"],
        },
    }

Bug: 122845490
Test: Add header_abi_checker to libc to filter out LIBC_PRIVATE
Change-Id: I60cfea868f815afe6213c242ed0ca818161d55c6
2019-01-30 22:18:59 +08:00
Logan Chien 8f74fe6e14 Fix a typo related to abidiffs
This commit fixes a typo related to abidiffs.  The generated abidiffs
should be copied to `$$DIST_DIR/abidiffs` instead of
`$$DIST_DIR/abidiff`.

(See also. https://android-review.googlesource.com/796458/)

Bug: 123491909
Test: lunch aosp_x86-userdebug && make dist
Change-Id: I89c13580344a27cac5ea0d00497f5bba3227cf61
2019-01-28 14:30:04 +08:00
Dan Willemsen fcabb1c518 Don't expect depfile from .s files
.s files (unlike .S files) aren't run through the preprocessor, so -M*
doesn't actually write out a depfile.

Since our ninja is now going to be verifying that the depfile is created
(https://android-review.googlesource.com/861510), don't specify a
depfile for .s files.

Bug: 121058584
Test: apply https://android-review.googlesource.com/861510
Test: cd external/libavc; mma
Change-Id: I1697aa020c63639317c8f4771147026601ae72fc
2019-01-03 23:25:11 -08:00
Dan Willemsen 60e62f0c44 Add nanopb-c support
Test: cd hardware/ril; mma
Change-Id: Id1481940d15a2a3f6eb29af54ee30080ff2286cb
2018-11-17 15:28:25 -08:00
Peter Collingbourne abde584fd1 Stop passing the gold plugin path to llvm-ar.
llvm-ar takes a --plugin argument but it is ignored for compatibility,
so passing it has no effect.

Change-Id: I4fc51d226d66cf2a43462d3d4ccc12e6e5ebb226
2018-11-08 20:13:16 -08:00
Dan Willemsen 2d31a44b8a Stop using DIST_DIR in Soong
We're only using it to distribute files in case of failure, which isn't
well supported currently, but can be handled for now by using the
DIST_DIR environment variable during the command execution.

This was at least one cause that we'd be re-running Soong during every
build server build, as the DIST_DIR values are unique.

Test: m dist
Change-Id: Ibd5e6b6c46695350de80b745bfb6a6aa685033a0
2018-10-20 21:33:41 -07:00
Logan Chien 3ff624f24b Switch include path of header-abi-dumper headers
This commit switches the include path of header-abi-dumper clang headers
to `prebuilts/clang-tools/${os}-x86/clang-headers`.  This decouples the
cross git repositories dependencies.

Bug: 111579848
Test: development/vndk/tools/header-checker/utils/create_reference_dumps.py
Change-Id: I53083298ca7be39b3fbaffb123146c12c189e7c3
2018-10-11 17:11:34 +08:00
Dan Willemsen 8536d6b3b7 Remove GCC checks
Clang is always used now, so we can remove all the GCC checks. Removing
GCC-specific configuration will happen in the next CL.

Test: m
Change-Id: I4835ecf6062159315d0dfb07b098e60bff033a8a
2018-10-09 02:16:58 +00:00
Dan Willemsen feea4dff66 Stop using GCC in toolchain_library
Instead, hardcode the ~dozen paths into build/soong/Android.bp, which
will unblock removing more GCC support.

Bug: 114286031
Test: m
Change-Id: I2508432e00b1469141f01e667f3c6a2fe30cd805
2018-10-07 23:50:34 -07:00
Colin Cross b496cfd9d2 Enable toc support for Darwin and Windows
Bug: 113936524
Test: m checkbuild
Change-Id: I0f2030ad75daae2cbe44e8cbedad329d33df55f7
2018-09-10 23:12:11 -07:00
Chih-Hung Hsieh b699c43f89 Define PATH_TO_CLANG_TIDY_SHELL for build/make rules.
* PATH_TO_CLANG_TIDY_SHELL is ${config.ClangTidyShellPath},
  wich is "build/soong/scripts/clang-tidy.sh"

Bug: 110538415
Test: build with WITH_TIDY=1
Change-Id: I27d7be095c998583fa9ad4d705aa1332bd018140
2018-08-27 16:19:59 -07:00
Chih-Hung Hsieh 9e88ba9f22 Remove flto dependent flags when -flto is removed.
* C++ source files could be compiled with "-fwhole-program-vtables"
  in cppflags. We need to filter out those flto dependent flags
  in flags.CppFlags and use flags.toolingCppFlags instead of
  flags.cppFlags.

Test: build with WITH_TIDY=1
Change-Id: Ic2b0f99b95a5f0422f879226e6f6060cab71456a
2018-08-24 18:42:22 +00:00
Chih-Hung Hsieh a7aa958e6e Add clang-tidy.sh to filter out troublesome flags.
* Some flags are accepted by clang but not clang-tidy.
  They could cause the diagnostic-unused-command-line-argument warning.
  Flag -flto messed up the -I flags.
* Add clang-diagnostic-unused-command-line-argument to
  default clang-tidy checks.
* Move CLANG_TIDY_UNKNOWN_CFLAGS to build/make/core/clang/tidy.mk.

Bug: 111850071
Bug: 111885396
Test: build with WITH_TIDY=1
Change-Id: Iabeeb27715acf83ef6aafe3e77206b9a01a0d889
2018-08-22 09:21:45 -07:00
Jayant Chowdhary c7434e28d3 For llndk libraries add -consider-opaque-types-different to header-abi-diff invocation.
Bug: 79576032

Test: Create abi reference for libmediandk; build libmediandk;
      header-abi-diff gets invoked with '-consider-opaque-types-different'

Change-Id: I132138e333cc944b54051243b44fa072af74aa83
Signed-off-by: Jayant Chowdhary <jchowdhary@google.com>
2018-06-11 10:51:43 -07:00
Chih-Hung Hsieh 30485c920c Use llvm-{objcopy,strip} when clang lld is used.
* Pass LLVM_{OBJCOPY,STRIP} to makefile rules.
* strip.sh is used only in soong-only mode.
  It will use llvm-strip and  and llvm-objcopy
  when --use-llvm-strip is given.
  Keep flags of strip.sh in alphabetic order.
* Tested build/soong/scripts/build-ndk-prebuilts.sh
  by adding "UseClangLld": true, to soong.variables file.

Bug: 80093681
Test: build/soong/scripts/build-ndk-prebuilts.sh
Change-Id: I612267304eea434c7a33cc086b27b577d5f64094
2018-06-07 16:04:14 -07:00
Jayant Chowdhary 39d167aa2c Temporarily remove -check-all-apis from header-abi-diff invocation.
-check-all-apis currently, produces noise for some libraries
(eg:libstagefright_soft_vpxenc), so remove this till a good solution
arrives.

Bug: 79928919

Test: create abi reference for libstagefright_soft_vpxenc; m -j
      libstagefright_soft_vpxenc.vendor; no warnings about struct LAYER_CONTEXT
      layout changing.

Change-Id: I8f30700c1b619c72504ca9aef69075f6e334ba5f
2018-05-18 08:10:58 -07:00
Jiyong Park a5f11e426c Friendlier message for ABI reference update
This change is to let people to just copy & paste the update command

Test: break the ABI of libbinder intentionally and make.
The message includes absolute path to the create_reference_dump.py tool.

Change-Id: If7703d64be1f51ea4b054aa1e815276e1d6dbc14
2018-04-19 10:42:40 +09:00
Dan Willemsen edd1ae0817 Fix ABI diff reporting with dist
When we're doing ABI diffing, we run something like:

  (run-abi-diff) || (echo && exit 1)

When `dist` is added, we attempt to copy out the result:

  (run-abi-diff) || (echo) && (copy && exit 1)

But this always fails, since it will always run exit 1. We really want
the parenthesis around the entire second section. This change switches
it to:

  (run-abi-diff) || (echo && (copy) && exit 1)

This matches the behavior before Iae25374fe937a0cbe8a8ddf9e23c3bc1f62bbb2a

Test: treehugger on P
Change-Id: Ic39da4d4630ee950b811ec7854d55d65c52f8661
2018-04-17 10:42:18 -07:00
Jayant Chowdhary d8b70a39d1 Add informational message to help with updation of VNDK abi references.
Test: create reference dump for libjpeg; add exported function to libjpeg;
      m -j libjpeg.vendor, build fails with helpful message.

Test: create reference dump for libjpeg; add exported function to libjpeg;
      m -j libjpeg.vendor dist DIST_DIR=dist, build fails with helpful message.

Change-Id: Iae25374fe937a0cbe8a8ddf9e23c3bc1f62bbb2a
2018-03-30 11:08:00 -07:00
Chih-Hung Hsieh 3ede294729 Switch to clang 7.0
* Suppress more noisy new warnings at global level.
* Add -no-pie to partial link .o files, with -r.
* Revert workaround of b/72706604, no need of
  -Wl,-plugin-opt,-emulated-tls
* Filter out clang 7.0 unknown flag "-Wno-extended-offsetof"

Bug: 72706604
Bug: 72412006
Test: make checkbuild
Change-Id: I7ff45465c4bd771991f42b40f68dc35586045656
2018-03-26 18:04:47 -07:00
Dan Willemsen bc0c509267 Add DistPath to reference the dist folder
Instead of open-coding the logic of whether there is one, or where to
find it.

Test: diff out/soong/build.ninja without dist
Test: diff out/soong/build.ninja with dist specified
Change-Id: Ia3f1ef335e2d6e2175343338d04867d778a50300
2018-03-12 15:48:30 -07:00
Dan Willemsen 54daaf0371 Switch PackageContext functions to take a ctx
So that the Path and similar functions can be used directly, without
manually adding something like configErrorWrapper (it just uses it all
the time now).

Test: out/soong/build.ninja is identical
Change-Id: I8cb524b09a84d0b8357d7c3501c71270af411e17
2018-03-12 15:48:26 -07:00
Dan Willemsen 8fec83a8b9 Use xz prebuilt
Instead of whichever xz happens to be on the PATH.

Bug: 36130900
Test: prebuilts/build-tools/build-prebuilts.sh
Change-Id: Ic9b66062ca7947f0eca9d839c0864da492d4ef71
2018-03-09 10:53:26 -08:00
Jayant Chowdhary dcd33b6c29 Create a make variable for all lsdump files.
This is needed so that we can embed the paths of lsdump files in a file,
in order to make lookup faster, while creating reference dumps.

Test: mm -j64 in external/libjpeg-turbo for aosp_arm64_ab;
      out/soong/make_vars-aosp_arm64_ab.mk contains
      SOONG_LSDUMP_PATHS := <list of lsdump paths>

Change-Id: I04608429e1add307cc1ee79d2f0c348fb041613c
2018-03-01 17:19:25 -08:00
Dan Willemsen ab9f4268c0 Add proto.canonical_path_from_root
Historically, we've always passed '-I .' as the first argument to
protoc, essentially treating all proto file package names as their full
path in the android source tree. This would make sense in a monorepo
world, but it makes less sense when we're pulling in external projects
with established package names.

So keep the same default (for now), but allow individual builds to opt
into using local paths as the default names with
'canonical_path_from_root: false'. A cleanup effort and/or large scale
change in the future could change the default to false.

As part of this, run protoc once per input proto file, since the flags
may need to change per-file. We'll also need this in order to specify
--dependency_out in the future.

Bug: 70704330
Test: aosp/master build-aosp_arm.ninja is identical
Test: aosp/master soong/build.ninja has expected changes
Test: m
Test: Build protobuf test
Change-Id: I9d6de9fd630326bbcced1c62a4a7e9546429b0ce
2018-02-22 16:48:35 -08:00
Jayant Chowdhary a4c6df5d69 Start using clang-tools prebuilts for abi diffing tools.
Bug: 72504455

Test: make -j64

Change-Id: Idbe1142e11147163d0c032fb351e9f3d5614dfb1
2018-02-20 12:44:50 -08:00
Zhizhou Yang 51be632b95 Fix llvm-ar error caused by using lto and sanitizer together
LLVM-AR does not allow passing --plugin options more than once. The
--plugin ARFLAGS that lto want to add, may already exist if sanitizer is
also turned on.

Fixed this by adding a new bool Flags.ArGoldPlugin. Set this variable to
true whenever LLVM gold plugin is needed for ArFlags. In function
TransformObjToStaticLib(), add this option to arFlags using global value
${config.LLVMGoldPlugin} if the bool value is true.

Bug: http://b/73160350
Test: build the image with make and succeeded.

Change-Id: I62785829b0a4b663225926e4aed98defc1b6da2c
(cherry picked from commit 4917049f6e)
2018-02-14 21:21:14 +08:00
Pirama Arumuga Nainar f231b19017 Add only compiler-flag dependencies as implicit
Bug: http://b/72343691

Change https://android-review.googlesource.com/c/572758, in addition to
dependencies from the compiler flags, also marked all exported
dependencies as implicit.  This can cause lots of unnecessary
recompiles.  This change moves exported dependencies back as order-only
dependencies.

Test: 1. mma in art after changing profile_compilation_info.h triggers
         only a limited number of recompiles.
      2. verify that changes to PGO profile files trigger recompiles.

Change-Id: Icb0f4cd2b6da0add3b6e5206661e6aa7a577602f
2018-01-23 11:24:33 -08:00
Logan Chien f351174107 Support VNDK extensions
This commit adds `extends: "name"` property and provides basic support
to VNDK extensions.  This is the simplest example:

```
cc_library {
    name: "libvndk",
    vendor_available: true,
    vndk {
        enabled: true,
    },
}

cc_library {
    name: "libvndk_ext",
    vendor: true,
    vndk: {
        enabled: true,
        extends: "libvndk",
    },
}
```

A vndk extension library must extend an existing vndk library which has
`vendor_available: true`.  These two libraries must have the same
`support_system_process` property.

VNDK-ext libraries are installed to `/vendor/lib[64]/vndk` and
VNDK-SP-ext libraries are installed to `/vendor/lib[64]/vndk-sp` by
default.

If there is a matching abi-dumps in `prebuilts/abi-dumps`,
`header-abi-diff` will be invoked to check for ABI breakages.

Bug: 38340960

Test: lunch aosp_walleye-userdebug && make -j8   # runs unit tests

Test: lunch aosp_arm-userdebug && make -j8  # build a target w/o VNDK

Test: Create a lsdump for a vndk lib, add an exported API to vndk lib,
and build fails as expected.

Test: Create a lsdump for a vndk lib, create an vndk extension lib with
extra API, and build succeeds as expected.

Test: Create libutils_ext, add an extra function to libutils_ext, and
call it from a HIDL service.

Change-Id: Iba90e08848ee99814405457f047321e6b52b2df0
2018-01-23 01:40:54 +00:00
Jayant Chowdhary e44995078f Use -advice-only for libraries which do not export headers.
While diffing abi, for libraries which do not export headers, use
-advice-only.

Test: Create reference dump for libdl; mm -j64; header-abi-diff gets
      invoked with '-advice-only'.

Test: Create reference dump for libjpeg; mm -j64; header-abi-diff gets
      invoked without '-advice-only'.

Bug: 71768219

Change-Id: I678346081f15088388f223f1276d0b0c42d2a8c2
2018-01-18 15:52:43 -08:00
Jayant Chowdhary df344d57b0 Remove the use of version scripts with header-abi-linker.
Version scripts were earlier used as a symbol map, primarily for llndk
libraries. Since they do have stub libraries which contain symbols, we
shall use them instead, to internally form symbol maps in
header-abi-linker.

Test: mm -j64 in bionic/libdl, header-abi-linker gets invoked with
      -so <so-file> rather than -v <version-script>

Change-Id: Ifb67dc34457a997f37cc9f71ca16ad068e9b44c1
2018-01-17 11:17:40 -08:00
Stephen Hines f1addebb44 Switch back to llvm-ar (with crsD flags only).
This properly sets -format=gnu for all non-Darwin targets, because
llvm-ar is cross-platform (but defaults to the host environment).

Bug: http://b/71618641
Test: m checkbuild
Change-Id: Ic5bce7e237ea0cadfa1f96ea151d41115d8c56b8
2018-01-10 15:57:49 -08:00
Yi Kong df97a8ac9c Revert "Switch to llvm-ar (with crsD flags only)."
This reverts commit 13bc31d6e1.

Bug: 71694982
Reason for revert: Broke Mac build

Change-Id: I0da6866442ca9273dd329f0b82932f939b7f65ed
2018-01-08 18:10:35 +00:00
Yi Kong 13bc31d6e1 Switch to llvm-ar (with crsD flags only).
llvm-ar is required for platform LTO build.

Bug: 71618641
Test: m checkbuild
Change-Id: Idecea9fbe5dcbb1023dbe90047e3f9535d953440
2018-01-04 23:52:44 -08:00
Pirama Arumuga Nainar 70ba5a38d1 Add compile-time pathDeps as implicit dependencies
Bug: http://b/70820751
Bug: http://b/70857959

Clang does not output file dependencies from the -fprofile-use= flag
during -MD/-MM.  Add this and other path dependencies as implicit Ninja
dependencies.  Generated header dependencies are retained as OrderOnly
dependencies.

Test: Perturb profdata files for hwui/skia in internal branch and verify
that the sources get rebuilt.

Change-Id: I3247d995ee27a4882172eb15ff36acf56536b6f7
2017-12-19 15:44:38 -08:00
Joe Onorato 09e94ab074 When compiling with the lite protobuf option, pass the option to aprotoc to force the lite runtime.
Test: make
Merged-In: I450f89d144d496a6ddfccc6a6a5a679a05809595
Change-Id: I450f89d144d496a6ddfccc6a6a5a679a05809595
2017-12-15 08:40:27 -08:00
Jayant Chowdhary 219139df8c Copy abidiffs into /abidiffs on abi breakages.
Bug: 64267858

Test: create reference abi dump for libjpeg locally. Change return type
      of libjpeg_std_err and build with :
      BOARD_VNDK_VERSION=current mm -j64 showcommands dist
      Build fails and abidiff report gets copied into out/dist/abidiffs.

Change-Id: I7c8ecfac95361e731009e5913bd3a7bb323a9597
2017-11-27 17:16:29 -08:00
Jayant Chowdhary a3bb1b3e3b Convert abi warnings to errors.
Convert abi warnings to errors by removing the -advice-only flag from
the invocation of header-abi-diff. This will only apply to branches with
reference abi dumps checked into prebuilts/abi-dumps/(v)ndk (since
abi-diffing will only be triggered on them.)

Also allow for:

1) Extensions.
2) Changes to types in exported headers, unreferenced by public symbols still
   trigger warnings.
3) Any removal of symbols appearing in a shared library's .dynsym table, but not
   in exported headers is still a warning.

Bug: 64267858

Test: make -j64 from ToT.

Change-Id: Iadeac8d060cb693d4310afb841dc48d91f38597d
2017-11-01 17:32:26 -07:00
Colin Cross ae88703df5 Move ModuleContext.ModuleBuild to ModuleContext.Build
Now that android.ModuleContext does not include blueprint.ModuleContext
we can rename android.ModuleContext.ModuleBuild to
android.ModuleContext.Build without colliding with
blueprint.ModuleContext.Build.  Leave ModuleBuild as a wrapper around
Build for now to avoid having to update all the users outside
build/soong simultaneously.

Test: m checkbuild
Change-Id: I18eb8cc04faf002049a11d9aac97e9732ff5d638
2017-10-24 10:59:00 -07:00
Jeff Gaston af3cc2d23c Some clarifications in preparation to automatically order linker dependencies
Test: Browse the code and determine whether it's easier to understand
Bug: 66260943
Change-Id: I88c24a8a31ef68f428919087d206433659265684
2017-10-18 18:06:02 +00:00
Jeff Gaston 7b6118be6b Revert "Some clarifications in preparation to automatically order linker dependencies"
This reverts commit 2370af0e23.

Reason for revert: New Build Breakage: aosp-master/aosp_arm64_ab-userdebug @ 4376965

Change-Id: Ibe4b819c4292457c454bf42e6d94fba3071ec04b
2017-10-04 21:07:42 +00:00
Jeff Gaston 2370af0e23 Some clarifications in preparation to automatically order linker dependencies
Test: Browse the code and determine whether it's easier to understand
Bug: 66260943
Change-Id: Ia3fdb8f38e83ad8225a72c8de2804db23a90ef9b
2017-10-03 17:18:01 -07:00
Dan Willemsen 4f1c3d4116 Add support for Windows Message Compiler
We've only got one user of this currently, but since it needs the
location of the toolchain, and different flags based on 32 vs 64-bit,
it's easier just to add support than to get this into a genrule.

Test: Convert external/mdnsresponder to Soong, build
Change-Id: I6c19a82bc14f6ab556f6cc5f37164862ba5f9083
2017-09-09 13:06:25 -07:00
Jayant Chowdhary af6eb71ad2 Allow apis from exported shared library headers as well, while dumping abi.
header-abi-diff has switched to recursive diffing of types and can
diff more accurately if types included in re-exported shared library
headers are included as well.

Bug: 62060883

Test: make -j64, android.hardware.light@2.0.so.lsdump contains structs
from libcutils as well (libcutils' headers are re-exported by
android.hardware.light@2.0)

Change-Id: I814819e4f7258b4b380350fe8ad0ccf8dbd5ce5c
2017-08-24 16:48:25 -07:00
Dan Willemsen 1d3e545a97 Add dependency support for yasm
Bug: 37719672
Test: lunch aosp_x86-eng; m native
Test: m out/soong/.intermediates/external/libvpx/libvpx/android_x86_static_core/obj/external/libvpx/libvpx/vp8/common/x86/copy_sse2.o
Test: NINJA_ARGS="-t deps out/soong/.intermediates/external/libvpx/libvpx/android_x87_static_core/obj/external/libvpx/libvpx/vp8/common/x86/copy_sse2.o" m
Change-Id: I01763b5870f994f7f0c6ac9d10f112f73addd7c7
2017-08-22 21:02:08 -07:00
Jayant Chowdhary 6ab3d846b2 Add header-abi-linker dependency on so file.
Whenever a symbol file is not available, header-abi-linker can look at
the symbols with STV_DEFAULT or STV_PROTECTED visibility for further abi
filtering.

Bug: 62463617

Bug: 62307940

Test: make -j64

Change-Id: I5dc618be104a49d47375d37cf78c4490b1529987
2017-06-27 11:19:10 -07:00
Jayant Chowdhary 9677e8c6ad Black-list for clang LibTooling Cflags.
Add a list of flags which are not understood by clang LibTooling tools
and filter them out of the Cflags the tools are invoked with.

Test: In frameworks/av, make libmedia vendor_available (this invokes
header-abi-dumper on this module), mm -j64.

Bug: 62447349

Change-Id: I46f017212b89f4331145c999103d0ed44da0abaf
2017-06-19 19:43:03 -07:00
Jayant Chowdhary 715cac3971 Optimizations to abi checking.
We now add export_static_lib_headers, export_generated_headers to the
filters while dumping the abi of a library using header-abi-dumper
(through -I<dir> additions to the invocation of header-abi-dumper and
header-abi-linker)

Also add support for zipped reference source based abi dumps.

Test: mm -j64 in hardware/interfaces/nfc/default/1.0 produces
android.hardware.nfc@1.0.so.lsdump with abi filtered out using generated
headers.

Test: Copied the linked abi dumps produced by mm -j64 in bionic/libc to
prebuilts/abi-dumps/ndk and gzipped them. Ran mm -j64 again in
bionic/libc and verified header-abi-diff getting invoked.

Bug: 32750600

Change-Id: I26210af908c87a6143e39fa25f50307acb68a387
2017-05-25 14:46:58 -07:00
Jayant Chowdhary f54e0a79e2 Add arch, lib name to header-abi-diff invocation.
Test: mm -j64 in platform/bionic, platform/system/core/liblog.

Bug: 38325544

Change-Id: Ia2098c1facf2999ef51d55212acc1317e2bf98c1
2017-05-22 10:54:23 -07:00
Colin Cross 67a5c132c5 Prettify soong ninja build descriptions
Descriptions currently look like:
[  0% 4/29328] cc out-soong/.intermediates/external/clang/lib/Sema/libclangSema/android_arm_armv7-a-neon_denver_static_core/obj/external/clang/lib/Sema/SemaCodeComplete.o

This is not very helpful - most of the characters are used to show the
output path, which contains useful information like target architecture,
but also contains most of the path to the source files twice, and less
useful information like the exact variant name used by soong.
Make the descriptions look like:
[  0% 3/29329] //external/clang/lib/Sema:libclangSema clang++ SemaTemplateInstantiate.cpp

This is //path/to/module:modulename tool relative/path/to/source/file

Test: builds, looks pretty
Change-Id: I3087aa7d4eb1860ef6239d77407b8b35445616d7
2017-05-10 11:04:16 -07:00
Colin Cross 5b52959c99 Use ctx.ModuleBuild for darwin ar
Test: builds
Change-Id: If90975c8545158012bc6201acadd136363c21260
2017-05-09 14:32:45 -07:00
Colin Cross 2a252bef50 Support .rs and .fs files in cc_* module srcs lists
Translate .rs and .fs files to .cpp files using llvm-rs-cc.

Test: builds
Change-Id: I242cea0d09c9985730a512cec7705c3f1479f4ed
2017-05-05 18:22:30 -07:00
Jayant Chowdhary 918b1d9105 Fix lots of warnings from abi dumping.
Also fix ndk libraries are always re-building. Fix this by having the
build system know the report's file path. This will need to be changed
once we go off "advisory mode" to keep the report if builds fail on abi
breakages.

Bug: 37451651

Bug: 37450828

Test: mm -j64 in bionic/libc produces abi-dumps without warning:
argument unused during compilation: '-Wa,--noexecstack'

Test: cd system/core/init; mma -j;  NINJA_ARGS="-d explain" mma -j; The
second mma does not show a dirty libc.so.

Change-Id: I824723fd9e76586831ee2278db0b61329b1475c0
2017-04-18 10:50:31 -07:00
Jayant Chowdhary 3e231fd8bd Add header-abi-checker for Vndk abi checks.
header-abi-dumper: dumps abi exported by source files for Vndk.
header-abi-linker: links abi dumps produced by header-abi-dumper.
header-abi-diff: compares linked dumps.

Test: mm -j64 showcommands > make_log in bionic/libc.
      This produced linked dumps in out/soong/.intermediates.
      Copied these dumps to
      prebuilts/abi-dumps/ndk/current/arm64/source-based/.
      Changed the abi and re-ran mm -j64 showcommands > make_log
      confirmed that the build reported compatibility breakge without
      actually failing (advisory mode).

Change-Id: Iccad6908fe68a80f47230751671d156893b96ead
2017-04-14 19:48:10 -07:00
Colin Cross c31994825a Fix include order
Include order should be module includes, dependency exported includes,
and then global includes.  Module includes and global includes are
computed during compileFlags, but dependency exported includes are
not handled until later.  Move the global includes into a new
flags variable so that the dependency includes can be appended
to the module includes.

Test: m -j native
Change-Id: Ifc3894f0a898a070d6da8eed4f4b9e8cc0cd2523
2017-03-31 00:48:53 +00:00
Nan Zhang 43a485cfb1 Removed unused return variables.
Sometimes it is confused that these variables are mixed with ninja
parameters when invoking pctx.AndroidStaticRule()/SourcePathVariable().

Test: m -j
Change-Id: Ibcf17eeed6ac79aafaa5edeec27427721b36e75a
2017-03-27 14:27:58 -07:00
Vishwath Mohan 83d9f71cc5 Allow custom ar flags to be set.
Adds the ability to set custom flags for ar in Soong, similar to how
they can currently be set for make.

Bug: 36290748
Test: sanitize.go is able to correct set custom ar flags for CFI. CFI
enabled Soong components build and boot without issue.

Change-Id: I3212793aa84ba51df910c184d8bb376b3650376e
2017-03-16 14:06:30 -07:00
Dan Willemsen 581341d4f2 Native Coverage support in Soong (gcov)
This is configured the same as make -- a global NATIVE_COVERAGE=true
flag to allow native coverage, then COVERAGE_PATHS=path1,path2,... to
turn it on for certain paths.

There are .gcnodir files exported to Make and saved in $OUT/coverage/...
files which are `ar` archives containing all of the compiler-produced
.gcno files for a particular executable / shared library.

Unlike the Make implementation, this only passes links the helper
library (automatically through --coverage) when one of the object files
or static libraries being used actually has coverage enabled.

Host support is currently disabled, since we set -nodefaultlibs, which
prevents libclang_rt.profile-*.a from being picked up automatically.

Bug: 32749731
Test: NATIVE_COVERAGE=true COVERAGE_PATHS=system/core/libcutils m -j libbacktrace libutils tombstoned
      $OUT/coverage/system/lib*/libcutils.gcnodir looks correct (self)
      $OUT/coverage/system/lib*/libbacktrace.gcnodir looks correct (static)
      $OUT/coverage/system/lib*/libutils.gcnodir doesn't exist (shared)
      $OUT/coverage/system/bin/tombstoned.gcnodir looks correct (executable)
Test: NATIVE_COVERAGE=true COVERAGE_PATHS=external/libcxxabi m -j libc++
      Confirm that $OUT/coverage/system/lib*/libc++.gcnodir looks correct (whole_static_libs)
Change-Id: I48aaa0ba8d76e50e9c2d1151421c0c6dc8ed79a9
2017-02-14 13:05:48 -08:00
Colin Cross 7a7cf97597 Fix mac build
Darwin doesn't support --start-group/--end-group, and groups
libraries anyways.

Test: m -j
Change-Id: I0fdbe24973cad3cd84164cdfeced2507a4c6ee91
2016-12-06 02:52:43 +00:00
Dan Willemsen e1240db6ab Support aidl cpp generation
Ideally we'd calculate the headers that are written here too, but I'll
add that in a later change that actually enforces the generated header
list.

Test: mmma -j system/tools/aidl
Change-Id: Ifd2e8e8ff444b0f67270fb5156e7bf7bceddb6be
2016-12-05 15:49:40 -08:00
Colin Cross 91e9004086 Support .asm files for assembly
Test: mmma -j external/libjpeg-turbo
Change-Id: Id192dae5d74ecbf500fc668931c37f9b91d25ca4
2016-12-02 21:12:30 -08:00
Colin Cross 18c0c5afbd Support grouping static libraries
LLVM has complicated static library layering that sometimes changes.
The make solution was to list all the static libraries twice, but
Soong dedups the list.  Add a group_static_libs flag to allow
surrounding the static libs with -Wl,--start-group and
-Wl,--end-group.

Test: mmma -j external/llvm
Change-Id: Ic08a183d7def9c9249d4a3014760759f16b68d04
2016-12-02 21:34:42 +00:00
Colin Cross 9978ffe347 Support .mm files
libchrome uses Objective C++ (.mm) files, treat them like .cc files
and pass them to g++/clang++.

Test: mmma -j external/libchrome
Change-Id: Ib9e5e82d8a9eff5f80a9fe06498a988d70ca4553
2016-12-01 15:33:16 -08:00
Dan Willemsen 21ec49068f Add subdir to GenPath
We were emulating this for proto files, standardize it and make the
other generators use it as well.

Test: Compare out/soong/build.ninja before/after change
Test: mmma -j system/tools/hidl
Change-Id: I1888c7b981749060a398387bbb9b481270bf6d75
2016-11-02 21:19:11 -07:00
Dan Willemsen a03cf6d322 Add clang-tidy support
For every file which we can run clang-tidy (C/C++ clang-built), we add a
new build node that depends on the object file (since clang-tidy does
not export a depfile), and is depended on by the link step. This is
better than how we're doing it in make, since calling tidy can be turned
on or off without needing to rebuild the object files.

This does not attempt to port WITH_TIDY_ONLY from Make, since the way
that it works is broken (due to the lack of a depfile).

Bug: 32244182
Test: WITH_TIDY=true mmma -j bionic/libc
Test: ./soong (Setting ClangTidy: true)
Change-Id: I40bbb5bb00d292d72bf1c293b93080b5f9f6d8ea
2016-10-31 16:21:01 -07:00
Dan Willemsen 5cb580f407 Start using "struct Objects" to store object Paths
So that we can represent other files that get generated along with the
objects, like the gcno coverage information, and per-file clang-tidy
runs.

Test: Soong's build.ninja identical before/after
Change-Id: I5c553a153c436d5403549f62c73fe79c5f101779
2016-10-31 16:18:49 -07:00
Colin Cross 0c461f1f6e Add support for .proto files
.proto files are translated to .pb.cc and .pb.h files, which are then
compiled normally.

Bug: 32286026
Test: mmma -j system/extras/perfprofd
Change-Id: I538071424d667aacf35b4b8bfebe217f5f092726
2016-10-27 15:28:09 -07:00