Skip to content

Commit

Permalink
Add a minimal set of symbols to the dynamic symbol table for Linux ex…
Browse files Browse the repository at this point in the history
…ecutables (flutter#8937)

This will reduce executable size.
  • Loading branch information
jason-simmons authored May 13, 2019
1 parent 96ffc89 commit b3b817a
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 16 deletions.
9 changes: 9 additions & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ config("config") {
include_dirs = [ ".." ]
}

config("export_dynamic_symbols") {
if (is_linux) {
inputs = [
"$flutter_root/common/exported_symbols.sym",
]
ldflags = [ "-Wl,--dynamic-list=" + rebase_path(inputs[0], root_build_dir) ]
}
}

group("dist") {
testonly = true

Expand Down
1 change: 1 addition & 0 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ FILE: ../../../flutter/assets/zip_asset_store.cc
FILE: ../../../flutter/assets/zip_asset_store.h
FILE: ../../../flutter/benchmarking/benchmarking.cc
FILE: ../../../flutter/benchmarking/benchmarking.h
FILE: ../../../flutter/common/exported_symbols.sym
FILE: ../../../flutter/common/settings.cc
FILE: ../../../flutter/common/settings.h
FILE: ../../../flutter/common/task_runners.cc
Expand Down
8 changes: 8 additions & 0 deletions common/exported_symbols.sym
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# These symbols are looked up from within the executable at runtime and must
# be exported in the dynamic symbol table.
{
kDartVmSnapshotData;
kDartVmSnapshotInstructions;
kDartIsolateSnapshotData;
kDartIsolateSnapshotInstructions;
};
6 changes: 2 additions & 4 deletions runtime/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ source_set("runtime_unittests_common") {
executable("runtime_unittests") {
testonly = true

configs += [ "$flutter_root:export_dynamic_symbols" ]

sources = [
"dart_isolate_unittests.cc",
"dart_lifecycle_unittests.cc",
Expand All @@ -136,8 +138,4 @@ executable("runtime_unittests") {
deps = [
":runtime_unittests_common",
]

if (is_linux) {
ldflags = [ "-rdynamic" ]
}
}
4 changes: 1 addition & 3 deletions shell/common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,7 @@ template("shell_host_executable") {
"//third_party/tonic",
]

if (is_linux) {
ldflags += [ "-rdynamic" ]
}
public_configs = [ "$flutter_root:export_dynamic_symbols" ]
}
}

Expand Down
6 changes: 2 additions & 4 deletions shell/platform/embedder/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ test_fixtures("fixtures") {
executable("embedder_unittests") {
testonly = true

configs += [ "$flutter_root:export_dynamic_symbols" ]

include_dirs = [ "." ]

sources = [
Expand All @@ -85,10 +87,6 @@ executable("embedder_unittests") {
"//third_party/skia",
"//third_party/tonic",
]

if (is_linux) {
ldflags = [ "-rdynamic" ]
}
}

shared_library("flutter_engine_library") {
Expand Down
9 changes: 4 additions & 5 deletions shell/testing/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ executable("testing") {

output_name = "flutter_tester"

public_configs = [ "$flutter_root:config" ]
public_configs = [
"$flutter_root:config",
"$flutter_root:export_dynamic_symbols",
]

sources = [
"tester_main.cc",
Expand All @@ -34,8 +37,4 @@ executable("testing") {
"//zircon/public/lib/trace-provider",
]
}

if (is_linux) {
ldflags = [ "-rdynamic" ]
}
}

0 comments on commit b3b817a

Please sign in to comment.