From 918f78d9c072cfbe01ac7fc5613547482d100aa9 Mon Sep 17 00:00:00 2001 From: lin-yuye99 Date: Wed, 10 Sep 2025 16:05:38 +0800 Subject: [PATCH 1/3] remove exe Signed-off-by: lin-yuye99 --- ohos_var.gni | 4 ++++ toolchain/gcc_link_wrapper.py | 4 ++++ toolchain/gcc_toolchain.gni | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/ohos_var.gni b/ohos_var.gni index 1397afc71b..3034a2b183 100755 --- a/ohos_var.gni +++ b/ohos_var.gni @@ -306,6 +306,10 @@ declare_args() { } } +declare_args() { + remove_exe = false +} + # Compile and generate output directory innersdk_build_out_dir = "innerkits/${target_type}" diff --git a/toolchain/gcc_link_wrapper.py b/toolchain/gcc_link_wrapper.py index f9e7179553..5c108d5e53 100755 --- a/toolchain/gcc_link_wrapper.py +++ b/toolchain/gcc_link_wrapper.py @@ -80,6 +80,7 @@ def main(): default=False, help='Add .gnu_debugdata section for stripped sofile') parser.add_argument('--clang-base-dir', help='') + parser.add_argument('--remove-exe', help='remove exe.unstripped after used') args = parser.parse_args() # Work-around for gold being slow-by-default. http://crbug.com/632230 @@ -112,6 +113,9 @@ def main(): ['python3', script_path, '--unstripped-path', unstripped_libfile, '--stripped-path', args.output, '--root-path', ohos_root_path, '--clang-base-dir', args.clang_base_dir])) + if args.remove_exe: + os.remove(args.unstripped_file) + return result diff --git a/toolchain/gcc_toolchain.gni b/toolchain/gcc_toolchain.gni index ef98dd7f00..5400669421 100644 --- a/toolchain/gcc_toolchain.gni +++ b/toolchain/gcc_toolchain.gni @@ -11,6 +11,7 @@ import("//build/config/v8_target_cpu.gni") import("//build/toolchain/cc_wrapper.gni") import("//build/toolchain/clang_static_analyzer.gni") import("//build/toolchain/toolchain.gni") +import("//build/ohos_var.gni") if (defined(remote_execution) && remote_execution) { import("${rbe_path}/rbe.gni") @@ -613,6 +614,9 @@ template("gcc_toolchain") { if (full_mini_debug && !is_debug) { command = "$command --mini-debug" } + if (remove_exe) { + command = "$command --remove-exe" + } command = "$command -- $link_command" description = "LINK $outfile" rspfile_content = "{{inputs}}" -- Gitee From 8ce074155a329a6333ab1cbe3a2aa66ef0a2e2b5 Mon Sep 17 00:00:00 2001 From: lin-yuye99 Date: Thu, 11 Sep 2025 14:55:53 +0800 Subject: [PATCH 2/3] xiugaidaima Signed-off-by: lin-yuye99 --- toolchain/gcc_link_wrapper.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/toolchain/gcc_link_wrapper.py b/toolchain/gcc_link_wrapper.py index 5c108d5e53..934a1d342c 100755 --- a/toolchain/gcc_link_wrapper.py +++ b/toolchain/gcc_link_wrapper.py @@ -80,7 +80,10 @@ def main(): default=False, help='Add .gnu_debugdata section for stripped sofile') parser.add_argument('--clang-base-dir', help='') - parser.add_argument('--remove-exe', help='remove exe.unstripped after used') + parser.add_argument('--remove-exe', + action='store_true', + default=False, + help='remove exe.unstripped after used') args = parser.parse_args() # Work-around for gold being slow-by-default. http://crbug.com/632230 -- Gitee From 764dc4eb2d2ce25ca9f6b511206915627e155d0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E6=98=B1=E6=99=94?= Date: Fri, 12 Sep 2025 08:12:28 +0000 Subject: [PATCH 3/3] update toolchain/gcc_link_wrapper.py. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 林昱晔 --- toolchain/gcc_link_wrapper.py | 32 +++++++------------------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/toolchain/gcc_link_wrapper.py b/toolchain/gcc_link_wrapper.py index 934a1d342c..e8a8a90c20 100755 --- a/toolchain/gcc_link_wrapper.py +++ b/toolchain/gcc_link_wrapper.py @@ -58,34 +58,20 @@ def update_crt(command): def main(): parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument('--strip', - help='The strip binary to run', - metavar='PATH') - parser.add_argument('--unstripped-file', - help='Executable file produced by linking command', - metavar='FILE') - parser.add_argument('--map-file', - help=('Use --Wl,-Map to generate a map file. Will be ' - 'gzipped if extension ends with .gz'), - metavar='FILE') - parser.add_argument('--output', - required=True, - help='Final output executable file', - metavar='FILE') - parser.add_argument('--clang_rt_dso_path', - help=('Clang asan runtime shared library')) + parser.add_argument('--strip', help='The strip binary to run', metavar='PATH') + parser.add_argument('--unstripped-file', help='Executable file produced by linking command', metavar='FILE') + parser.add_argument('--map-file', help=('Use --Wl,-Map to generate a map file. Will be gzipped if extension ends with .gz'), + metavar='FILE') + parser.add_argument('--output', required=True, help='Final output executable file', metavar='FILE') + parser.add_argument('--clang_rt_dso_path', help=('Clang asan runtime shared library')) parser.add_argument('command', nargs='+', help='Linking command') - parser.add_argument('--mini-debug', - action='store_true', - default=False, - help='Add .gnu_debugdata section for stripped sofile') + parser.add_argument('--mini-debug', action='store_true', default=False, help='Add .gnu_debugdata section for stripped sofile') parser.add_argument('--clang-base-dir', help='') parser.add_argument('--remove-exe', action='store_true', default=False, help='remove exe.unstripped after used') args = parser.parse_args() - # Work-around for gold being slow-by-default. http://crbug.com/632230 fast_env = dict(os.environ) fast_env['LC_ALL'] = 'C' @@ -99,13 +85,11 @@ def main(): command, env=fast_env, map_file=args.map_file) if result != 0: return result - # Finally, strip the linked executable (if desired). if args.strip: result = subprocess.call( command_to_run( [args.strip, '-o', args.output, args.unstripped_file])) - if args.mini_debug and not args.unstripped_file.endswith(".exe") and not args.unstripped_file.endswith(".dll"): unstripped_libfile = os.path.abspath(args.unstripped_file) script_path = os.path.join( @@ -115,10 +99,8 @@ def main(): wrapper_utils.command_to_run( ['python3', script_path, '--unstripped-path', unstripped_libfile, '--stripped-path', args.output, '--root-path', ohos_root_path, '--clang-base-dir', args.clang_base_dir])) - if args.remove_exe: os.remove(args.unstripped_file) - return result -- Gitee