summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Android.bp15
-rw-r--r--cpu_ref/rsCpuExecutable.cpp28
-rw-r--r--cpu_ref/rsCpuScript.cpp7
-rw-r--r--cpu_ref/rsCpuScript.h3
-rw-r--r--tests/java_api/RsTest/AndroidTest.xml2
5 files changed, 52 insertions, 3 deletions
diff --git a/Android.bp b/Android.bp
index ae126b87..0b322487 100644
--- a/Android.bp
+++ b/Android.bp
@@ -54,6 +54,12 @@ cc_library_shared {
"libbcinfo",
],
+
+ product_variables: {
+ pdk: {
+ enabled: false,
+ },
+ },
}
// Build rsg-generator ====================
@@ -203,6 +209,9 @@ cc_library_shared {
override_rs_driver: {
cflags: ["-DOVERRIDE_RS_DRIVER=%s"],
},
+ pdk: {
+ enabled: false,
+ },
},
}
@@ -235,6 +244,12 @@ cc_library_shared {
"libandroid_runtime",
],
+ product_variables: {
+ pdk: {
+ enabled: false,
+ },
+ },
+
static_libs: ["libRSDispatch"],
version_script: "libRS.map",
diff --git a/cpu_ref/rsCpuExecutable.cpp b/cpu_ref/rsCpuExecutable.cpp
index 83ef7574..c42ea0fd 100644
--- a/cpu_ref/rsCpuExecutable.cpp
+++ b/cpu_ref/rsCpuExecutable.cpp
@@ -94,6 +94,22 @@ static std::string findSharedObjectName(const char *cacheDir,
return scriptSOName;
}
+#ifndef RS_COMPATIBILITY_LIB
+static bool isRunningInVndkNamespace() {
+ static bool result = []() {
+ Dl_info info;
+ if (dladdr(reinterpret_cast<const void*>(&isRunningInVndkNamespace), &info) != 0) {
+ std::string filename = std::string(info.dli_fname);
+ return filename.find("/vndk-sp") != std::string::npos;
+ } else {
+ ALOGW("Can't determine whether this lib is running in vndk namespace or not. Assuming it is in vndk namespace.");
+ }
+ return true;
+ }();
+ return result;
+}
+#endif
+
} // anonymous namespace
const char* SharedLibraryUtils::LD_EXE_PATH = "/system/bin/ld.mc";
@@ -121,16 +137,24 @@ bool SharedLibraryUtils::createSharedLibrary(const char *driverName,
linkDriverName.erase(linkDriverName.length() - 3);
linkDriverName.replace(0, 3, "-l");
- const char *compiler_rt = SYSLIBPATH"/libcompiler_rt.so";
+ const char *compiler_rt = isRunningInVndkNamespace() ?
+ SYSLIBPATH_VNDK "/libcompiler_rt.so" : SYSLIBPATH "/libcompiler_rt.so";
const char *mTriple = "-mtriple=" DEFAULT_TARGET_TRIPLE_STRING;
const char *libPath = "--library-path=" SYSLIBPATH;
+ // vndk path is only added when RS framework is running in vndk namespace.
+ // If we unconditionally add the vndk path to the library path, then RS
+ // driver in the vndk-sp directory will always be used even for CPU fallback
+ // case, where RS framework is loaded from the default namespace.
+ const char *vndkLibPath = isRunningInVndkNamespace() ?
+ "--library-path=" SYSLIBPATH_VNDK : "";
const char *vendorLibPath = "--library-path=" SYSLIBPATH_VENDOR;
+ // The search path order should be vendor -> vndk -> system
std::vector<const char *> args = {
LD_EXE_PATH,
"-shared",
"-nostdlib",
- compiler_rt, mTriple, vendorLibPath, libPath,
+ compiler_rt, mTriple, vendorLibPath, vndkLibPath, libPath,
linkDriverName.c_str(), "-lm", "-lc",
objFileName.c_str(),
"-o", sharedLibName.c_str(),
diff --git a/cpu_ref/rsCpuScript.cpp b/cpu_ref/rsCpuScript.cpp
index cf1b869f..cb13b114 100644
--- a/cpu_ref/rsCpuScript.cpp
+++ b/cpu_ref/rsCpuScript.cpp
@@ -108,7 +108,13 @@ static void setCompileArguments(std::vector<const char*>* args,
// Only load additional libraries for compiles that don't use
// the debug context.
if (bccPluginName && strlen(bccPluginName) > 0) {
+#ifdef __ANDROID__
+ // For Android, -plugin option must be used in order to load the
+ // vendor plugin from the sphal namespace.
+ args->push_back("-plugin");
+#else
args->push_back("-load");
+#endif
args->push_back(bccPluginName);
}
}
@@ -156,6 +162,7 @@ static bool compileBitcode(const std::string &bcFileName,
// reinstalled, which would already clear the code_cache/ directory.
bool isChecksumNeeded(const char *cacheDir) {
if ((::strcmp(SYSLIBPATH, cacheDir) == 0) ||
+ (::strcmp(SYSLIBPATH_VNDK, cacheDir) == 0) ||
(::strcmp(SYSLIBPATH_VENDOR, cacheDir) == 0))
return false;
char buf[PROP_VALUE_MAX];
diff --git a/cpu_ref/rsCpuScript.h b/cpu_ref/rsCpuScript.h
index dc96f8ba..bd192ab1 100644
--- a/cpu_ref/rsCpuScript.h
+++ b/cpu_ref/rsCpuScript.h
@@ -157,14 +157,17 @@ uint32_t constructBuildChecksum(uint8_t const *bitcode, size_t bitcodeSize,
#ifdef __LP64__
#define SYSLIBPATH "/system/lib64"
+#define SYSLIBPATH_VNDK "/system/lib64/vndk-sp"
#define SYSLIBPATH_BC "/system/lib64"
#define SYSLIBPATH_VENDOR "/system/vendor/lib64"
#elif defined(BUILD_ARM_FOR_X86) && defined(__arm__)
#define SYSLIBPATH "/system/lib/arm"
+#define SYSLIBPATH_VNDK "/system/lib/arm/vndk-sp"
#define SYSLIBPATH_BC "/system/lib"
#define SYSLIBPATH_VENDOR "/system/vendor/lib/arm"
#else
#define SYSLIBPATH "/system/lib"
+#define SYSLIBPATH_VNDK "/system/lib/vndk-sp"
#define SYSLIBPATH_BC "/system/lib"
#define SYSLIBPATH_VENDOR "/system/vendor/lib"
#endif
diff --git a/tests/java_api/RsTest/AndroidTest.xml b/tests/java_api/RsTest/AndroidTest.xml
index 7db6f8bc..0a276087 100644
--- a/tests/java_api/RsTest/AndroidTest.xml
+++ b/tests/java_api/RsTest/AndroidTest.xml
@@ -20,7 +20,7 @@
<option name="test-suite-tag" value="apct" />
<option name="test-tag" value="RSTest" />
- <test class="com.android.tradefed.testtype.InstrumentationTest" >
+ <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
<option name="package" value="com.android.rs.test" />
<option name="runner" value="android.support.test.runner.AndroidJUnitRunner" />
</test>