Commit graph

114 commits

Author SHA1 Message Date
Chih-Hung Hsieh
f6ca1b961b object files depend only on NDK headers
* shared libraries and binaries can depend on NDK share libraries

Bug: 208310402
Test: WITH_TIDY=1 make tidy-soong
Test: WITH_TIDY=1 make droid
Change-Id: I88ca8555c62d5ca49e36ca089749722166afec30
2021-12-05 18:10:13 -08:00
Chih-hung Hsieh
4dceb3705f Merge "Do not add .tidy files as RBE link inputs" 2021-10-27 20:29:04 +00:00
Liz Kammer
e6583482a8 bp2build: Handle export_generated_header property
The generated_header property resides in BaseCompilerProperties, while
export_generated_header resides in BaseLinkerProperties. Previously
bp2build handled these property structs separately; however, these two
related properties residing in separate structs requires restructuring
the code to allow access to both BaseCompilerProperties and
BaseLinkerProperties for a single axis/configuration combination to
resolve which generated headers are exported/not for the
axis/configuration..

Test: go test soong tests
Test: build/bazel/ci/bp2build.sh
Change-Id: Id150003637fd19d87e8dc5d6941e9f36dc4031dd
2021-10-26 15:10:41 -04:00
Chih-Hung Hsieh
3bb934f0ad Do not add .tidy files as RBE link inputs
* RBE adds implicit dependent files as inputs
  and creates too long commands.
* Adds .tidy files as validation paths.
* Change type of tidyFiles to WritablePaths.

Bug: 203577539
Test: lunch aosp_cf_arm64_phone-userdebug; USE_RBE=true WITH_TIDY=1 make
Test: USE_RBE=true WITH_TIDY=1 mm in external/skia
Change-Id: I5fc9d6f8c9c58abcd3721ca9fbae1bc785e4e609
2021-10-25 12:24:30 -07:00
Liz Kammer
2b8004b1ef bp2build: Add support for cc_binary.
Bug: 197920036
Test: build/bazel/ci/bp2build.sh
Change-Id: I2c4200967653af15a330ab8cbaf796b70d43f32d
2021-10-19 14:12:39 -04:00
Colin Cross
a793db33a2 Support static_executable: true for musl builds
Bug: 190084016
Test: aosp-build-tools linux_musl build
Change-Id: I630c54033c44ddd6b54388ed36642629cf2e4e5b
2021-08-24 13:39:02 -07:00
Colin Cross
450744e718 Use SystemSharedLibs as StaticLibs for static executables
Shared libraries are ignored for static executables, treat
SystemSharedLibs as StaticLibs to avoid every static executable
having to list libc as a static dependency.

Test: m checkbuild
Change-Id: I02442a1a2a8d4164ec3dd389a16da2346e2d8751
2021-08-24 13:39:02 -07:00
Colin Cross
528d67e523 Reland "Split the x86 host toolchain into glibc and musl variants"
Split the x86 host toolchain into glibc and musl variants

Create new musl toolchains that are based on the existing glibc
toolchains, and add the necessary flags for musl compiles.

This relands Ifc02f9e5afa61ff758be98b0c962f3a4b53d0546 with changes
for I46672e3a096b6ea94ff4c10e1c31e8fd010a163c.

Bug: 190084016
Change-Id: Iaa9f7a50ff601155ecd73acc5701a2c226be66dc
Test: TestArchMutator
2021-07-23 22:25:36 +00:00
Colin Cross
5d6904e1cf Revert "Split the x86 host toolchain into glibc and musl variants"
This reverts commit 4fb4ef2242.

Reason for revert: crossed with aosp/1775072

Change-Id: Ied922850b810d82627ba4f9ee42f672cfe286c91
2021-07-23 22:20:29 +00:00
Colin Cross
4fb4ef2242 Split the x86 host toolchain into glibc and musl variants
Create new musl toolchains that are based on the existing glibc
toolchains, and add the necessary flags for musl compiles.

Bug: 190084016
Test: TestArchMutator
Change-Id: Ifc02f9e5afa61ff758be98b0c962f3a4b53d0546
2021-07-23 08:57:17 -07:00
Colin Cross
cb0ac95bde Remove Fuchsia support from Soong
Bug: 194215932
Test: m checkbuild
Change-Id: Id7d3964d9417f8b0938af9b168bb4c00cebe9390
2021-07-21 20:37:46 -07:00
Liz Kammer
187d5445e8 Remove IsDependencyRoot from interface
This is equivalent to Binary() -- reduce the interface and improve
clarity.

