Skip to content
This repository was archived by the owner on Apr 21, 2025. It is now read-only.

Commit ff1975d

Browse files
author
Hidenori Matsubayashi
authored
Fix: Strip option doesn't work for linux .so files (#455)
libflutter_engine.so and libflutter_linux_gtk.so are not stripped
1 parent ef50dec commit ff1975d

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

build/toolchain/clang.gni

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ declare_args() {
1919

2020
# Set this flag to cause bitcode to be marker only.
2121
bitcode_marker = false
22+
23+
# Set this flag to strip .so files.
24+
stripped_symbols = !is_debug
2225
}
2326

2427
declare_args() {

build/toolchain/gcc_toolchain.gni

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,22 @@ template("gcc_toolchain") {
176176
replace_command = "if ! cmp -s $temporary_tocname $tocfile; then mv $temporary_tocname $tocfile; fi"
177177

178178
command = "$link_command && $toc_command && $replace_command"
179+
if (stripped_symbols) {
180+
if (defined(invoker.strip) || defined(invoker.llvm_objcopy)) {
181+
unstripped_outfile = "{{root_out_dir}}/lib.unstripped/$sofile"
182+
pre_strip_command = "mkdir -p {{root_out_dir}}/lib.unstripped && cp $sofile {{root_out_dir}}/lib.unstripped/"
183+
}
184+
if (defined(invoker.strip)) {
185+
strip = invoker.strip
186+
strip_command =
187+
"${strip} --strip-unneeded -o $sofile $unstripped_outfile"
188+
command += " && " + pre_strip_command + " && " + strip_command
189+
} else if (defined(invoker.llvm_objcopy)) {
190+
strip = invoker.llvm_objcopy
191+
strip_command = "${strip} --strip-all $unstripped_outfile $sofile"
192+
command += " && " + pre_strip_command + " && " + strip_command
193+
}
194+
}
179195
if (defined(invoker.postsolink)) {
180196
command += " && " + invoker.postsolink
181197
}

0 commit comments

Comments
 (0)