On Tue, 2 Dec 2025 15:43:00 GMT, Matthias Baesken <[email protected]> wrote:

>> 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

> 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 ?

I pointed this out because I observed it:


$ git status
On branch pull/28559
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        make/lto.o

nothing added to commit but untracked files present (use "git add" to track)


Neither `/tmp/lto.o` nor `$TOPDIR/make/lto.o` are acceptable locations for 
output files, temporary or not, from the build process.

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

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

Reply via email to