Test: go test soong tests
Change-Id: I770f5ce79fd4d888586d31ec5e67be88153626b6
2021-07-07 16:29:09 -04:00
Colin Cross
d1a2813063 Move default crt objects into Toolchain
Move the crt objects spread around cc/library.go and cc/binary.go
into the Toolchain.  This will simplify adding new toolchains that
have custom crt objects.

Test: m checkbuild
Test: go test ./cc/...
Change-Id: I7fdc1f53769799cb9c10e3e5816dabee0f918768
2021-06-22 16:54:40 -07:00
Colin Cross
9cfe6119fe Use a linker script for host bionic embedded linker sections
Use an implicit linker script instead of flags in a file to specify
the locations of the host bionic embedded linker and to prevent it
from being stripped.

Test: build and run host bionic binary
Change-Id: I64e12118d33c67bab5e657cbc3ea8cde8f0fd7e6
2021-06-11 18:02:22 -07:00
Colin Cross
c465efd5d4 Support multiple CrtBegin and CrtEnd files
Host bionic will use multiple files for CrtBegin, make CrtBegin and
CrtEnd Paths instead of OptionalPath.

Test: go test ./build/soong/cc/...
Change-Id: Ie2e954cd87808a903617696da443009f6173e312
2021-06-11 18:00:04 -07:00
Colin Cross
f04eb99acc Stop injecting symbols into host bionic binaries
The host bionic bootstrapping no longer needs an injected symbol.
Replace host_bionic_inject with host_bionic_verify that validates
the resulting binary, and add it as a validation dependency of the
binary.

Test: build and run host bionic binary
Change-Id: I3e303d2a164b6eef851bdc8075e6ee456c05b0a8
2021-06-11 15:22:41 -07:00
Liz Kammer
356f7d45c1 bp2build: convert paths/module refs to Bazel label
This currently expands all globs, still need to support converting glob
syntax.

Test: go build_conversion_test
Test: GENERATE_BAZEL_FILES=true m nothing
Test: m nothing
Bug: 165114590
Change-Id: If7b26e8e663d17566fad9614ca87a8da1f095284
2021-02-04 13:45:56 -05:00
Jaewoong Jung
18aefc1977 Remove unnecessary snake case variables.
Test: m nothing + TreeHugger
Change-Id: I99f7162944daa6c57c6ae4763261e108bb5cb6b1
2020-12-22 12:38:35 -08:00
Chris Parsons
bf4f55f180 Improve commenting for cc/builer.go, and kill dead code
Test: m nothing
Change-Id: I836c717d3243e901257120be71246e419de4d28e
2020-12-01 18:28:38 -05:00
Chris Parsons
e0f2ab3f3c Improve commenting of cc/binary.go.
Test: N/A
Change-Id: If4a1be0a0f111cd08fc1e8762702c32115562cf1
2020-11-20 17:27:25 -05:00
Colin Cross
a615901b53 Use the the preferred architecture symlink as the tool path if it exists
When a genrule uses a binary with symlink_preferred_arch set as a tool,
use the symlink instead of the binary as the tool, as the symlink is
the more canonical name for the binary.

Test: m checkbuild
Change-Id: I5330b57139f03ca07bf70547261f191ed84ec9b8
2020-11-14 14:38:34 -08:00
Yifan Hong
60e0cfb5cb Add vendor-ramdisk image to Soong.
Add vendor_ramdisk_available and vendor_ramdisk attribute to
various rules. When a vendor_ramdisk variant of a module is
generated, it is installed to $OUT/vendor-ramdisk.

It is similar to a ramdisk image.
Test: m nothing -j

Change-Id: Ib2d16459f3094dbe21c3bdb7c016cb4b2bf62765
2020-10-22 10:26:26 -07:00
Colin Cross
56a8321c21 Remove global state from apex modules
A global variant was used to store the global mapping between
modules and APEXes.  Replace it with storing pointers to APEX
contents inside each module so that they can query the contents
of any APEXes they belong to.

