On Tue, 31 Mar 2026 15:06:18 GMT, Matthias Baesken <[email protected]> wrote:

> When building a JVM with -ffunction-sections in the C/C++ compile flags, the 
> gtest os_linux.decoder_get_source_info_valid_vm fails and delivers another 
> result
> 
> 
> [ RUN ] os_linux.decoder_get_source_info_valid_vm
> test/hotspot/gtest/runtime/test_os_linux.cpp:404: Failure
> Expected equality of these values:
>   buf
>     Which is: "test_os_linux.cpp"
>   "jniCheck.hpp"
> 
> [ FAILED ] os_linux.decoder_get_source_info_valid_vm (20 ms)
> 
> 
> So for this compilation mode, it is probably better to avoid the check for 
> this specific header.

I tried unsetting the section flags for BUILD_GTEST_LIBJVM and this worked for 
me 

diff --git a/make/hotspot/lib/CompileGtest.gmk 
b/make/hotspot/lib/CompileGtest.gmk
index 4b21d481049..40993250135 100644
--- a/make/hotspot/lib/CompileGtest.gmk
+++ b/make/hotspot/lib/CompileGtest.gmk
@@ -45,6 +45,12 @@ else
   GTEST_COPY_DEBUG_SYMBOLS := false
 endif
 
+ifeq ($(ENABLE_LINKTIME_GC), true)
+ifeq ($(TOOLCHAIN_TYPE), gcc)
+  GTEST_LIBJVM_CFLAGS := -fno-function-sections -fno-data-sections
+endif
+endif
+
 
################################################################################
 ## Build libgtest
 
################################################################################
@@ -99,7 +105,7 @@ $(eval $(call SetupJdkLibrary, BUILD_GTEST_LIBJVM, \
     EXCLUDE_PATTERNS := $(JVM_EXCLUDE_PATTERNS), \
     EXTRA_OBJECT_FILES := $(BUILD_LIBJVM_ALL_OBJS), \
     DEFAULT_CFLAGS := false, \
-    CFLAGS := $(JVM_CFLAGS) \
+    CFLAGS := $(JVM_CFLAGS) $(GTEST_LIBJVM_CFLAGS) \
         -DHOTSPOT_GTEST \
         -I$(GTEST_FRAMEWORK_SRC)/googletest/include \
         -I$(GTEST_FRAMEWORK_SRC)/googlemock/include \


Should  I better use this approach  ?

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

PR Comment: https://git.openjdk.org/jdk/pull/30516#issuecomment-4223570316

Reply via email to