From 72b8fcbbec330f2c9f0465a551be287fbe8101f7 Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Tue, 5 Sep 2023 23:02:27 +0000 Subject: [PATCH] Use ndk_system STL header library Soong currently adds -isystem prebuilts/ndk/current/sources/cxx-stl/system/include to modules that have ndk_system STL. This does not translate well to Bazel because of its stricter sandboxing constraints. In preparation for building sdk variants with Bazel, create an indirection where sdk variants that use this STL depend on a `ndk_system` header library module. This should be a no-op in Soong, but the resultant ninja files are not identical. (e.g diff https://diff.googleplex.com/#key=OOLtc1GFmDDF). The -isystem now appears _before_ the local cflags. However, this should be fine because we have a check in `CheckBadCompilerFlags` that bans use of -I/-isystem in user-provided cflags. Test: diff'd ninja file Test: TH Bug: 298258442 Change-Id: I8c4e2b66bb9ac25c44ceedd52298ba474a554a04 --- cc/stl.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cc/stl.go b/cc/stl.go index 8f92dcb40..a31a58508 100644 --- a/cc/stl.go +++ b/cc/stl.go @@ -172,6 +172,7 @@ func (stl *stl) deps(ctx BaseModuleContext, deps Deps) Deps { // The system STL doesn't have a prebuilt (it uses the system's libstdc++), but it does have // its own includes. The includes are handled in CCBase.Flags(). deps.SharedLibs = append([]string{"libstdc++"}, deps.SharedLibs...) + deps.HeaderLibs = append([]string{"ndk_system"}, deps.HeaderLibs...) case "ndk_libc++_shared", "ndk_libc++_static": if stl.Properties.SelectedStl == "ndk_libc++_shared" { deps.SharedLibs = append(deps.SharedLibs, stl.Properties.SelectedStl) @@ -219,8 +220,7 @@ func (stl *stl) flags(ctx ModuleContext, flags Flags) Flags { case "libstdc++": // Nothing case "ndk_system": - ndkSrcRoot := android.PathForSource(ctx, "prebuilts/ndk/current/sources/cxx-stl/system/include") - flags.Local.CFlags = append(flags.Local.CFlags, "-isystem "+ndkSrcRoot.String()) + // Nothing: The exports of ndk_system will be added automatically to the local cflags case "ndk_libc++_shared", "ndk_libc++_static": if ctx.Arch().ArchType == android.Arm { // Make sure the _Unwind_XXX symbols are not re-exported.