diff --git a/engine/src/flutter/build/toolchain/gcc_toolchain.gni b/engine/src/flutter/build/toolchain/gcc_toolchain.gni index 3421a9575bd..bb1d7919385 100644 --- a/engine/src/flutter/build/toolchain/gcc_toolchain.gni +++ b/engine/src/flutter/build/toolchain/gcc_toolchain.gni @@ -36,6 +36,10 @@ concurrent_links = exec_script("get_concurrent_links.py", [], "value") # - deps # Just forwarded to the toolchain definition. # - is_clang +# - strip +# Location of the strip executable. When specified, strip will be run on +# all shared libraries and executables as they are built. The pre-stripped +# artifacts will be put in lib.stripped/ and exe.stripped/. template("gcc_toolchain") { toolchain(target_name) { assert(defined(invoker.cc), "gcc_toolchain() must specify a \"cc\" value") @@ -185,9 +189,21 @@ template("gcc_toolchain") { } tool("link") { - outfile = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" + exename = "{{target_output_name}}{{output_extension}}" + outfile = "{{root_out_dir}}/$exename" rspfile = "$outfile.rsp" - command = "$ld {{ldflags}} -o $outfile -Wl,--start-group @$rspfile {{solibs}} -Wl,--end-group $libs_section_prefix {{libs}} $libs_section_postfix" + unstripped_outfile = outfile + + if (defined(invoker.strip)) { + unstripped_outfile = "{{root_out_dir}}/exe.unstripped/$exename" + } + + command = "$ld {{ldflags}} -o $unstripped_outfile -Wl,--start-group @$rspfile {{solibs}} -Wl,--end-group $libs_section_prefix {{libs}} $libs_section_postfix" + if (defined(invoker.strip)) { + strip = invoker.strip + strip_command = "${strip} --strip-unneeded -o $outfile $unstripped_outfile" + command += " && " + strip_command + } if (defined(invoker.postlink)) { command += " && " + invoker.postlink } @@ -196,6 +212,9 @@ template("gcc_toolchain") { outputs = [ outfile, ] + if (outfile != unstripped_outfile) { + outputs += [ unstripped_outfile ] + } if (defined(invoker.link_outputs)) { outputs += invoker.link_outputs } diff --git a/engine/src/flutter/build/toolchain/linux/BUILD.gn b/engine/src/flutter/build/toolchain/linux/BUILD.gn index 15ad5bdea8c..c16e31c46b1 100644 --- a/engine/src/flutter/build/toolchain/linux/BUILD.gn +++ b/engine/src/flutter/build/toolchain/linux/BUILD.gn @@ -80,6 +80,7 @@ gcc_toolchain("clang_x64") { nm = "nm" ar = "ar" ld = cxx + strip = "strip" toolchain_cpu = "x64" toolchain_os = "linux"