< prev index next >

make/launcher/LauncherCommon.gmk

Print this page
*** 76,10 ***
--- 76,11 ---
  # EXTRA_RC_FLAGS   Additional EXTRA_RC_FLAGS
  # MACOSX_PRIVILEGED   On macosx, allow to access other processes
  # OPTIMIZATION   Override default optimization level (LOW)
  # OUTPUT_DIR   Override default output directory
  # VERSION_INFO_RESOURCE   Override default Windows resource file
+ # INCLUDE_TSAN   If true, pass compiler and linker flags for TSAN.
  SetupBuildLauncher = $(NamedParamsMacroTemplate)
  define SetupBuildLauncherBody
    # Setup default values (unless overridden)
    ifeq ($$($1_OPTIMIZATION), )
      $1_OPTIMIZATION := LOW

*** 129,10 ***
--- 130,21 ---
  
    ifeq ($(USE_EXTERNAL_LIBZ), true)
      $1_LIBS += -lz
    endif
  
+   ifeq ($$($1_INCLUDE_TSAN), true)
+     $1_CFLAGS += -DINCLUDE_TSAN
+     # TSAN runtime needs to be statically or dynamically linked with the launcher
+     # instead of libjvm.so, because initialization of TSAN runtime has to happen
+     # early at program start.
+     # '-fsanitize=thread' works as a link-only flag for either GCC or Clang.
+     # With GCC, it dynamically links with libtsan.so; with Clang, it statically
+     # links the runtime into the launcher's executable.
+     $1_LDFLAGS += -fsanitize=thread
+   endif
+ 
    $1_WINDOWS_JLI_LIB := $(call FindStaticLib, java.base, jli, /libjli)
  
    $$(eval $$(call SetupJdkExecutable, BUILD_LAUNCHER_$1, \
        NAME := $1, \
        EXTRA_FILES := $(LAUNCHER_SRC)/main.c, \
< prev index next >