Hi Orion,
Thank you for the tips! I'm now attempting to add a simple prebuilt
library to the ART runtime, but I can't seem to get it to link properly.
What I've done is this so far:
Create new file "simple_example.h" in "art/runtime":
#ifndef ART_RUNTIME_SIMPLE_H
#define ART_RUNTIME_SIMPLE_H
namespace simple {
extern void simple_print(int num);
}
#endif
Where the `simple_print(int)` function is implemented as a Rust library.
I then use the `simple_print()` function in some ART code by importing
the header and using the function like: `simple::simple_print(10);`
I then copy the `libsimple.so` prebuilt library into the respective
"prebuilts/runtime/mainline/runtime/sdk/{os}/{arch}
/lib/" directories.
I've then edited two SOONG blueprint files:
"art/runtime/Android.bp":
@@ -485,6 +485,7 @@ libart_cc_defaults {
"libbase", // For common macros.
"liblog",
"liblz4",
+ "libsimple",
"liblzma", // libelffile(d) dependency; must be repeated here
since it's a static lib.
"libnativebridge",
"libnativeloader",
(i.e. I've added the library to the "shared_libs" for "libart_cc_defaults")
"prebuilts/runtime/mainline/runtime/sdk/Android.bp":
@@ -1612,6 +1612,54 @@ cc_prebuilt_library_static {
},
}
+cc_prebuilt_library_shared {
+ name: "libsimple",
+ prefer: true,
+ visibility: ["//visibility:public"],
+ apex_available: [
+ "com.android.art",
+ "com.android.art.debug",
+ ],
+ target: {
+ host: {
+ enabled: true,
+ },
+ android: {
+ compile_multilib: "both",
+ },
+ android_arm64: {
+ srcs: ["android/arm64/lib/libsimple.so"],
+ },
+ android_x86_64: {
+ srcs: ["android/x86_64/lib/libsimple.so"],
+ },
+ android_arm: {
+ srcs: ["android/arm/lib/libsimple.so"],
+ },
+ android_x86: {
+ srcs: ["android/x86/lib/libsimple.so"],
+ },
+ linux_bionic: {
+ compile_multilib: "64",
+ },
+ linux_bionic_x86_64: {
+ enabled: true,
+ srcs: ["linux_bionic/x86_64/lib/libsimple.so"],
+ },
+ linux_glibc_x86_64: {
+ enabled: true,
+ srcs: ["linux_glibc/x86_64/lib/libsimple.so"],
+ },
+ linux_glibc_x86: {
+ enabled: true,
+ srcs: ["linux_glibc/x86/lib/libsimple.so"],
+ },
+ },
+ strip: {
+ none: true,
+ }
+}
+
sdk_snapshot {
name: "runtime-module-sdk@current",
visibility: ["//visibility:public"],
However, building it gives me an error like: "module libart missing
dependencies: libsimple{os:linux_glibc,arch:x86_64,link:shared}". Note I
created the "linux_glibc" directory to
"prebuilts/runtime/mainline/runtime/sdk/" myself which I though would
have been a fix for the error, but unfortunately it did not work.
Any help you can offer will be much appreciated. Thank you for your time.
Sincerely,
Kunal
On Tuesday, November 15, 2022 at 9:28:25 PM UTC+11 Orion Hodson wrote:
Hi Kunal
You can build ART for host with the master-art manifest using:
$ cd $ANDROID_BUILD_TOP
$ . build/envsetup.sh
$ lunch silvermont-eng
$ art/tools/buildbot-build.sh --host
You can check your changes don't break existing tests unexpectedly running:
$ art/test.py --host -r -g
Good luck
Orion