Add static variants of Dart engine library and update samples
Fixes https://github.com/dart-lang/sdk/issues/60799
Change-Id: I16a8dd2c854ed6915f14e1b71547879f50f2de0e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432920
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Ivan Inozemtsev <iinozemtsev@google.com>
diff --git a/runtime/engine/BUILD.gn b/runtime/engine/BUILD.gn
index ed11c81..6dd85e6 100644
--- a/runtime/engine/BUILD.gn
+++ b/runtime/engine/BUILD.gn
@@ -107,3 +107,37 @@
]
}
}
+
+static_library("dart_engine_jit_static") {
+ deps = [ ":engine_jit_set" ]
+ complete_static_lib = true
+
+ if (is_win) {
+ libs = [
+ "ole32.lib",
+ "iphlpapi.lib",
+ "psapi.lib",
+ "ws2_32.lib",
+ "Rpcrt4.lib",
+ "shlwapi.lib",
+ "winmm.lib",
+ ]
+ }
+}
+
+static_library("dart_engine_aot_static") {
+ deps = [ ":engine_aot_set" ]
+ complete_static_lib = true
+
+ if (is_win) {
+ libs = [
+ "ole32.lib",
+ "iphlpapi.lib",
+ "psapi.lib",
+ "ws2_32.lib",
+ "Rpcrt4.lib",
+ "shlwapi.lib",
+ "winmm.lib",
+ ]
+ }
+}
diff --git a/runtime/tools/entitlements/run_futures_aot_static.plist b/runtime/tools/entitlements/run_futures_aot_static.plist
new file mode 100644
index 0000000..eeda4be
--- /dev/null
+++ b/runtime/tools/entitlements/run_futures_aot_static.plist
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+ <dict>
+ <key>com.apple.security.cs.allow-jit</key>
+ <true/>
+ <key>com.apple.security.cs.disable-library-validation</key>
+ <true/>
+ </dict>
+</plist>
\ No newline at end of file
diff --git a/runtime/tools/entitlements/run_futures_kernel_static.plist b/runtime/tools/entitlements/run_futures_kernel_static.plist
new file mode 100644
index 0000000..eeda4be
--- /dev/null
+++ b/runtime/tools/entitlements/run_futures_kernel_static.plist
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+ <dict>
+ <key>com.apple.security.cs.allow-jit</key>
+ <true/>
+ <key>com.apple.security.cs.disable-library-validation</key>
+ <true/>
+ </dict>
+</plist>
\ No newline at end of file
diff --git a/runtime/tools/entitlements/run_main_aot_static.plist b/runtime/tools/entitlements/run_main_aot_static.plist
new file mode 100644
index 0000000..eeda4be
--- /dev/null
+++ b/runtime/tools/entitlements/run_main_aot_static.plist
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+ <dict>
+ <key>com.apple.security.cs.allow-jit</key>
+ <true/>
+ <key>com.apple.security.cs.disable-library-validation</key>
+ <true/>
+ </dict>
+</plist>
\ No newline at end of file
diff --git a/runtime/tools/entitlements/run_main_kernel_static.plist b/runtime/tools/entitlements/run_main_kernel_static.plist
new file mode 100644
index 0000000..eeda4be
--- /dev/null
+++ b/runtime/tools/entitlements/run_main_kernel_static.plist
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+ <dict>
+ <key>com.apple.security.cs.allow-jit</key>
+ <true/>
+ <key>com.apple.security.cs.disable-library-validation</key>
+ <true/>
+ </dict>
+</plist>
\ No newline at end of file
diff --git a/runtime/tools/entitlements/run_timer_aot_static.plist b/runtime/tools/entitlements/run_timer_aot_static.plist
new file mode 100644
index 0000000..eeda4be
--- /dev/null
+++ b/runtime/tools/entitlements/run_timer_aot_static.plist
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+ <dict>
+ <key>com.apple.security.cs.allow-jit</key>
+ <true/>
+ <key>com.apple.security.cs.disable-library-validation</key>
+ <true/>
+ </dict>
+</plist>
\ No newline at end of file
diff --git a/runtime/tools/entitlements/run_timer_async_aot_static.plist b/runtime/tools/entitlements/run_timer_async_aot_static.plist
new file mode 100644
index 0000000..eeda4be
--- /dev/null
+++ b/runtime/tools/entitlements/run_timer_async_aot_static.plist
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+ <dict>
+ <key>com.apple.security.cs.allow-jit</key>
+ <true/>
+ <key>com.apple.security.cs.disable-library-validation</key>
+ <true/>
+ </dict>
+</plist>
\ No newline at end of file
diff --git a/runtime/tools/entitlements/run_timer_async_kernel_static.plist b/runtime/tools/entitlements/run_timer_async_kernel_static.plist
new file mode 100644
index 0000000..eeda4be
--- /dev/null
+++ b/runtime/tools/entitlements/run_timer_async_kernel_static.plist
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+ <dict>
+ <key>com.apple.security.cs.allow-jit</key>
+ <true/>
+ <key>com.apple.security.cs.disable-library-validation</key>
+ <true/>
+ </dict>
+</plist>
\ No newline at end of file
diff --git a/runtime/tools/entitlements/run_timer_kernel_static.plist b/runtime/tools/entitlements/run_timer_kernel_static.plist
new file mode 100644
index 0000000..eeda4be
--- /dev/null
+++ b/runtime/tools/entitlements/run_timer_kernel_static.plist
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+ <dict>
+ <key>com.apple.security.cs.allow-jit</key>
+ <true/>
+ <key>com.apple.security.cs.disable-library-validation</key>
+ <true/>
+ </dict>
+</plist>
\ No newline at end of file
diff --git a/runtime/tools/entitlements/run_two_programs_aot_static.plist b/runtime/tools/entitlements/run_two_programs_aot_static.plist
new file mode 100644
index 0000000..eeda4be
--- /dev/null
+++ b/runtime/tools/entitlements/run_two_programs_aot_static.plist
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+ <dict>
+ <key>com.apple.security.cs.allow-jit</key>
+ <true/>
+ <key>com.apple.security.cs.disable-library-validation</key>
+ <true/>
+ </dict>
+</plist>
\ No newline at end of file
diff --git a/runtime/tools/entitlements/run_two_programs_kernel_static.plist b/runtime/tools/entitlements/run_two_programs_kernel_static.plist
new file mode 100644
index 0000000..eeda4be
--- /dev/null
+++ b/runtime/tools/entitlements/run_two_programs_kernel_static.plist
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+ <dict>
+ <key>com.apple.security.cs.allow-jit</key>
+ <true/>
+ <key>com.apple.security.cs.disable-library-validation</key>
+ <true/>
+ </dict>
+</plist>
\ No newline at end of file
diff --git a/samples/embedder/BUILD.gn b/samples/embedder/BUILD.gn
index 5f990dc..0b41610 100644
--- a/samples/embedder/BUILD.gn
+++ b/samples/embedder/BUILD.gn
@@ -16,28 +16,42 @@
group("aot") {
deps = [
":run_main_aot",
+ ":run_main_aot_static",
":run_timer_aot",
+ ":run_timer_aot_static",
":run_timer_async_aot",
+ ":run_timer_async_aot_static",
":run_two_programs_aot",
+ ":run_two_programs_aot_static",
]
# FFI can't execute on the VM's simulator
if (dart_target_arch == host_cpu) {
- deps += [ ":run_futures_aot" ]
+ deps += [
+ ":run_futures_aot",
+ ":run_futures_aot_static",
+ ]
}
}
group("kernel") {
deps = [
":run_main_kernel",
+ ":run_main_kernel_static",
":run_timer_async_kernel",
+ ":run_timer_async_kernel_static",
":run_timer_kernel",
+ ":run_timer_kernel_static",
":run_two_programs_kernel",
+ ":run_two_programs_kernel_static",
]
# FFI can't execute on the VM's simulator
if (dart_target_arch == host_cpu) {
- deps += [ ":run_futures_kernel" ]
+ deps += [
+ ":run_futures_kernel",
+ ":run_futures_kernel_static",
+ ]
}
}
@@ -45,6 +59,7 @@
{
suffix = "_kernel"
dart_shared_lib = "../../runtime/engine:dart_engine_jit_shared"
+ dart_static_lib = "../../runtime/engine:dart_engine_jit_static"
dart_snapshot_kind = "kernel"
gen_kernel_args = [ "--link-platform" ]
snapshot_target = "application_snapshot"
@@ -53,6 +68,7 @@
{
suffix = "_aot"
dart_shared_lib = "../../runtime/engine:dart_engine_aot_shared"
+ dart_static_lib = "../../runtime/engine:dart_engine_aot_static"
snapshot_target = "aot_snapshot"
# AOT snapshots as shared libraries on Windows are not
@@ -105,6 +121,37 @@
}
deps += extra_deps
}
+
+ executable("${target_name}${conf.suffix}_static") {
+ forward_variables_from(invoker,
+ "*",
+ [
+ "extra_deps",
+ "configurable_deps",
+ ])
+ if (!defined(include_dirs)) {
+ include_dirs = []
+ }
+
+ include_dirs += [
+ ".",
+ "../../runtime",
+ "../../runtime/engine",
+ ]
+
+ # Otherwise build with --no-clang (jit) or MSAN (aot) fails.
+ if (is_linux) {
+ if (!defined(ldflags)) {
+ ldflags = []
+ }
+ ldflags += [ "-Wl,--allow-shlib-undefined" ]
+ }
+ deps = [ conf.dart_static_lib ]
+ foreach(dep, configurable_deps) {
+ deps += [ "${dep}${conf.suffix}_static" ]
+ }
+ deps += extra_deps
+ }
}
}
@@ -118,7 +165,8 @@
extra_deps += invoker.extra_deps
}
foreach(conf, _all_configs) {
- target(conf.snapshot_target, "${target_name}${conf.suffix}") {
+ snapshot_target_name = "${target_name}${conf.suffix}"
+ target(conf.snapshot_target, snapshot_target_name) {
forward_variables_from(invoker,
"*",
[
@@ -143,6 +191,9 @@
}
deps += extra_deps
}
+ group("${snapshot_target_name}_static") {
+ deps = [ ":${snapshot_target_name}" ]
+ }
}
}
@@ -197,6 +248,35 @@
}
deps += extra_deps
}
+
+ static_library("${target_name}${conf.suffix}_static") {
+ forward_variables_from(invoker,
+ "*",
+ [
+ "name",
+ "extra_deps",
+ "configurable_deps",
+ ])
+ if (!defined(include_dirs)) {
+ include_dirs = []
+ }
+ include_dirs += [
+ ".",
+ "../../runtime",
+ "../../runtime/engine",
+ ]
+
+ sources = [
+ "$name.cc",
+ "$name.h",
+ ]
+ public = [ "$name.h" ]
+ deps = [ conf.dart_static_lib ]
+ foreach(dep, configurable_deps) {
+ deps += [ "$dep${conf.suffix}" ]
+ }
+ deps += extra_deps
+ }
}
}
diff --git a/tests/standalone/embedder_samples_test.dart b/tests/standalone/embedder_samples_test.dart
index 40d9009..94bd1d4 100644
--- a/tests/standalone/embedder_samples_test.dart
+++ b/tests/standalone/embedder_samples_test.dart
@@ -2,6 +2,17 @@
import 'package:expect/expect.dart';
+void checkSamples(
+ String binaryBasename,
+ List<String> args, {
+ bool skipIfNotBuilt = false,
+}) {
+ // Shared library variant.
+ checkSample(binaryBasename, args, skipIfNotBuilt: skipIfNotBuilt);
+ // Static variant.
+ checkSample('${binaryBasename}_static', args, skipIfNotBuilt: skipIfNotBuilt);
+}
+
void checkSample(
String binary,
List<String> args, {
@@ -35,35 +46,37 @@
final executable = File(Platform.executable).absolute.path;
final out = executable.substring(0, executable.lastIndexOf('dart') - 1);
- checkSample('$out/run_main_kernel', ['$out/gen/hello_kernel.dart.snapshot']);
- checkSample('$out/run_two_programs_kernel', [
+ checkSamples('$out/run_main_kernel', ['$out/gen/hello_kernel.dart.snapshot']);
+ checkSamples('$out/run_two_programs_kernel', [
'$out/gen/program1_kernel.dart.snapshot',
'$out/gen/program2_kernel.dart.snapshot',
]);
- checkSample('$out/run_timer_kernel', ['$out/gen/timer_kernel.dart.snapshot']);
- checkSample('$out/run_timer_async_kernel', [
+ checkSamples('$out/run_timer_kernel', [
+ '$out/gen/timer_kernel.dart.snapshot',
+ ]);
+ checkSamples('$out/run_timer_async_kernel', [
'$out/gen/timer_kernel.dart.snapshot',
]);
// FFI samples aren't built on some platforms.
- checkSample('$out/run_futures_kernel', [
+ checkSamples('$out/run_futures_kernel', [
'$out/gen/futures_kernel.dart.snapshot',
], skipIfNotBuilt: true);
// AOT Samples aren't built on some platforms.
- checkSample('$out/run_main_aot', [
+ checkSamples('$out/run_main_aot', [
'$out/hello_aot.snapshot',
], skipIfNotBuilt: true);
- checkSample('$out/run_two_programs_aot', [
+ checkSamples('$out/run_two_programs_aot', [
'$out/program1_aot.snapshot',
'$out/program2_aot.snapshot',
], skipIfNotBuilt: true);
- checkSample('$out/run_timer_aot', [
+ checkSamples('$out/run_timer_aot', [
'$out/timer_aot.snapshot',
], skipIfNotBuilt: true);
- checkSample('$out/run_timer_async_aot', [
+ checkSamples('$out/run_timer_async_aot', [
'$out/timer_aot.snapshot',
], skipIfNotBuilt: true);
- checkSample('$out/run_futures_aot', [
+ checkSamples('$out/run_futures_aot', [
'$out/futures_aot.snapshot',
], skipIfNotBuilt: true);
}