--- a/make/common/NativeCompilation.gmk Fri Sep 18 09:21:07 2015 -0700
+++ b/make/common/NativeCompilation.gmk Mon Sep 28 15:51:29 2015 +0200
@@ -49,6 +49,7 @@
# AS - Assembler
# MT - Windows MT tool
# RC - Windows RC tool
+# STRIP - The tool to use for stripping debug symbols
# SYSROOT_CFLAGS - Compiler flags for using the specific sysroot
# SYSROOT_LDFLAGS - Linker flags for using the specific sysroot
DefineNativeToolchain = $(NamedParamsMacroTemplate)
@@ -64,6 +65,7 @@
$$(call SetIfEmpty, $1_AS, $$($$($1_EXTENDS)_AS))
$$(call SetIfEmpty, $1_MT, $$($$($1_EXTENDS)_MT))
$$(call SetIfEmpty, $1_RC, $$($$($1_EXTENDS)_RC))
+ $$(call SetIfEmpty, $1_STRIP, $$($$($1_EXTENDS)_STRIP))
$$(call SetIfEmpty, $1_SYSROOT_CFLAGS, $$($$($1_EXTENDS)_SYSROOT_CFLAGS))
$$(call SetIfEmpty, $1_SYSROOT_LDFLAGS, $$($$($1_EXTENDS)_SYSROOT_LDFLAGS))
endif
@@ -78,6 +80,7 @@
AS := $(AS), \
MT := $(MT), \
RC := $(RC), \
+ STRIP := $(STRIP), \
SYSROOT_CFLAGS := $(SYSROOT_CFLAGS), \
SYSROOT_LDFLAGS := $(SYSROOT_LDFLAGS), \
))
@@ -265,6 +268,8 @@
# LD the linker to use, default is $(LD)
# OPTIMIZATION sets optimization level to NONE, LOW, HIGH, HIGHEST
# DISABLED_WARNINGS_<toolchain> Disable the given warnings for the specified toolchain
+# STRIP_SYMBOLS Set to true to strip the final binary if the toolchain allows for it
+# STRIPFLAGS Optionally change the flags given to the strip command
SetupNativeCompilation = $(NamedParamsMacroTemplate)
define SetupNativeCompilationBody
@@ -367,6 +372,7 @@
$$(call SetIfEmpty, $1_AS, $$($$($1_TOOLCHAIN)_AS))
$$(call SetIfEmpty, $1_MT, $$($$($1_TOOLCHAIN)_MT))
$$(call SetIfEmpty, $1_RC, $$($$($1_TOOLCHAIN)_RC))
+ $$(call SetIfEmpty, $1_STRIP, $$($$($1_TOOLCHAIN)_STRIP))
$$(call SetIfEmpty, $1_SYSROOT_CFLAGS, $$($$($1_TOOLCHAIN)_SYSROOT_CFLAGS))
$$(call SetIfEmpty, $1_SYSROOT_LDFLAGS, $$($$($1_TOOLCHAIN)_SYSROOT_LDFLAGS))
@@ -657,6 +663,14 @@
endif # $1_DEBUG_SYMBOLS
endif # !STATIC_LIBRARY
+ ifeq ($$($1_STRIP_SYMBOLS), true)
+ ifneq ($$($1_STRIP), )
+ # Default to using the global STRIPFLAGS. Allow for overriding with an empty value
+ $1_STRIPFLAGS ?= $(STRIPFLAGS)
+ $1_STRIP_CMD := $$($1_STRIP) $$($1_STRIPFLAGS) $$($1_TARGET)
+ endif
+ endif
+
ifneq (,$$($1_LIBRARY))
# Generating a dynamic library.
$1_EXTRA_LDFLAGS += $$(call SET_SHARED_LIBRARY_NAME,$$($1_BASENAME))
@@ -667,7 +681,8 @@
$1_EXTRA_LDFLAGS_SUFFIX += $(GLOBAL_LDFLAGS_SUFFIX)
$1_VARDEPS := $$($1_LD) $$($1_SYSROOT_LDFLAGS) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) \
- $$($1_LDFLAGS_SUFFIX) $$($1_EXTRA_LDFLAGS_SUFFIX) $$($1_CREATE_DEBUGINFO_CMDS)
+ $$($1_LDFLAGS_SUFFIX) $$($1_EXTRA_LDFLAGS_SUFFIX) $$($1_CREATE_DEBUGINFO_CMDS) \
+ $$($1_STRIP_CMD)
$1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \
$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).vardeps)
@@ -680,6 +695,7 @@
$$($1_EXPECTED_OBJS) $$($1_RES) \
$$($1_LDFLAGS_SUFFIX) $$($1_EXTRA_LDFLAGS_SUFFIX))
$$($1_CREATE_DEBUGINFO_CMDS)
+ $$($1_STRIP_CMD)
# Touch target to make sure it has a later time stamp than the debug
# symbol files to avoid unnecessary relinking on rebuild.
ifeq ($(OPENJDK_TARGET_OS), windows)
@@ -708,7 +724,8 @@
$1_VARDEPS := $$($1_LD) $$($1_SYSROOT_LDFLAGS) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) \
$$($1_LDFLAGS_SUFFIX) $$($1_EXTRA_LDFLAGS_SUFFIX) $$($1_MT) \
- $$($1_CODESIGN) $$($1_CREATE_DEBUGINFO_CMDS) $$($1_MANIFEST_VERSION)
+ $$($1_CODESIGN) $$($1_CREATE_DEBUGINFO_CMDS) $$($1_MANIFEST_VERSION) \
+ $$($1_STRIP_CMD)
$1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \
$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).vardeps)
@@ -733,6 +750,7 @@
endif
endif
$$($1_CREATE_DEBUGINFO_CMDS)
+ $$($1_STRIP_CMD)
# Touch target to make sure it has a later time stamp than the debug
# symbol files to avoid unnecessary relinking on rebuild.
ifeq ($(OPENJDK_TARGET_OS), windows)