From de34d2375f9cde8ec6c29a8af490775692d7d889 Mon Sep 17 00:00:00 2001 From: Jooyung Han Date: Thu, 23 Jul 2020 13:04:15 +0900 Subject: [PATCH] Fix __ANDROID_SDK_VERSION__=0 __ANDROID_SDK_VERSION__ for a cc module means API level of which the module should work with. For APEX variants, it should be apex.min_sdk_version and tracked by the variable cc.Module.apexSdkVersion. The variable was set in the wrong place and used uninitialized sometimes, which results __ANDROID_SDK_VERSION__=0. Bug: n/a Test: m Test: checked build.ninja manually => no __ANDROID_SDK_VERSION__=0 Change-Id: Iba532b2c62773983414a061f5291a73363322487 --- cc/cc.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/cc/cc.go b/cc/cc.go index fdf28799c..57fe9ba9c 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -2215,6 +2215,19 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { depPaths.ReexportedGeneratedHeaders = append(depPaths.ReexportedGeneratedHeaders, exporter.exportedGeneratedHeaders()...) } + // For the dependency from platform to apex, use the latest stubs + c.apexSdkVersion = android.FutureApiLevel + if !c.IsForPlatform() { + c.apexSdkVersion = c.ApexProperties.Info.MinSdkVersion + } + + if android.InList("hwaddress", ctx.Config().SanitizeDevice()) { + // In hwasan build, we override apexSdkVersion to the FutureApiLevel(10000) + // so that even Q(29/Android10) apexes could use the dynamic unwinder by linking the newer stubs(e.g libc(R+)). + // (b/144430859) + c.apexSdkVersion = android.FutureApiLevel + } + ctx.VisitDirectDeps(func(dep android.Module) { depName := ctx.OtherModuleName(dep) depTag := ctx.OtherModuleDependencyTag(dep) @@ -2303,19 +2316,6 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { } } - // For the dependency from platform to apex, use the latest stubs - c.apexSdkVersion = android.FutureApiLevel - if !c.IsForPlatform() { - c.apexSdkVersion = c.ApexProperties.Info.MinSdkVersion - } - - if android.InList("hwaddress", ctx.Config().SanitizeDevice()) { - // In hwasan build, we override apexSdkVersion to the FutureApiLevel(10000) - // so that even Q(29/Android10) apexes could use the dynamic unwinder by linking the newer stubs(e.g libc(R+)). - // (b/144430859) - c.apexSdkVersion = android.FutureApiLevel - } - if depTag == staticUnwinderDepTag { // Use static unwinder for legacy (min_sdk_version = 29) apexes (b/144430859) if c.apexSdkVersion <= android.SdkVersion_Android10 {