Merge "Add rs_allocation_create as an RS header"
diff --git a/lit-tests/lit.cfg b/lit-tests/lit.cfg
index e123f09..7d14bc8 100644
--- a/lit-tests/lit.cfg
+++ b/lit-tests/lit.cfg
@@ -44,8 +44,8 @@
 
     return os.path.abspath(tool)
 
-config.slang = inferTool('llvm-rs-cc', 'SLANG', os.path.join(config.base_path, 'out', 'host', 'linux-x86', 'bin')).replace('\\', '/')
-config.llvm_rs_as = inferTool('llvm-rs-as', 'LLVM_RS_AS', os.path.join(config.base_path, 'out', 'host', 'linux-x86', 'bin')).replace('\\', '/')
+config.slang = inferTool('llvm-rs-cc', 'SLANG', os.path.join(os.getenv('ANDROID_HOST_OUT'), 'bin')).replace('\\', '/')
+config.llvm_rs_as = inferTool('llvm-rs-as', 'LLVM_RS_AS', os.path.join(os.getenv('ANDROID_HOST_OUT'), 'bin')).replace('\\', '/')
 
 config.filecheck = inferTool('FileCheck', 'FILECHECK', config.environment['PATH'])
 config.rs_filecheck_wrapper = inferTool('rs-filecheck-wrapper.sh', 'RS_FILECHECK_WRAPPER', os.path.join(config.base_path, 'frameworks', 'compile', 'slang', 'lit-tests'))
diff --git a/slang_rs_context.cpp b/slang_rs_context.cpp
index 5f1878c..86e66e5 100644
--- a/slang_rs_context.cpp
+++ b/slang_rs_context.cpp
@@ -263,9 +263,16 @@
     }
   }
 
-  // Create a dummy root in slot 0 if a root kernel is not seen.
+  // Create a dummy root in slot 0 if a root kernel is not seen
+  // and there exists a non-root kernel.
   if (valid && mExportForEach[0] == nullptr) {
-    mExportForEach[0] = RSExportForEach::CreateDummyRoot(this);
+    const size_t numExportedForEach = mExportForEach.size();
+    if (numExportedForEach > 1) {
+      mExportForEach[0] = RSExportForEach::CreateDummyRoot(this);
+    } else {
+      slangAssert(numExportedForEach == 1);
+      mExportForEach.pop_back();
+    }
   }
 
   // Finally, export type forcely set to be exported by user