diff --git a/Makefile b/Makefile index 9e1db783ba597e773f0729926dd388415c20b919..e3a7e3bc88374fd545074c6ad755af9a98538cf7 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 58f11e6829075e805ff374ef95f547f8925b25f4..f6bf9c997bceafc4b607c0d0210eb51ef04d2aa6 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 00a3f708a9f91ea0f1dbf3e8d212fa55154be348..d45cde7be74dbf4cc33faff3ebd9af95e833d9f0 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 1d7192aebd9c7e067f184bad39f1dbe56898639b..13f19b6240a592c80542c04185d5bddd40f654ca 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 793e90cdd78af82057184e8a7452dd8893e989a9..58d3b9292c1326a3d9c5113b4fe0f1ef44d506b3 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}", ]