Bug: 146393795
Test: all Soong tests
Test: single line change to build.ninja host install dependency ordering
Test: no Android-${TARGET_PRODUCT}.mk, make_vars-${TARGET_PRODUCT}.mk or late-${TARGET_PRODUCT}.mk
Change-Id: Id2d7b73ea27f8c3b41d30820bdd86b65c539bfa4
2020-10-06 13:39:57 -07:00
Thiébaud Weksteen
d458745f15 cc: export Stripper struct
The cc stripping logic can be reused for Rust. Export the Stripper
structure for that purpose. Extract the strip-related flags from
builderFlags into StripFlags. Add the method flagsToStripFlags
(similarly to flagsToBuilderFlags).

Add the helper method disableStripping on libraryDecorator.

Test: m
Bug: 153430439
Change-Id: I11aef1abb8d498a4c1672500a7398279edf7f548
2020-08-27 10:13:42 +02:00
Jiyong Park
89f7bf1635 bootstrap is added for cc_binary only when the module is in an APEX
Like shared libraries, the bootstrap subdirectory is appended to the
install path only when the module is in an APEX. Currently, this change
doesn't make any difference because only the Bionic binary (linker) is
satisfying the existing condition InstallToBootstrap() and it already
satisfies DirectlyInAnyApex.

However, this change makes a diference when we build the binary for the
host targets. Then without this change, it is installed to
out/soong/host/<OS>-<arch>/bin/bootstrap. This doesn't make sense
because we don't use APEXes for the host targets. With this change,
the binary is correctly installed to out/soong/host/<OS>-<arch>/bin
because DirectlyInAnyApex returns false for hosts.

Bug: 159685774
Test: m
Change-Id: I0d63bd8c11e3a96ee6a27b2295bc14d6dc15ff9e
2020-08-25 18:57:39 +09:00
Colin Cross
e07f2316b7 Rename ApexName to ApexVariationName
In preparation for reusing the same variation for multiple apexes,
rename ApexName to ApexVariationName.

Bug: 164216768
Test: all soong tests
Change-Id: I88f2c5b192ffa27acd38e01952d0cefd413222a0
2020-08-13 17:50:29 -07:00
Dan Albert
92fe740677 Stop using prebuilt NDK CRT objects.
We don't need the prebuilt versions. The NDK CRT objects are (now)
built from the platform sources and the only difference is that the
NDK CRT objects also include an ELF note that identifies the NDK
version, which isn't helpful for anything built by the platform.

Add a `crt` property to cc_object that allows CRT objects to identify
themselves. CRT objects, unlike other modules, will have a variant
built per-API level they support, rather than just an SDK variant and
a platform variant. This is needed because new CRT objects will rely
on APIs not available in old libcs and old CRT objects will not
support all the features of a modern one.

Test: treehugger
Bug: http://b/159925977
Change-Id: I6595485fa1bfe0ad4945193d344b863f64eec654
2020-08-11 15:06:55 -07:00
Jingwen Chen
40fd90ae52 Support multiple dists per Android.bp module, and dist output selection.
This CL adds "dists" to the base property struct to support multiple
dist file configurations, and generic tag support to dist tagged outputs
of modules.

Fixes: b/152834186
Test: soong tests and `m sdk dist`

Change-Id: I80c86bc9b7b09e671f640a4480c45d438bdd9a2a
Signed-off-by: Jingwen Chen <jingwen@google.com>
2020-06-25 12:42:07 +00:00
Inseob Kim
7f283f4bd0 Refine logic choosing vendor snapshot modules
This refines the vendor snapshot codes in order to fix logic errors.

- Capture toolchain_library and cc_library_headers correctly.
- Redirect unwind static library correctly.
- Filter out sanitize / coverage / lto by looking at HideFromMake.
- Add binary() function for clear and shorter codes.
- Include test modules.
- Add more tests to prevent further snapshot breakages.

Bug: 157106227
Test: m vendor-snapshot
Test: m nothing for all available targets
Test: EMMA_INSTRUMENT=true EMMA_INSTRUMENT_FRAMEWORK=true \
NATIVE_COVERAGE=true COVERAGE_PATHS="*" m nothing

Change-Id: Id90082b5ab730f928582ad24f022ba410855400e
Merged-In: Id90082b5ab730f928582ad24f022ba410855400e
(cherry picked from commit 4d8d8fec4a)
2020-06-05 04:25:40 +00:00
Paul Duffin
25ce04bd3a Add support for cc_binary in module_exports
Bug: 142920869
Test: m nothing
Change-Id: Ib7e16cb323806782c2186e73e13642e4485fc149
2020-02-18 16:17:35 +00:00
Yifan Hong
1b3348d50a Add ramdisk image.
It is similar to recovery image.
Test: m nothing -j

