From 9d3b826940c04c67b44e12a3508678c936cd0b3c Mon Sep 17 00:00:00 2001 From: YazZz1k Date: Wed, 13 Jul 2022 19:13:18 +0300 Subject: [PATCH] [hir2mpl, mapleall] gprof build option --- Makefile | 4 +++- build/config/BUILDCONFIG.gn | 1 + build/toolchain/BUILD.gn | 11 +++++++---- src/hir2mpl/BUILD.gn | 4 ++++ src/mapleall/BUILD.gn | 4 ++++ 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 9e1db783ba..e3a7e3bc88 100644 --- a/Makefile +++ b/Makefile @@ -29,6 +29,7 @@ MAST := 0 ASAN := 0 ONLY_C := 0 COV := 0 +GPROF := 0 ifeq ($(DEBUG),0) BUILD_TYPE := RELEASE else @@ -60,7 +61,8 @@ GN_OPTIONS := \ MAST=$(MAST) \ ASAN=$(ASAN) \ ONLY_C=$(ONLY_C) \ - COV=$(COV) + COV=$(COV) \ + GPROF=$(GPROF) .PHONY: default default: install diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn index 58f11e6829..f6bf9c997b 100755 --- a/build/config/BUILDCONFIG.gn +++ b/build/config/BUILDCONFIG.gn @@ -34,6 +34,7 @@ declare_args() { ASAN = 0 ONLY_C = 0 COV = 0 + GPROF = 0 } # Define global args diff --git a/build/toolchain/BUILD.gn b/build/toolchain/BUILD.gn index 00a3f708a9..d45cde7be7 100755 --- a/build/toolchain/BUILD.gn +++ b/build/toolchain/BUILD.gn @@ -86,11 +86,14 @@ toolchain("clang") { outfile = "${GN_BINARY_OUTPUT_DIRECTORY}/{{target_output_name}}{{output_extension}}" rspfile = "$outfile.rsp" rspfile_content = "{{inputs}}" - if (GN_BUILD_TYPE == "RELEASE") { - command = "${GN_CXX_COMPILER} -s -fuse-ld=lld {{ldflags}} -o $outfile -Wl,--start-group ${rspfile_content} {{libs}} -Wl,--end-group {{solibs}}" - } else { - command = "${GN_CXX_COMPILER} -fuse-ld=lld {{ldflags}} -o $outfile -Wl,--start-group ${rspfile_content} {{libs}} -Wl,--end-group {{solibs}}" + + strip_flag = "" + if (GN_BUILD_TYPE == "RELEASE" && GPROF == 0) { + strip_flag = "-s" } + + command = "${GN_CXX_COMPILER} ${strip_flag} -fuse-ld=lld {{ldflags}} -o $outfile -Wl,--start-group ${rspfile_content} {{libs}} -Wl,--end-group {{solibs}}" + description = "LINK $outfile" rspfile_content = "{{inputs}}" outputs = [ diff --git a/src/hir2mpl/BUILD.gn b/src/hir2mpl/BUILD.gn index 1d7192aebd..13f19b6240 100644 --- a/src/hir2mpl/BUILD.gn +++ b/src/hir2mpl/BUILD.gn @@ -203,6 +203,10 @@ executable("hir2mpl") { "-ftest-coverage" ] } + if (GPROF == 1) { + ldflags += ["-pg"] + cflags_cc += ["-pg"] + } } include_bytecode_input_jbc_directories = [ diff --git a/src/mapleall/BUILD.gn b/src/mapleall/BUILD.gn index 793e90cdd7..58d3b9292c 100644 --- a/src/mapleall/BUILD.gn +++ b/src/mapleall/BUILD.gn @@ -92,6 +92,10 @@ config("mapleallcompilecfg") { "-ftest-coverage" ] } + if (GPROF == 1) { + ldflags += ["-pg"] + cflags_cc += ["-pg"] + } if (MAJOR_VERSION != "") { cflags_cc += [ "-DMAJOR_VERSION=${MAJOR_VERSION}", ] -- Gitee