diff --git a/make/Main.gmk b/make/Main.gmk index f2f1bce0e10..eda3b79265a 100644 --- a/make/Main.gmk +++ b/make/Main.gmk @@ -1321,10 +1321,7 @@ endif ################################################################################ # all-images builds all our deliverables as images. -all-images: product-images test-image all-docs-images -ifeq ($(call isTargetOs, linux macosx windows), true) - all-images: static-jdk-image -endif +all-images: product-images static-jdk-image test-image all-docs-images # all-bundles packages all our deliverables as tar.gz bundles. all-bundles: product-bundles test-bundles docs-bundles static-libs-bundles diff --git a/make/StaticLibs.gmk b/make/StaticLibs.gmk index 3fcbd0565c3..3cf2a4dd136 100644 --- a/make/StaticLibs.gmk +++ b/make/StaticLibs.gmk @@ -31,6 +31,7 @@ include CopyFiles.gmk include DebugInfoUtils.gmk include Modules.gmk include modules/LauncherCommon.gmk +include Execute.gmk ################################################################################ # @@ -68,6 +69,10 @@ else ifeq ($(call isTargetOs, windows), true) BROKEN_STATIC_LIBS += sspi_bridge # dt_shmem define jdwpTransport_OnLoad which conflict with dt_socket BROKEN_STATIC_LIBS += dt_shmem +else ifeq ($(call isTargetOs, aix), true) + # libsplashscreen has a name conflict with libawt in the function + # BitmapToYXBandedRectangles, so we exclude it for now. + BROKEN_STATIC_LIBS += splashscreen endif $(foreach module, $(STATIC_LIB_MODULES), \ @@ -99,6 +104,18 @@ else ifeq ($(call isTargetOs, linux), true) STATIC_LIBS := -Wl,--export-dynamic -Wl,--whole-archive $(STATIC_LIB_FILES) -Wl,--no-whole-archive else ifeq ($(call isTargetOs, windows), true) STATIC_LIBS := $(addprefix -wholearchive:, $(STATIC_LIB_FILES)) +else ifeq ($(call isTargetOs, aix), true) + # on AIX we have to generate export files for all static libs, because we have no whole-archive linker flag + $(foreach lib, $(STATIC_LIB_FILES), \ + $(eval $(call SetupExecute, generate_export_list_$(notdir $(lib)), \ + INFO := Generating export list for $(notdir $(lib)), \ + DEPS := $(lib), \ + OUTPUT_FILE := $(lib).exp, \ + COMMAND := ( $(AR) $(ARFLAGS) -w $(lib) | $(GREP) -v '^\.' | $(AWK) '{print $$1}' | $(SORT) -u > $(lib).exp ), \ + )) \ + $(eval STATIC_LIB_EXPORT_FILES += $(lib).exp) \ + ) + STATIC_LIBS := -Wl,-bexpfull $(STATIC_LIB_FILES) $(addprefix -Wl$(COMMA)-bE:, $(STATIC_LIB_EXPORT_FILES)) else $(error Unsupported platform) endif @@ -118,6 +135,9 @@ $(eval $(call SetupBuildLauncher, java, \ )) $(java): $(STATIC_LIB_FILES) +ifeq ($(call isTargetOs, aix), true) + $(java): $(STATIC_LIB_EXPORT_FILES) +endif TARGETS += $(java) diff --git a/make/modules/java.base/lib/CoreLibraries.gmk b/make/modules/java.base/lib/CoreLibraries.gmk index 1046b8f846c..316103be4cd 100644 --- a/make/modules/java.base/lib/CoreLibraries.gmk +++ b/make/modules/java.base/lib/CoreLibraries.gmk @@ -167,6 +167,14 @@ endif ifeq ($(call isTargetOs, aix), true) # AIX requires a static libjli because the compiler doesn't support '-rpath' BUILD_LIBJLI_TYPE := STATIC_LIBRARY + + # This is the object file to provide the dladdr API, which is not + # part of AIX. It occurs several times in the jdk code base. + # Do not include it. When statically linking the java + # launcher with all JDK and VM static libraries, we use the + # --whole-archive linker option. The duplicate objects in different + # static libraries cause linking errors due to duplicate symbols. + LIBJLI_STATIC_EXCLUDE_OBJS += java_md_aix.o endif $(eval $(call SetupJdkLibrary, BUILD_LIBJLI, \ diff --git a/make/modules/java.desktop/lib/AwtLibraries.gmk b/make/modules/java.desktop/lib/AwtLibraries.gmk index 23b1e6e9d59..5507c1d3edd 100644 --- a/make/modules/java.desktop/lib/AwtLibraries.gmk +++ b/make/modules/java.desktop/lib/AwtLibraries.gmk @@ -95,6 +95,16 @@ ifeq ($(call isTargetOs, windows), true) $(TOPDIR)/src/$(MODULE)/windows/native/libawt/windows/awt.rc endif +# This is the object file to provide the dladdr API, which is not +# part of AIX. It occurs several times in the jdk code base. +# Do not include it. When statically linking the java +# launcher with all JDK and VM static libraries, we use the +# --whole-archive linker option. The duplicate objects in different +# static libraries cause linking errors due to duplicate symbols. +ifeq ($(call isTargetOs, aix), true) + LIBAWT_STATIC_EXCLUDE_OBJS := porting_aix.o +endif + # -fgcse-after-reload improves performance of MaskFill in Java2D by 20% for # some gcc $(eval $(call SetupJdkLibrary, BUILD_LIBAWT, \ @@ -140,6 +150,7 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBAWT, \ user32.lib uuid.lib winmm.lib winspool.lib, \ VERSIONINFO_RESOURCE := $(LIBAWT_VERSIONINFO_RESOURCE), \ EXTRA_RCFLAGS := $(LIBAWT_RCFLAGS), \ + STATIC_LIB_EXCLUDE_OBJS := $(LIBAWT_STATIC_EXCLUDE_OBJS), \ )) TARGETS += $(BUILD_LIBAWT) diff --git a/src/hotspot/os/aix/loadlib_aix.cpp b/src/hotspot/os/aix/loadlib_aix.cpp index 2c38e1b637c..90a7271ad6d 100644 --- a/src/hotspot/os/aix/loadlib_aix.cpp +++ b/src/hotspot/os/aix/loadlib_aix.cpp @@ -42,6 +42,9 @@ // For loadquery() #include +// For getargs() +#include + // Use raw malloc instead of os::malloc - this code gets used for error reporting. // A class to "intern" eternal strings. @@ -205,6 +208,22 @@ static bool reload_table() { trcVerbose("loadquery buffer size is %zu.", buflen); + // the entry for the executable itself does not contain a path. + // instead we retrieve the path of the executable with the getargs API. + static char pgmpath[PATH_MAX+1] = ""; + static char* pgmbase = nullptr; + if (pgmpath[0] == 0) { + procentry64 PInfo; + PInfo.pi_pid = ::getpid(); + if (0 == ::getargs(&PInfo, sizeof(PInfo), (char*)pgmpath, PATH_MAX) && *pgmpath) { + pgmpath[PATH_MAX] = '\0'; + pgmbase = strrchr(pgmpath, '/'); + if (pgmbase != nullptr) { + pgmbase += 1; + } + } + } + // Iterate over the loadquery result. For details see sys/ldr.h on AIX. ldi = (struct ld_info*) buffer; @@ -223,7 +242,12 @@ static bool reload_table() { lm->data = ldi->ldinfo_dataorg; lm->data_len = ldi->ldinfo_datasize; - lm->path = g_stringlist.add(ldi->ldinfo_filename); + if (pgmbase != nullptr && 0 == strcmp(pgmbase, ldi->ldinfo_filename)) { + lm->path = g_stringlist.add(pgmpath); + } else { + lm->path = g_stringlist.add(ldi->ldinfo_filename); + } + if (!lm->path) { log_warning(os)("OOM."); free(lm);