From 12326770dc4116dd3b374c3a50fabfa1f27249dd Mon Sep 17 00:00:00 2001 From: Andreas Steiner Date: Fri, 11 Aug 2023 13:21:46 +0000 Subject: [PATCH] 8313244: NM flags handling in configure process Reviewed-by: clanger, jwaters, mbaesken, erikj --- make/autoconf/flags-other.m4 | 10 ++++++++++ make/autoconf/flags.m4 | 1 + make/autoconf/spec.gmk.in | 1 + make/common/NativeCompilation.gmk | 4 ++-- make/hotspot/lib/CompileJvm.gmk | 10 ++-------- make/hotspot/lib/JvmMapfile.gmk | 6 +++--- 6 files changed, 19 insertions(+), 13 deletions(-) diff --git a/make/autoconf/flags-other.m4 b/make/autoconf/flags-other.m4 index 8062a32601f..0af7c02cff6 100644 --- a/make/autoconf/flags-other.m4 +++ b/make/autoconf/flags-other.m4 @@ -88,6 +88,16 @@ AC_DEFUN([FLAGS_SETUP_RCFLAGS], AC_SUBST(RCFLAGS) ]) +AC_DEFUN([FLAGS_SETUP_NMFLAGS], +[ + # On AIX, we need to set NM flag -X64 for processing 64bit object files + if test "x$OPENJDK_TARGET_OS" = xaix; then + NMFLAGS="-X64" + fi + + AC_SUBST(NMFLAGS) +]) + ################################################################################ # platform independent AC_DEFUN([FLAGS_SETUP_ASFLAGS], diff --git a/make/autoconf/flags.m4 b/make/autoconf/flags.m4 index f56fbc9b1c4..04bee0c9969 100644 --- a/make/autoconf/flags.m4 +++ b/make/autoconf/flags.m4 @@ -429,6 +429,7 @@ AC_DEFUN([FLAGS_SETUP_FLAGS], FLAGS_SETUP_ARFLAGS FLAGS_SETUP_STRIPFLAGS FLAGS_SETUP_RCFLAGS + FLAGS_SETUP_NMFLAGS FLAGS_SETUP_ASFLAGS FLAGS_SETUP_ASFLAGS_CPU_DEP([TARGET]) diff --git a/make/autoconf/spec.gmk.in b/make/autoconf/spec.gmk.in index d147eb5a251..1c472b5ed68 100644 --- a/make/autoconf/spec.gmk.in +++ b/make/autoconf/spec.gmk.in @@ -606,6 +606,7 @@ AR := @AR@ ARFLAGS:=@ARFLAGS@ NM:=@NM@ +NMFLAGS:=@NMFLAGS@ STRIP:=@STRIP@ OBJDUMP:=@OBJDUMP@ CXXFILT:=@CXXFILT@ diff --git a/make/common/NativeCompilation.gmk b/make/common/NativeCompilation.gmk index 9fb71dc2a79..8609fc4ca00 100644 --- a/make/common/NativeCompilation.gmk +++ b/make/common/NativeCompilation.gmk @@ -48,12 +48,12 @@ define GetSymbols $(SED) -e 's/#.*//;s/global://;s/local://;s/\;//;s/^[ ]*/_/;/^_$$$$/d' | \ $(EGREP) -v "JNI_OnLoad|JNI_OnUnload|Agent_OnLoad|Agent_OnUnload|Agent_OnAttach" > \ $$(@D)/$$(basename $$(@F)).symbols || true; \ - $(NM) $$($1_TARGET) | $(GREP) " T " | \ + $(NM) $(NMFLAGS) $$($1_TARGET) | $(GREP) " T " | \ $(EGREP) "JNI_OnLoad|JNI_OnUnload|Agent_OnLoad|Agent_OnUnload|Agent_OnAttach" | \ $(CUT) -d ' ' -f 3 >> $$(@D)/$$(basename $$(@F)).symbols || true;\ else \ $(ECHO) "Getting symbols from nm"; \ - $(NM) -m $$($1_TARGET) | $(GREP) "__TEXT" | \ + $(NM) $(NMFLAGS) -m $$($1_TARGET) | $(GREP) "__TEXT" | \ $(EGREP) -v "non-external|private extern|__TEXT,__eh_frame" | \ $(SED) -e 's/.* //' > $$(@D)/$$(basename $$(@F)).symbols; \ fi diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk index da81b2ca5be..0123829afee 100644 --- a/make/hotspot/lib/CompileJvm.gmk +++ b/make/hotspot/lib/CompileJvm.gmk @@ -281,19 +281,13 @@ ifneq ($(GENERATE_COMPILE_COMMANDS_ONLY), true) # UNDEF_PATTERN := ' U ' - # 'nm' on AIX needs -X64 option - - ifeq ($(call isTargetOs, aix), true) - NM := $(NM) -X64 - endif - define SetupOperatorNewDeleteCheck $1.op_check: $1 $$(call ExecuteWithLog, $1.op_check, \ - $$(NM) $$< 2>&1 | $$(GREP) $$(addprefix -e , $$(MANGLED_SYMS)) | $$(GREP) $$(UNDEF_PATTERN) > $1.op_check || true) + $$(NM) $$(NMFLAGS) $$< 2>&1 | $$(GREP) $$(addprefix -e , $$(MANGLED_SYMS)) | $$(GREP) $$(UNDEF_PATTERN) > $1.op_check || true) if [ -s $1.op_check ]; then \ $$(ECHO) "$$(notdir $$<): Error: Use of global operators new and delete is not allowed in Hotspot:"; \ - $$(NM) $$< | $$(CXXFILT) | $$(EGREP) '$$(DEMANGLED_REGEXP)' | $$(GREP) $$(UNDEF_PATTERN); \ + $$(NM) $$(NMFLAGS) $$< | $$(CXXFILT) | $$(EGREP) '$$(DEMANGLED_REGEXP)' | $$(GREP) $$(UNDEF_PATTERN); \ $$(ECHO) "See: $$(TOPDIR)/make/hotspot/lib/CompileJvm.gmk"; \ exit 1; \ fi diff --git a/make/hotspot/lib/JvmMapfile.gmk b/make/hotspot/lib/JvmMapfile.gmk index d80b804a2f6..2808ac2af03 100644 --- a/make/hotspot/lib/JvmMapfile.gmk +++ b/make/hotspot/lib/JvmMapfile.gmk @@ -53,7 +53,7 @@ endif # platform dependent. ifeq ($(call isTargetOs, linux), true) - DUMP_SYMBOLS_CMD := $(NM) --defined-only *$(OBJ_SUFFIX) + DUMP_SYMBOLS_CMD := $(NM) $(NMFLAGS) --defined-only *$(OBJ_SUFFIX) ifneq ($(FILTER_SYMBOLS_PATTERN), ) FILTER_SYMBOLS_PATTERN := $(FILTER_SYMBOLS_PATTERN)| endif @@ -67,7 +67,7 @@ ifeq ($(call isTargetOs, linux), true) else ifeq ($(call isTargetOs, macosx), true) # nm on macosx prints out "warning: nm: no name list" to stderr for # files without symbols. Hide this, even at the expense of hiding real errors. - DUMP_SYMBOLS_CMD := $(NM) -Uj *$(OBJ_SUFFIX) 2> /dev/null + DUMP_SYMBOLS_CMD := $(NM) $(NMFLAGS) -Uj *$(OBJ_SUFFIX) 2> /dev/null ifneq ($(FILTER_SYMBOLS_PATTERN), ) FILTER_SYMBOLS_PATTERN := $(FILTER_SYMBOLS_PATTERN)| endif @@ -89,7 +89,7 @@ else ifeq ($(call isTargetOs, aix), true) # which may be installed under /opt/freeware/bin. So better use an absolute path here! # NM=/usr/bin/nm - DUMP_SYMBOLS_CMD := $(NM) -X64 -B -C *$(OBJ_SUFFIX) + DUMP_SYMBOLS_CMD := $(NM) $(NMFLAGS) -B -C *$(OBJ_SUFFIX) FILTER_SYMBOLS_AWK_SCRIPT := \ '{ \ if (($$2="d" || $$2="D") && ($$3 ~ /^__vft/ || $$3 ~ /^gHotSpotVM/)) print $$3; \