RFR: 8372643: Warning message on macos when building the JDK - (arm64) /tmp/lto.o unable to open object file: No such file or directory

Matthias Baesken mbaesken at openjdk.org
Tue Dec 2 15:47:58 UTC 2025


On Tue, 2 Dec 2025 08:18:05 GMT, Matthias Baesken <mbaesken at openjdk.org> wrote:

>> make/autoconf/flags-ldflags.m4 line 83:
>> 
>>> 81:     else
>>> 82:       LDFLAGS_LTO="-flto=auto -fuse-linker-plugin -fno-strict-aliasing"
>>> 83:     fi
>> 
>> The way I understand this flag, we are defining a non temporary location for this file. Just specifying a file name without a directory path means it's relative to the directory where the compiler is running, which in our case is `make/`. We do not want to drop files in the source tree. Also, this file needs to be unique for each link unit using lto, so we can't have a global value defined here in configure. The filename needs to be generated uniquely into the build output dir for each call to SetupNativeCompilation.
>
> In the error/warning messages we got we saw `/tmp/lto.o` . Not sure if the files would show up under 'make' when giving no full path with this added flag, but if so this would not be very nice; but from my observations I never saw stored files. Can we somehow reference the build-target-dir in configure/autoconf files ?

We could set EXTRA_LDFLAGS_LTO for macos/clang and then use it later in make/common/native/Flags.gmk where we add a unique string for every lib built and also keep it away from the source dir


     LDFLAGS_LTO="-flto=auto -fuse-linker-plugin -fno-strict-aliasing"
+    EXTRA_LDFLAGS_LTO="-Wl,-object_path_lto,"
     LDFLAGS_CXX_PARTIAL_LINKING="$MACHINE_FLAG -r"
 
     if test "x$OPENJDK_TARGET_OS" = xlinux; then
@@ -159,6 +160,7 @@ AC_DEFUN([FLAGS_SETUP_LDFLAGS_HELPER],
   # Export some intermediate variables for compatibility
   LDFLAGS_CXX_JDK="$DEBUGLEVEL_LDFLAGS_JDK_ONLY"
   AC_SUBST(LDFLAGS_LTO)
+  AC_SUBST(EXTRA_LDFLAGS_LTO)
   AC_SUBST(LDFLAGS_CXX_JDK)
   AC_SUBST(LDFLAGS_CXX_PARTIAL_LINKING)
 ])
diff --git a/make/autoconf/spec.gmk.template b/make/autoconf/spec.gmk.template
index b3d58704c50..e4523a23e6e 100644
--- a/make/autoconf/spec.gmk.template
+++ b/make/autoconf/spec.gmk.template
@@ -592,6 +592,8 @@ LDFLAGS_CXX_PARTIAL_LINKING := @LDFLAGS_CXX_PARTIAL_LINKING@
 # LDFLAGS specific to link time optimization
 LDFLAGS_LTO := @LDFLAGS_LTO@
 
+EXTRA_LDFLAGS_LTO := @EXTRA_LDFLAGS_LTO@
+
 # Sometimes a different linker is needed for c++ libs
 LDCXX := @LDCXX@
 # The flags for linking libstdc++ linker.
diff --git a/make/common/native/Flags.gmk b/make/common/native/Flags.gmk
index 843701cb4db..ee96dbb5d11 100644
--- a/make/common/native/Flags.gmk
+++ b/make/common/native/Flags.gmk
@@ -229,6 +229,7 @@ define SetupLinkerFlags
   # TOOLCHAIN_TYPE plus OPENJDK_TARGET_OS
   ifeq ($$($1_LINK_TIME_OPTIMIZATION), true)
     $1_EXTRA_LDFLAGS += $(LDFLAGS_LTO)
+    $1_EXTRA_LDFLAGS += $(EXTRA_LDFLAGS_LTO)/tmp/$1.o
   endif

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/28559#discussion_r2581755075


More information about the build-dev mailing list