Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
d63442c1
Unverified
Commit
d63442c1
authored
Sep 09, 2022
by
Ivan Dlugos
Committed by
GitHub
Sep 09, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: strip all local symbols from macOS and iOS App.framework - reduces app size (#111264)
parent
d7f6a4db
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
80 additions
and
53 deletions
+80
-53
build.dart
packages/flutter_tools/lib/src/base/build.dart
+3
-3
build_test.dart
...ges/flutter_tools/test/general.shard/base/build_test.dart
+4
-4
common_test.dart
.../test/general.shard/build_system/targets/common_test.dart
+2
-2
macos_test.dart
...s/test/general.shard/build_system/targets/macos_test.dart
+2
-2
ios_content_validation_test.dart
...st/host_cross_arch.shard/ios_content_validation_test.dart
+20
-29
macos_content_validation_test.dart
.../host_cross_arch.shard/macos_content_validation_test.dart
+21
-13
test_utils.dart
...ages/flutter_tools/test/integration.shard/test_utils.dart
+28
-0
No files found.
packages/flutter_tools/lib/src/base/build.dart
View file @
d63442c1
...
...
@@ -162,7 +162,7 @@ class AOTSnapshotter {
}
final
String
assembly
=
_fileSystem
.
path
.
join
(
outputDir
.
path
,
'snapshot_assembly.S'
);
if
(
platform
==
TargetPlatform
.
ios
||
platform
==
TargetPlatform
.
darwin
)
{
if
(
targetingApplePlatform
)
{
genSnapshotArgs
.
addAll
(<
String
>[
'--snapshot_kind=app-aot-assembly'
,
'--assembly=
$assembly
'
,
...
...
@@ -181,7 +181,7 @@ class AOTSnapshotter {
if
(
targetingApplePlatform
)
{
stripAfterBuild
=
shouldStrip
;
if
(
stripAfterBuild
)
{
_logger
.
printTrace
(
'Will strip AOT snapshot manual after build and dSYM generation.'
);
_logger
.
printTrace
(
'Will strip AOT snapshot manual
ly
after build and dSYM generation.'
);
}
}
else
{
stripAfterBuild
=
false
;
...
...
@@ -331,7 +331,7 @@ class AOTSnapshotter {
if
(
stripAfterBuild
)
{
// See https://www.unix.com/man-page/osx/1/strip/ for arguments
final
RunResult
stripResult
=
await
_xcode
.
strip
(<
String
>[
'-
S
'
,
appLib
,
'-o'
,
appLib
]);
final
RunResult
stripResult
=
await
_xcode
.
strip
(<
String
>[
'-
x
'
,
appLib
,
'-o'
,
appLib
]);
if
(
stripResult
.
exitCode
!=
0
)
{
_logger
.
printError
(
'Failed to strip debugging symbols from the generated AOT snapshot - strip terminated with exit code
${stripResult.exitCode}
'
);
return
stripResult
.
exitCode
;
...
...
packages/flutter_tools/test/general.shard/base/build_test.dart
View file @
d63442c1
...
...
@@ -262,7 +262,7 @@ void main() {
const
FakeCommand
(
command:
<
String
>[
'xcrun'
,
'strip'
,
'-
S
'
,
'-
x
'
,
'build/foo/App.framework/App'
,
'-o'
,
'build/foo/App.framework/App'
,
...
...
@@ -335,7 +335,7 @@ void main() {
const
FakeCommand
(
command:
<
String
>[
'xcrun'
,
'strip'
,
'-
S
'
,
'-
x
'
,
'build/foo/App.framework/App'
,
'-o'
,
'build/foo/App.framework/App'
,
...
...
@@ -407,7 +407,7 @@ void main() {
const
FakeCommand
(
command:
<
String
>[
'xcrun'
,
'strip'
,
'-
S
'
,
'-
x
'
,
'build/foo/App.framework/App'
,
'-o'
,
'build/foo/App.framework/App'
,
...
...
@@ -476,7 +476,7 @@ void main() {
const
FakeCommand
(
command:
<
String
>[
'xcrun'
,
'strip'
,
'-
S
'
,
'-
x
'
,
'build/foo/App.framework/App'
,
'-o'
,
'build/foo/App.framework/App'
,
...
...
packages/flutter_tools/test/general.shard/build_system/targets/common_test.dart
View file @
d63442c1
...
...
@@ -529,7 +529,7 @@ void main() {
FakeCommand
(
command:
<
String
>[
'xcrun'
,
'strip'
,
'-
S
'
,
'-
x
'
,
'
$build
/arm64/App.framework/App'
,
'-o'
,
'
$build
/arm64/App.framework/App'
,
...
...
@@ -619,7 +619,7 @@ void main() {
FakeCommand
(
command:
<
String
>[
'xcrun'
,
'strip'
,
'-
S
'
,
'-
x
'
,
'
$build
/arm64/App.framework/App'
,
'-o'
,
'
$build
/arm64/App.framework/App'
,
...
...
packages/flutter_tools/test/general.shard/build_system/targets/macos_test.dart
View file @
d63442c1
...
...
@@ -503,7 +503,7 @@ void main() {
FakeCommand
(
command:
<
String
>[
'xcrun'
,
'strip'
,
'-
S
'
,
'-
x
'
,
environment
.
buildDir
.
childFile
(
'arm64/App.framework/App'
).
path
,
'-o'
,
environment
.
buildDir
.
childFile
(
'arm64/App.framework/App'
).
path
,
...
...
@@ -511,7 +511,7 @@ void main() {
FakeCommand
(
command:
<
String
>[
'xcrun'
,
'strip'
,
'-
S
'
,
'-
x
'
,
environment
.
buildDir
.
childFile
(
'x86_64/App.framework/App'
).
path
,
'-o'
,
environment
.
buildDir
.
childFile
(
'x86_64/App.framework/App'
).
path
,
...
...
packages/flutter_tools/test/host_cross_arch.shard/ios_content_validation_test.dart
View file @
d63442c1
...
...
@@ -193,37 +193,28 @@ void main() {
});
testWithoutContext
(
'check symbols'
,
()
{
final
ProcessResult
symbols
=
processManager
.
runSync
(
<
String
>[
'nm'
,
'-g'
,
outputAppFrameworkBinary
.
path
,
'-arch'
,
'arm64'
,
],
);
final
bool
aotSymbolsFound
=
(
symbols
.
stdout
as
String
).
contains
(
'_kDartVmSnapshot'
);
expect
(
aotSymbolsFound
,
buildMode
!=
BuildMode
.
debug
);
final
List
<
String
>
symbols
=
AppleTestUtils
.
getExportedSymbols
(
outputAppFrameworkBinary
.
path
);
if
(
buildMode
==
BuildMode
.
debug
)
{
expect
(
symbols
,
isEmpty
);
}
else
{
expect
(
symbols
,
equals
(
AppleTestUtils
.
requiredSymbols
));
}
});
// dSYM is not created for a debug build so nothing to check.
if
(
buildMode
!=
BuildMode
.
debug
)
{
testWithoutContext
(
'check symbols in dSYM'
,
()
{
final
ProcessResult
nm
=
processManager
.
runSync
(
<
String
>[
'nm'
,
'--debug-syms'
,
'--defined-only'
,
'--just-symbol-name'
,
buildAppFrameworkDsymBinary
.
path
,
'-arch'
,
'arm64'
,
],
);
final
List
<
String
>
symbols
=
(
nm
.
stdout
as
String
).
split
(
'
\n
'
);
expect
(
symbols
,
contains
(
'_kDartVmSnapshotInstructions'
));
});
}
testWithoutContext
(
'check symbols in dSYM'
,
()
{
if
(
buildMode
==
BuildMode
.
debug
)
{
// dSYM is not created for a debug build.
expect
(
buildAppFrameworkDsymBinary
.
existsSync
(),
isFalse
);
}
else
{
final
List
<
String
>
symbols
=
AppleTestUtils
.
getExportedSymbols
(
buildAppFrameworkDsymBinary
.
path
);
expect
(
symbols
,
containsAll
(
AppleTestUtils
.
requiredSymbols
));
// The actual number of symbols is going to vary but there should
// be "many" in the dSYM. At the time of writing, it was 7656.
expect
(
symbols
.
length
,
greaterThanOrEqualTo
(
5000
));
}
});
testWithoutContext
(
'xcode_backend embed_and_thin'
,
()
{
outputFlutterFramework
.
deleteSync
(
recursive:
true
);
...
...
packages/flutter_tools/test/host_cross_arch.shard/macos_content_validation_test.dart
View file @
d63442c1
...
...
@@ -87,19 +87,27 @@ void main() {
'App.framework'
,
));
_checkFatBinary
(
outputAppFramework
.
childFile
(
'App'
),
buildModeLower
,
'dynamically linked shared library'
,
);
// dSYM is not created for a debug build so nothing to check.
if
(
buildMode
!=
'Debug'
)
{
_checkFatBinary
(
buildPath
.
childFile
(
'App.framework.dSYM/Contents/Resources/DWARF/App'
),
buildModeLower
,
'dSYM companion file'
,
);
final
File
libBinary
=
outputAppFramework
.
childFile
(
'App'
);
final
File
libDsymBinary
=
buildPath
.
childFile
(
'App.framework.dSYM/Contents/Resources/DWARF/App'
);
_checkFatBinary
(
libBinary
,
buildModeLower
,
'dynamically linked shared library'
);
final
List
<
String
>
libSymbols
=
AppleTestUtils
.
getExportedSymbols
(
libBinary
.
path
);
if
(
buildMode
==
'Debug'
)
{
// dSYM is not created for a debug build.
expect
(
libDsymBinary
.
existsSync
(),
isFalse
);
expect
(
libSymbols
,
isEmpty
);
}
else
{
_checkFatBinary
(
libDsymBinary
,
buildModeLower
,
'dSYM companion file'
);
expect
(
libSymbols
,
equals
(
AppleTestUtils
.
requiredSymbols
));
final
List
<
String
>
dSymSymbols
=
AppleTestUtils
.
getExportedSymbols
(
libDsymBinary
.
path
);
expect
(
dSymSymbols
,
containsAll
(
AppleTestUtils
.
requiredSymbols
));
// The actual number of symbols is going to vary but there should
// be "many" in the dSYM. At the time of writing, it was 19195.
expect
(
dSymSymbols
.
length
,
greaterThanOrEqualTo
(
15000
));
}
expect
(
outputAppFramework
.
childLink
(
'Resources'
),
exists
);
...
...
packages/flutter_tools/test/integration.shard/test_utils.dart
View file @
d63442c1
...
...
@@ -99,3 +99,31 @@ Future<void> pollForServiceExtensionValue<T>({
" attempts responded with '
$continuePollingValue
'."
,
);
}
class
AppleTestUtils
{
// static only
AppleTestUtils
.
_
();
static
const
List
<
String
>
requiredSymbols
=
<
String
>[
'_kDartIsolateSnapshotData'
,
'_kDartIsolateSnapshotInstructions'
,
'_kDartVmSnapshotData'
,
'_kDartVmSnapshotInstructions'
];
static
List
<
String
>
getExportedSymbols
(
String
dwarfPath
)
{
final
ProcessResult
nm
=
processManager
.
runSync
(
<
String
>[
'nm'
,
'--debug-syms'
,
// nm docs: 'Show all symbols, even debugger only'
'--defined-only'
,
'--just-symbol-name'
,
dwarfPath
,
'-arch'
,
'arm64'
,
],
);
final
String
nmOutput
=
(
nm
.
stdout
as
String
).
trim
();
return
nmOutput
.
isEmpty
?
const
<
String
>[]
:
nmOutput
.
split
(
'
\n
'
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment