diff --git a/make/Hsdis.gmk b/make/Hsdis.gmk index 7496a3a2cf1..42d18d61901 100644 --- a/make/Hsdis.gmk +++ b/make/Hsdis.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -122,8 +122,8 @@ ifeq ($(HSDIS_BACKEND), binutils) TOOLCHAIN_TYPE := gcc OPENJDK_TARGET_OS := linux + OPENJDK_TARGET_OS_TYPE := unix CC_OUT_OPTION := -o$(SPACE) - LD_OUT_OPTION := -o$(SPACE) GENDEPS_FLAGS := -MMD -MF CFLAGS_DEBUG_SYMBOLS := -g DISABLED_WARNINGS := diff --git a/make/autoconf/buildjdk-spec.gmk.template b/make/autoconf/buildjdk-spec.gmk.template index 993ed503902..924389b94e8 100644 --- a/make/autoconf/buildjdk-spec.gmk.template +++ b/make/autoconf/buildjdk-spec.gmk.template @@ -1,5 +1,5 @@ # -# Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -40,6 +40,7 @@ LDCXX := @BUILD_LDCXX@ AS := @BUILD_AS@ NM := @BUILD_NM@ AR := @BUILD_AR@ +LIB := @BUILD_LIB@ OBJCOPY := @BUILD_OBJCOPY@ STRIP := @BUILD_STRIP@ SYSROOT_CFLAGS := @BUILD_SYSROOT_CFLAGS@ diff --git a/make/autoconf/flags-ldflags.m4 b/make/autoconf/flags-ldflags.m4 index 195c1d34159..58bc4a44bfb 100644 --- a/make/autoconf/flags-ldflags.m4 +++ b/make/autoconf/flags-ldflags.m4 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -93,7 +93,7 @@ AC_DEFUN([FLAGS_SETUP_LDFLAGS_HELPER], BASIC_LDFLAGS_JVM_ONLY="-Wl,-lC_r -bbigtoc" elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then - BASIC_LDFLAGS="-nologo -opt:ref" + BASIC_LDFLAGS="-opt:ref" BASIC_LDFLAGS_JDK_ONLY="-incremental:no" BASIC_LDFLAGS_JVM_ONLY="-opt:icf,8 -subsystem:windows" fi diff --git a/make/autoconf/flags-other.m4 b/make/autoconf/flags-other.m4 index 7e2521ffef3..8d4d405b076 100644 --- a/make/autoconf/flags-other.m4 +++ b/make/autoconf/flags-other.m4 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -33,9 +33,6 @@ AC_DEFUN([FLAGS_SETUP_ARFLAGS], # FIXME: figure out if we should select AR flags depending on OS or toolchain. if test "x$OPENJDK_TARGET_OS" = xaix; then ARFLAGS="-X64" - elif test "x$OPENJDK_TARGET_OS" = xwindows; then - # lib.exe is used as AR to create static libraries. - ARFLAGS="-nologo -NODEFAULTLIB:MSVCRT" else ARFLAGS="" fi @@ -43,6 +40,18 @@ AC_DEFUN([FLAGS_SETUP_ARFLAGS], AC_SUBST(ARFLAGS) ]) +AC_DEFUN([FLAGS_SETUP_LIBFLAGS], +[ + # LIB is used to create static libraries on Windows + if test "x$OPENJDK_TARGET_OS" = xwindows; then + LIBFLAGS="-nodefaultlib:msvcrt" + else + LIBFLAGS="" + fi + + AC_SUBST(LIBFLAGS) +]) + AC_DEFUN([FLAGS_SETUP_STRIPFLAGS], [ ## Setup strip. diff --git a/make/autoconf/flags.m4 b/make/autoconf/flags.m4 index 8c029f7d2f5..147382f398e 100644 --- a/make/autoconf/flags.m4 +++ b/make/autoconf/flags.m4 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -364,24 +364,12 @@ AC_DEFUN([FLAGS_SETUP_TOOLCHAIN_CONTROL], if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then CC_OUT_OPTION=-Fo - LD_OUT_OPTION=-out: - AR_OUT_OPTION=-out: else # The option used to specify the target .o,.a or .so file. # When compiling, how to specify the to be created object file. CC_OUT_OPTION='-o$(SPACE)' - # When linking, how to specify the output - LD_OUT_OPTION='-o$(SPACE)' - # When archiving, how to specify the destination static archive. - if test "x$OPENJDK_TARGET_OS" = xmacosx; then - AR_OUT_OPTION='-r -cs$(SPACE)' - else - AR_OUT_OPTION='-rcs$(SPACE)' - fi fi AC_SUBST(CC_OUT_OPTION) - AC_SUBST(LD_OUT_OPTION) - AC_SUBST(AR_OUT_OPTION) # Generate make dependency files if test "x$TOOLCHAIN_TYPE" = xgcc; then @@ -423,6 +411,7 @@ AC_DEFUN([FLAGS_SETUP_FLAGS], FLAGS_SETUP_LDFLAGS FLAGS_SETUP_ARFLAGS + FLAGS_SETUP_LIBFLAGS FLAGS_SETUP_STRIPFLAGS FLAGS_SETUP_RCFLAGS FLAGS_SETUP_NMFLAGS diff --git a/make/autoconf/spec.gmk.template b/make/autoconf/spec.gmk.template index e9d53fcd77a..249582a16b7 100644 --- a/make/autoconf/spec.gmk.template +++ b/make/autoconf/spec.gmk.template @@ -498,8 +498,6 @@ COMPILER_COMMAND_FILE_FLAG := @COMPILER_COMMAND_FILE_FLAG@ COMPILER_BINDCMD_FILE_FLAG := @COMPILER_BINDCMD_FILE_FLAG@ CC_OUT_OPTION := @CC_OUT_OPTION@ -LD_OUT_OPTION := @LD_OUT_OPTION@ -AR_OUT_OPTION := @AR_OUT_OPTION@ # Flags used for overriding the default opt setting for a C/C++ source file. C_O_FLAG_HIGHEST_JVM := @C_O_FLAG_HIGHEST_JVM@ @@ -604,10 +602,10 @@ BUILD_SYSROOT_LDFLAGS := @BUILD_SYSROOT_LDFLAGS@ AS := @AS@ -# AR is used to create a static library (is ar in unix, lib.exe in windows) AR := @AR@ ARFLAGS := @ARFLAGS@ - +LIB := @LIB@ +LIBFLAGS := @LIBFLAGS@ NM := @NM@ NMFLAGS := @NMFLAGS@ STRIP := @STRIP@ diff --git a/make/autoconf/toolchain.m4 b/make/autoconf/toolchain.m4 index 7a24815d163..6a29529c5c5 100644 --- a/make/autoconf/toolchain.m4 +++ b/make/autoconf/toolchain.m4 @@ -732,11 +732,10 @@ AC_DEFUN_ONCE([TOOLCHAIN_DETECT_TOOLCHAIN_CORE], AC_SUBST(AS) # - # Setup the archiver (AR) + # Setup tools for creating static libraries (AR/LIB) # if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then - # The corresponding ar tool is lib.exe (used to create static libraries) - UTIL_LOOKUP_TOOLCHAIN_PROGS(AR, lib) + UTIL_LOOKUP_TOOLCHAIN_PROGS(LIB, lib) elif test "x$TOOLCHAIN_TYPE" = xgcc; then UTIL_LOOKUP_TOOLCHAIN_PROGS(AR, ar gcc-ar) else diff --git a/make/common/NativeCompilation.gmk b/make/common/NativeCompilation.gmk index b9ea519cc3f..7b743216ee2 100644 --- a/make/common/NativeCompilation.gmk +++ b/make/common/NativeCompilation.gmk @@ -40,6 +40,7 @@ include native/CompileFile.gmk include native/DebugSymbols.gmk include native/Flags.gmk include native/Link.gmk +include native/LinkMicrosoft.gmk include native/Paths.gmk include native/ToolchainDefinitions.gmk @@ -72,7 +73,8 @@ include native/ToolchainDefinitions.gmk # used both for C and C++. # LIBS__ the libraries to link to for the specified target # OS and toolchain, used both for C and C++. -# ARFLAGS the archiver flags to be used +# ARFLAGS the archiver flags to be used on unix platforms +# LIBFLAGS the flags for the lib tool used on windows # OBJECT_DIR the directory where we store the object files # OUTPUT_DIR the directory where the resulting binary is put # SYMBOLS_DIR the directory where the debug symbols are put, defaults to OUTPUT_DIR @@ -198,12 +200,20 @@ define SetupNativeCompilationBody # Prepare for linking $$(eval $$(call SetupLinkerFlags,$1)) - $$(eval $$(call SetupLinking,$1)) + ifneq ($(TOOLCHAIN_TYPE), microsoft) + $$(eval $$(call SetupLinking,$1)) + else + $$(eval $$(call SetupLinkingMicrosoft,$1)) + endif $$(eval $$(call SetupObjectFileList,$1)) # Link the individually compiled files into a single unit - $$(eval $$(call CreateLinkedResult,$1)) + ifneq ($(TOOLCHAIN_TYPE), microsoft) + $$(eval $$(call CreateLinkedResult,$1)) + else + $$(eval $$(call CreateLinkedResultMicrosoft,$1)) + endif ifeq ($(GENERATE_COMPILE_COMMANDS_ONLY), true) # Override all targets (this is a hack) diff --git a/make/common/native/Link.gmk b/make/common/native/Link.gmk index 37291d496a6..4544dd054c3 100644 --- a/make/common/native/Link.gmk +++ b/make/common/native/Link.gmk @@ -62,11 +62,10 @@ define SetupLinking $$(call SetIfEmpty, $1_STRIP_SYMBOLS, $$($1_COPY_DEBUG_SYMBOLS)) ifneq ($$($1_STRIP_SYMBOLS), false) - 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 + # 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 endef @@ -81,7 +80,7 @@ endef ################################################################################ define CreateStaticLibrary - # Include partial linking when building the static library with clang on linux. + # Include partial linking when building the static library with clang on linux ifeq ($(call isTargetOs, linux), true) ifneq ($(findstring $(TOOLCHAIN_TYPE), clang), ) $1_ENABLE_PARTIAL_LINKING := true @@ -103,7 +102,8 @@ define CreateStaticLibrary endif endif - $1_TARGET_DEPS := $$($1_ALL_OBJS) $$($1_RES) $$($1_VARDEPS_FILE) $$(STATIC_MAPFILE_DEP) + $1_TARGET_DEPS := $$($1_ALL_OBJS) $$($1_RES) $$($1_VARDEPS_FILE) \ + $$(STATIC_MAPFILE_DEP) $1_AR_OBJ_ARG := $$($1_LD_OBJ_ARG) # With clang on linux, partial linking is enabled and 'AR' takes the output @@ -128,13 +128,13 @@ define CreateStaticLibrary $$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_partial_link, \ $(if $$($1_LINK_OBJS_RELATIVE), $$(CD) $$(OUTPUTDIR) ; ) \ $$($1_LD) $(LDFLAGS_CXX_PARTIAL_LINKING) $$($1_SYSROOT_LDFLAGS) \ - $(LD_OUT_OPTION)$$($1_TARGET_RELOCATABLE) \ + -o $$($1_TARGET_RELOCATABLE) \ $$($1_LD_OBJ_ARG)) endif $$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \ $(if $$($1_LINK_OBJS_RELATIVE), $$(CD) $$(OUTPUTDIR) ; ) \ - $$($1_AR) $$(ARFLAGS) $$($1_ARFLAGS) $(AR_OUT_OPTION)$$($1_TARGET) $$($1_AR_OBJ_ARG) \ - $$($1_RES)) + $$($1_AR) $$(ARFLAGS) $$($1_ARFLAGS) -r -cs $$($1_TARGET) \ + $$($1_AR_OBJ_ARG) $$($1_RES)) ifeq ($(STATIC_BUILD), true) ifeq ($$($1_USE_MAPFILE_FOR_SYMBOLS), true) $(CP) $$($1_MAPFILE) $$(@D)/$$(basename $$(@F)).symbols @@ -174,39 +174,13 @@ define CreateDynamicLibraryOrExecutable endif endif - ifeq ($(call isTargetOs, windows), true) - ifeq ($$($1_EMBED_MANIFEST), true) - $1_EXTRA_LDFLAGS += -manifest:embed - endif - - $1_IMPORT_LIBRARY := $$($1_OBJECT_DIR)/$$($1_NAME).lib - $1_EXTRA_LDFLAGS += "-implib:$$($1_IMPORT_LIBRARY)" - ifeq ($$($1_TYPE), LIBRARY) - # To properly trigger downstream dependants of the import library, just as - # for debug files, we must have a recipe in the rule. To avoid rerunning - # the recipe every time have it touch the target. If an import library - # file is deleted by something external, explicitly delete the target to - # trigger a rebuild of both. - ifneq ($$(wildcard $$($1_IMPORT_LIBRARY)), $$($1_IMPORT_LIBRARY)) - $$(call LogDebug, Deleting $$($1_BASENAME) because import library is missing) - $$(shell $(RM) $$($1_TARGET)) - endif - $$($1_IMPORT_LIBRARY): $$($1_TARGET) - $(TOUCH) $$@ - - $1 += $$($1_IMPORT_LIBRARY) - endif - endif - - $1_VARDEPS := $$($1_LD) $$($1_SYSROOT_LDFLAGS) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) \ - $$($1_LIBS) $$($1_EXTRA_LIBS) $$($1_MT) \ - $$($1_CREATE_DEBUGINFO_CMDS) $$($1_MANIFEST_VERSION) \ - $$($1_STRIP_CMD) $$($1_CREATE_DEBUGLINK_CMDS) + $1_VARDEPS := $$($1_LD) $$($1_SYSROOT_LDFLAGS) $$($1_LDFLAGS) \ + $$($1_EXTRA_LDFLAGS) $$($1_LIBS) $$($1_EXTRA_LIBS) \ + $$($1_CREATE_DEBUGINFO_CMDS) $$($1_STRIP_CMD) $$($1_CREATE_DEBUGLINK_CMDS) $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \ $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).vardeps) - $1_TARGET_DEPS := $$($1_ALL_OBJS) $$($1_RES) $$($1_MANIFEST) \ - $$($1_REAL_MAPFILE) $$($1_VARDEPS_FILE) + $1_TARGET_DEPS := $$($1_ALL_OBJS) $$($1_REAL_MAPFILE) $$($1_VARDEPS_FILE) $$($1_TARGET): $$($1_TARGET_DEPS) ifneq ($$($1_OBJ_FILE_LIST), ) @@ -216,47 +190,27 @@ define CreateDynamicLibraryOrExecutable $$(eval $$(call ListPathsSafely, $1_ALL_OBJS, $$($1_OBJ_FILE_LIST))) endif endif - # Keep as much as possible on one execution line for best performance - # on Windows $$(call LogInfo, Linking $$($1_BASENAME)) $$(call MakeDir, $$($1_OUTPUT_DIR) $$($1_SYMBOLS_DIR)) - ifeq ($(call isTargetOs, windows), true) - $$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \ - $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \ - $(LD_OUT_OPTION)$$($1_TARGET) $$($1_LD_OBJ_ARG) $$($1_RES) \ - $$($1_LIBS) $$($1_EXTRA_LIBS)) \ - | $(GREP) -v "^ Creating library .*\.lib and object .*\.exp" || \ - test "$$$$?" = "1" ; \ - $$($1_CREATE_DEBUGINFO_CMDS) - $$($1_STRIP_CMD) - $$($1_CREATE_DEBUGLINK_CMDS) - ifeq ($(call isBuildOsEnv, windows.wsl2), true) - $$(CHMOD) +x $$($1_TARGET) - endif - else - $$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \ - $$(if $$($1_LINK_OBJS_RELATIVE), $$(CD) $$(OUTPUTDIR) ; ) \ - $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \ - $(LD_OUT_OPTION)$$($1_TARGET) $$($1_LD_OBJ_ARG) $$($1_RES) \ - $$($1_LIBS) $$($1_EXTRA_LIBS)) ; \ - $$($1_CREATE_DEBUGINFO_CMDS) - $$($1_STRIP_CMD) - $$($1_CREATE_DEBUGLINK_CMDS) - endif - ifeq ($(call isTargetOs, windows), true) - ifneq ($$($1_MANIFEST), ) - $$($1_MT) -nologo -manifest $$($1_MANIFEST) -identity:"$$($1_NAME).exe, version=$$($1_MANIFEST_VERSION)" -outputresource:$$@;#1 - endif - endif + $$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \ + $$(if $$($1_LINK_OBJS_RELATIVE), $$(CD) $$(OUTPUTDIR) ; ) \ + $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) \ + $$($1_SYSROOT_LDFLAGS) -o $$($1_TARGET) $$($1_LD_OBJ_ARG) \ + $$($1_LIBS) $$($1_EXTRA_LIBS)) + $$($1_CREATE_DEBUGINFO_CMDS) + $$($1_STRIP_CMD) + $$($1_CREATE_DEBUGLINK_CMDS) # On macosx, optionally run codesign on every binary. # Remove signature explicitly first to avoid warnings if the linker # added a default adhoc signature. ifeq ($(MACOSX_CODESIGN_MODE), hardened) $(CODESIGN) --remove-signature $$@ - $(CODESIGN) -f -s "$(MACOSX_CODESIGN_IDENTITY)" --timestamp --options runtime \ - --entitlements $$(call GetEntitlementsFile, $$@) $$@ + $(CODESIGN) -f -s "$(MACOSX_CODESIGN_IDENTITY)" --timestamp \ + --options runtime --entitlements \ + $$(call GetEntitlementsFile, $$@) $$@ else ifeq ($(MACOSX_CODESIGN_MODE), debug) $(CODESIGN) --remove-signature $$@ - $(CODESIGN) -f -s - --entitlements $$(call GetEntitlementsFile, $$@) $$@ + $(CODESIGN) -f -s - --entitlements \ + $$(call GetEntitlementsFile, $$@) $$@ endif endef diff --git a/make/common/native/LinkMicrosoft.gmk b/make/common/native/LinkMicrosoft.gmk new file mode 100644 index 00000000000..949e4963a84 --- /dev/null +++ b/make/common/native/LinkMicrosoft.gmk @@ -0,0 +1,124 @@ +# +# Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +################################################################################ +# This file contains functionality related to linking a native binary; +# creating either a dynamic library, a static library or an executable. + + +################################################################################ +define SetupLinkingMicrosoft + ifneq ($(DISABLE_MAPFILES), true) + $1_REAL_MAPFILE := $$($1_MAPFILE) + endif + + ifneq ($$($1_REAL_MAPFILE), ) + $1_EXTRA_LDFLAGS += $(call SET_SHARED_LIBRARY_MAPFILE,$$($1_REAL_MAPFILE)) + endif +endef + +################################################################################ +define CreateLinkedResultMicrosoft + ifeq ($$($1_TYPE), STATIC_LIBRARY) + $$(eval $$(call CreateStaticLibraryMicrosoft,$1)) + else + $$(eval $$(call CreateDynamicLibraryOrExecutableMicrosoft,$1)) + endif +endef + +################################################################################ +define CreateStaticLibraryMicrosoft + $1_VARDEPS := $$($1_LIB) $$(LIBFLAGS) $$($1_LIBFLAGS) $$($1_LIBS) \ + $$($1_EXTRA_LIBS) + $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \ + $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).vardeps) + + $$($1_TARGET): $$($1_ALL_OBJS) $$($1_RES) $$($1_VARDEPS_FILE) + ifneq ($$($1_OBJ_FILE_LIST), ) + $$(eval $$(call ListPathsSafely, $1_ALL_OBJS, $$($1_OBJ_FILE_LIST))) + endif + $$(call LogInfo, Building static library $$($1_BASENAME)) + $$(call MakeDir, $$($1_OUTPUT_DIR) $$($1_SYMBOLS_DIR)) + $$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \ + $$($1_LIB) -nologo $$(LIBFLAGS) $$($1_LIBFLAGS) -out:$$($1_TARGET) \ + $$($1_LD_OBJ_ARG) $$($1_RES)) +endef + +################################################################################ +define CreateDynamicLibraryOrExecutableMicrosoft + ifeq ($$($1_EMBED_MANIFEST), true) + $1_EXTRA_LDFLAGS += -manifest:embed + endif + + $1_IMPORT_LIBRARY := $$($1_OBJECT_DIR)/$$($1_NAME).lib + $1_EXTRA_LDFLAGS += "-implib:$$($1_IMPORT_LIBRARY)" + + ifeq ($$($1_TYPE), LIBRARY) + # To properly trigger downstream dependants of the import library, just as + # for debug files, we must have a recipe in the rule. To avoid rerunning + # the recipe every time have it touch the target. If an import library + # file is deleted by something external, explicitly delete the target to + # trigger a rebuild of both. + ifneq ($$(wildcard $$($1_IMPORT_LIBRARY)), $$($1_IMPORT_LIBRARY)) + $$(call LogDebug, Deleting $$($1_BASENAME) because import library is missing) + $$(shell $(RM) $$($1_TARGET)) + endif + $$($1_IMPORT_LIBRARY): $$($1_TARGET) + $(TOUCH) $$@ + + $1 += $$($1_IMPORT_LIBRARY) + endif + + $1_VARDEPS := $$($1_LD) $$($1_SYSROOT_LDFLAGS) $$($1_LDFLAGS) \ + $$($1_EXTRA_LDFLAGS) $$($1_LIBS) $$($1_EXTRA_LIBS) $$($1_MT) \ + $$($1_MANIFEST_VERSION) + + $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \ + $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).vardeps) + + $1_TARGET_DEPS := $$($1_ALL_OBJS) $$($1_RES) $$($1_MANIFEST) \ + $$($1_REAL_MAPFILE) $$($1_VARDEPS_FILE) + + $$($1_TARGET): $$($1_TARGET_DEPS) + ifneq ($$($1_OBJ_FILE_LIST), ) + $$(eval $$(call ListPathsSafely, $1_ALL_OBJS, $$($1_OBJ_FILE_LIST))) + endif + $$(call LogInfo, Linking $$($1_BASENAME)) + $$(call MakeDir, $$($1_OUTPUT_DIR) $$($1_SYMBOLS_DIR)) + $$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \ + $$($1_LD) -nologo $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) \ + $$($1_SYSROOT_LDFLAGS) -out:$$($1_TARGET) $$($1_LD_OBJ_ARG) \ + $$($1_RES) $$($1_LIBS) $$($1_EXTRA_LIBS)) \ + | $(GREP) -v "^ Creating library .*\.lib and object .*\.exp" || \ + test "$$$$?" = "1" + ifeq ($(call isBuildOsEnv, windows.wsl2), true) + $$(CHMOD) +x $$($1_TARGET) + endif + ifneq ($$($1_MANIFEST), ) + $$($1_MT) -nologo -manifest $$($1_MANIFEST) \ + -identity:"$$($1_NAME).exe, version=$$($1_MANIFEST_VERSION)" \ + -outputresource:$$@;#1 + endif +endef diff --git a/make/common/native/ToolchainDefinitions.gmk b/make/common/native/ToolchainDefinitions.gmk index b640df83d6a..cac3632a218 100644 --- a/make/common/native/ToolchainDefinitions.gmk +++ b/make/common/native/ToolchainDefinitions.gmk @@ -39,6 +39,7 @@ # CXX - The C++ compiler # LD - The Linker # AR - Static linker +# LIB - lib, a Windows for creating static libraries # AS - Assembler # MT - Windows MT tool # RC - Windows RC tool @@ -56,6 +57,7 @@ define DefineNativeToolchainBody $$(call SetIfEmpty, $1_CXX, $$($$($1_EXTENDS)_CXX)) $$(call SetIfEmpty, $1_LD, $$($$($1_EXTENDS)_LD)) $$(call SetIfEmpty, $1_AR, $$($$($1_EXTENDS)_AR)) + $$(call SetIfEmpty, $1_LIB, $$($$($1_EXTENDS)_LIB)) $$(call SetIfEmpty, $1_AS, $$($$($1_EXTENDS)_AS)) $$(call SetIfEmpty, $1_MT, $$($$($1_EXTENDS)_MT)) $$(call SetIfEmpty, $1_RC, $$($$($1_EXTENDS)_RC)) @@ -72,6 +74,7 @@ $(eval $(call DefineNativeToolchain, TOOLCHAIN_DEFAULT, \ CXX := $(CXX), \ LD := $(LD), \ AR := $(AR), \ + LIB := $(LIB), \ AS := $(AS), \ MT := $(MT), \ RC := $(RC), \ @@ -94,6 +97,7 @@ $(eval $(call DefineNativeToolchain, TOOLCHAIN_BUILD, \ CXX := $(BUILD_CXX), \ LD := $(BUILD_LD), \ AR := $(BUILD_AR), \ + LIB := $(BUILD_LIB), \ AS := $(BUILD_AS), \ OBJCOPY := $(BUILD_OBJCOPY), \ STRIP := $(BUILD_STRIP), \ @@ -115,6 +119,7 @@ define SetupToolchain $$(call SetIfEmpty, $1_CXX, $$($$($1_TOOLCHAIN)_CXX)) $$(call SetIfEmpty, $1_LD, $$($$($1_TOOLCHAIN)_LD)) $$(call SetIfEmpty, $1_AR, $$($$($1_TOOLCHAIN)_AR)) + $$(call SetIfEmpty, $1_LIB, $$($$($1_TOOLCHAIN)_LIB)) $$(call SetIfEmpty, $1_AS, $$($$($1_TOOLCHAIN)_AS)) $$(call SetIfEmpty, $1_MT, $$($$($1_TOOLCHAIN)_MT)) $$(call SetIfEmpty, $1_RC, $$($$($1_TOOLCHAIN)_RC)) diff --git a/make/hotspot/gensrc/GensrcAdlc.gmk b/make/hotspot/gensrc/GensrcAdlc.gmk index bb356476847..34a4002fc12 100644 --- a/make/hotspot/gensrc/GensrcAdlc.gmk +++ b/make/hotspot/gensrc/GensrcAdlc.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -45,7 +45,6 @@ ifeq ($(call check-jvm-feature, compiler2), true) ADLC_CFLAGS := -qnortti -qeh -q64 -DAIX endif else ifeq ($(call isBuildOs, windows), true) - ADLC_LDFLAGS += -nologo ADLC_CFLAGS := -nologo -EHsc ADLC_CFLAGS_WARNINGS := -W3 -D_CRT_SECURE_NO_WARNINGS endif