forked from firka/flutter
Use a linker script to export only the required symbols in the Linux embedder library (flutter/engine#36187)
This commit is contained in:
@@ -2033,6 +2033,7 @@ FILE: ../../../flutter/shell/platform/embedder/embedder.cc
|
||||
FILE: ../../../flutter/shell/platform/embedder/embedder.h
|
||||
FILE: ../../../flutter/shell/platform/embedder/embedder_engine.cc
|
||||
FILE: ../../../flutter/shell/platform/embedder/embedder_engine.h
|
||||
FILE: ../../../flutter/shell/platform/embedder/embedder_exports.lst
|
||||
FILE: ../../../flutter/shell/platform/embedder/embedder_external_texture_gl.cc
|
||||
FILE: ../../../flutter/shell/platform/embedder/embedder_external_texture_gl.h
|
||||
FILE: ../../../flutter/shell/platform/embedder/embedder_external_texture_metal.h
|
||||
|
||||
@@ -370,8 +370,12 @@ shared_library("flutter_engine_library") {
|
||||
|
||||
output_name = "flutter_engine"
|
||||
|
||||
ldflags = []
|
||||
if (is_mac && !embedder_for_target) {
|
||||
ldflags = [ "-Wl,-install_name,@rpath/FlutterEmbedder.framework/$_framework_binary_subpath" ]
|
||||
ldflags += [ "-Wl,-install_name,@rpath/FlutterEmbedder.framework/$_framework_binary_subpath" ]
|
||||
}
|
||||
if (is_linux) {
|
||||
ldflags += [ "-Wl,--version-script=" + rebase_path("embedder_exports.lst") ]
|
||||
}
|
||||
|
||||
deps = [ ":embedder" ]
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
# Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
# Linker script that exports the minimal symbols required for the embedder library
|
||||
|
||||
{
|
||||
global:
|
||||
Flutter*;
|
||||
__Flutter*;
|
||||
kDartIsolateSnapshotData;
|
||||
kDartIsolateSnapshotInstructions;
|
||||
kDartVmSnapshotData;
|
||||
kDartVmSnapshotInstructions;
|
||||
local:
|
||||
*;
|
||||
};
|
||||
@@ -66,10 +66,15 @@ void main(List<String> arguments) {
|
||||
.where((String s) => s.startsWith('ios_'));
|
||||
final Iterable<String> androidReleaseBuilds = releaseBuilds
|
||||
.where((String s) => s.startsWith('android_'));
|
||||
final Iterable<String> hostReleaseBuilds = releaseBuilds
|
||||
.where((String s) => s.startsWith('host_'));
|
||||
|
||||
int failures = 0;
|
||||
failures += _checkIos(outPath, nmPath, iosReleaseBuilds);
|
||||
failures += _checkAndroid(outPath, nmPath, androidReleaseBuilds);
|
||||
if (Platform.isLinux) {
|
||||
failures += _checkLinux(outPath, nmPath, hostReleaseBuilds);
|
||||
}
|
||||
print('Failing checks: $failures');
|
||||
exit(failures);
|
||||
}
|
||||
@@ -248,6 +253,40 @@ int _checkAndroid(String outPath, String nmPath, Iterable<String> builds) {
|
||||
return failures;
|
||||
}
|
||||
|
||||
int _checkLinux(String outPath, String nmPath, Iterable<String> builds) {
|
||||
int failures = 0;
|
||||
for (final String build in builds) {
|
||||
final String libFlutter = p.join(outPath, build, 'libflutter_engine.so');
|
||||
if (!File(libFlutter).existsSync()) {
|
||||
print('SKIPPING: $libFlutter does not exist.');
|
||||
continue;
|
||||
}
|
||||
final ProcessResult nmResult = Process.runSync(nmPath, <String>['-gUD', libFlutter]);
|
||||
if (nmResult.exitCode != 0) {
|
||||
print('ERROR: failed to execute "nm -gUD $libFlutter":\n${nmResult.stderr}');
|
||||
failures++;
|
||||
continue;
|
||||
}
|
||||
final List<NmEntry> entries = NmEntry.parse(nmResult.stdout as String).toList();
|
||||
for (final NmEntry entry in entries) {
|
||||
if (entry.type != 'T' && entry.type != 'R') {
|
||||
print('ERROR: $libFlutter exports an unexpected symbol type: ($entry)');
|
||||
print(' Library has $entries.');
|
||||
failures++;
|
||||
break;
|
||||
}
|
||||
if (!(entry.name.startsWith('Flutter')
|
||||
|| entry.name.startsWith('__Flutter'))) {
|
||||
print('ERROR: $libFlutter exports an unexpected symbol name: ($entry)');
|
||||
print(' Library has $entries.');
|
||||
failures++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return failures;
|
||||
}
|
||||
|
||||
class NmEntry {
|
||||
NmEntry._(this.address, this.type, this.name);
|
||||
|
||||
@@ -261,4 +300,7 @@ class NmEntry {
|
||||
return NmEntry._(parts[0], parts[1], parts.last);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() => '$name: $type';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user