diff --git a/ohos_var.gni b/ohos_var.gni index 1397afc71b02bc9402135b84d990bf0c1dee82b2..3034a2b1832ace94feae0bfcc5cbb714f74082ae 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 f9e7179553b16635140941553d82739d82bebcec..e8a8a90c20cea19f5eb1413b5c0bcce2cc0a56dd 100755 --- a/toolchain/gcc_link_wrapper.py +++ b/toolchain/gcc_link_wrapper.py @@ -58,30 +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', + 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='Add .gnu_debugdata section for stripped sofile') - parser.add_argument('--clang-base-dir', help='') + 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' @@ -95,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( @@ -111,7 +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 diff --git a/toolchain/gcc_toolchain.gni b/toolchain/gcc_toolchain.gni index ef98dd7f003656cea1e33cd208c6f17a7b11c416..54006694215c610fa9cf123d00f43546975e719c 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}}"