Change-Id: I11389777c6bfb0c0d73bbb4c70091c1e70f44077
2020-01-22 16:54:18 -08:00
Paul Duffin
2ee6979443 Dedup cc binary build components registration
Bug: 146540677
Test: m nothing

Change-Id: I1c677d0ee2cead1d61f81e34e8d5a2f4a52f6cad
2020-01-16 14:10:18 +00:00
Colin Cross
4af21ed26f Split local and global cflags
Native compiler flags are currently applied in approximately:
global cflags
local cflags
local include dirs
global include dirs
global conlyflags
local conlyflags
global cppflags
local cppflags

This means that a flag that is enabled in the global cppflags
cannot be disabled in the local cflags, and an Android.bp author
must know to disable it in the local cppflags.  A better order
would be:
global cflags
global conlyflags
global cppflags
local cflags
local conlyflags
local cppflags
local include dirs
global include dirs

We are mixing both the global and local cflags into a single
variable, and similar for conlyflags and cppflags, which
prevents reordering them.  This CL prepares to reorder them
by splitting the global and local cflags into separate variables.

Bug: 143713277
Test: m native
Change-Id: Ic55a8c3516c331dc5f2af9d00e59ceca9d3e6c15
2019-11-07 15:27:58 -08:00
Ryan Prichard
b49fe1bde7 Stop linking libdl.a into static bins
libdl.a has a no-op dlopen, which breaks static libraries that need a real
dlopen. Instead of automatically linking libdl.a into static executables,
make it optional.

Until recently, the libunwind_llvm.a unwinder, used on arm32, needed the
no-op dladdr, but it's now built using -D_LIBUNWIND_USE_DLADDR=0.

The HWASan run-time uses dlsym and dladdr, so add a libdl dependency for
HWASan-built static binaries. We could also remove the dependency from
libclang_rt.hwasan_static-*.a, but this is also easy to do.

Bug: http://b/141485154
Test: bionic unit tests, device boots, verify that static and dynamic
   executables can throw/catch an exception
Test: verify that a static executable using dlopen doesn't link (unless it
   adds an explicit dependency on libdl)

Change-Id: Ic52c3f336b671b4ed335e99c94a64dfe8614b618
2019-10-24 22:25:54 -07:00
Colin Cross
3b19f5d71d Remove old-style support for translated second architectures
Translated second architectures now go in NativeBridgeArch instead
of DeviceSecondaryArch.

This reapplies I568046330abc002d4eed582cb999b62a5eaba790 with
ctx.Config().HasMulitlibConflict() added to fix the NDK build,
which has arm64, arm, x86_64, and x86 architectures enabled.

Test: m checkbuild
Test: OUT_DIR=out_ndk build/soong/scripts/build-ndk-prebuilts.sh
Test: no change to build.ninja or Android-aosp_cf_x86_phone.mk
Change-Id: Iadcafbd64bfb9579ae7c86914927c43a062b0c8e
2019-09-19 12:54:32 -07:00
Martin Stjernholm
279de572d7 Treat libclang_rt.hwasan-* the same way as the other Bionic bootstrap libs.
Ensure that it ends up in the bionic/ subdir in the Runtime APEX and is
symlinked from /system/lib(64). That makes it available in the default
(platform) linker namespace and no longer requires it to be accessible
through the runtime namespace. All this makes it consistent with how the
other Bionic libs are handled, and avoids the need for various special
cases in ld.config.txt files (to be cleaned up later).

With this there might no longer be a need for a linker namespace for the
Runtime APEX, and we could consider removing the kludge with the
/apex/com.android.runtime/${LIB}/bionic subdirectories and the special case
in getCopyManifestForNativeLibrary in apex.go. However, keeping it calls out
the special treatment of those libraries, and allows a namespace to be added
again if necessary.

Test: Build and boot on taimen_hwasan-userdebug
Test: adb shell /apex/com.android.art/bin/dexdump on taimen_hwasan-userdebug
Test: atest CtsCompilationTestCases on taimen_hwasan-userdebug
Bug: 140734238
Bug: 140790209
Change-Id: Ieb506bfa5d5c159db391273c7eba41d7909de286
2019-09-11 12:16:31 +01:00
Colin Cross
d7227f99eb Support boringssl hash injection on binaries and make it transitive
Move handling the inject_bssl_hash property to a helper function,
and also treat it as set if any static libraries have it set.

Bug: 137267623
Test: m checkbuild
Change-Id: Icb12cfffb20797c807b410daffbf7fcccb1b1975
2019-09-05 15:30:05 -07:00
Jiyong Park
ee9a98d88e Build native coverage variant of APEXes when needed
When the native coverage is enabled, APEXes (and files there) are built
for native coverage as well.

Bug: 138952487
Test: make -j NATIVE_COVERAGE=true COVERAGE_PATHS='*' com.android.resolv
find out -name "*.gcno" | grep DnsResolver shows files

Test: libnetd_resolv.zip is found under
$(TARGET_OUT)/apex/com.android.resolv/lib directory

Change-Id: I97bcee9bf8ffc0dc71453abbdb613ed56ea2cdb4
2019-08-13 08:55:08 +09:00
Jiyong Park
acbf6c76c6 Use ctx.Target().NativeBridge to detect if the arch is translated or not
Bug: 137015854
Test: m
Test: build cf_x86_phone and ensure there is no dangling symlink
/system/lib/arm/libm.so

Change-Id: I0f5efdb9e1f5e4e213ca4ebaa28ace0a130b36a6
2019-07-10 18:07:38 +09: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
Roland Levillain
d7607c1c99 Merge "Have symlink_preferred_arch: true honor the stem property." 2019-06-11 13:45:25 +00: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
Roland Levillain
9efb8c773f Have symlink_preferred_arch: true honor the stem property.
If a module defines a `stem` property, use it to name the symlink
created for `symlink_preferred_arch: true` (instead of the module's
name).

Also always require suffixes when using `symlink_preferred_arch: true`.

Test: m
Change-Id: Ia8a56f94d21599194797ef8b259f5f03e08cb16a
2019-06-10 15:03:44 +01: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
Roland Levillain
d9bf9be007 Allow arch-specific symlink_preferred_arch properties.
Test: m
Bug: 133864678
Change-Id: Ia6e62156adda2b3a51220552bbe4dab738753674
2019-06-05 19:38:45 +01:00
Ryan Prichard
f979d73428 Omit .gnu_debuglink sections in object files
I'm not sure if these sections are used, but by adding them to
libgcc_stripped.a, we can end up with multiple .gnu_debuglink sections in
an executable, where the first two unhelpfully point at "libgcc.a". e.g.:

$ readelf -SW -x.gnu_debuglink out/target/product/walleye/system/bin/bootstrap/linker64
...

Section Headers:
  ...
  [18] .gnu_debuglink    PROGBITS        0000000000000000 10f19c 000020 00      0   0  1
  ...
  [22] .gnu_debuglink    PROGBITS        0000000000000000 18a2c8 000010 00      0   0  4
  ...

Hex dump of section '.gnu_debuglink':
  0x00000000 6c696267 63632e61 00000000 3d5f65d8 libgcc.a....=_e.
  0x00000010 6c696267 63632e61 00000000 3d5f65d8 libgcc.a....=_e.

Hex dump of section '.gnu_debuglink':
  0x00000000 6c696e6b 65723634 00000000 f85db7ea linker64.....]..

Bug: none
Test: m libgcc_stripped linker
Test: no .gnu_debuglink section in libgcc_stripped.a
Test: only one .gnu_debuglink section in system/bin/bootstrap/linker64
Change-Id: I0c47a9acd6d52f5cbc5bfa8b67d072ebb075a242
2019-05-31 15:07:16 -07:00
Peter Collingbourne
3478bb2a7f Teach soong not to duplicate the HWASAN runtime into each APEX.
When HWASAN is enabled, the runtime is conceptually part of Bionic (and
mutually depends on it), so it needs to be treated in the same way as the
Bionic libs.

Now there are only two copies of the runtime: the one in
/system/lib64/bootstrap (which won't be used by ordinary processes) and the
one in the runtime APEX.

This reduces the size of the HWASAN system image and fixes an issue where
multiple copies of the HWASAN runtime were being loaded into 64-bit binaries in
APEXes because the linker namespace for the binary is different from the one
for its dependent libraries outside of APEXes. HWASAN only supports loading
one copy of the runtime per process, so this was causing such binaries to
crash on startup.

Change-Id: I228896e193a035e6dfba9f6e28d0b2e12fc163ea
2019-05-17 10:00:39 -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
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