Skip to content

Commit

Permalink
8300592: ASan build does not correctly propagate options to some test…
Browse files Browse the repository at this point in the history
… launchers

Reviewed-by: ihse
  • Loading branch information
jcking authored and magicus committed Jan 25, 2023
1 parent e80b5ea commit edf1e1a
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 2 deletions.
1 change: 0 additions & 1 deletion make/autoconf/jdk-options.m4
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,6 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_ADDRESS_SANITIZER],
LDFLAGS_JDKLIB="$LDFLAGS_JDKLIB $ASAN_LDFLAGS"
LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE $ASAN_LDFLAGS"
])
AC_SUBST(ASAN_ENABLED)
])

Expand Down
3 changes: 2 additions & 1 deletion make/common/TestFilesCompilation.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ include NativeCompilation.gmk
# SOURCE_DIRS A list of source directories to search
# OUTPUT_DIR Where to put the resulting files
# EXCLUDE A list of filenames to exclude from compilation
# EXTRA_FILES List of extra files not in SOURCE_DIRS
SetupTestFilesCompilation = $(NamedParamsMacroTemplate)
define SetupTestFilesCompilationBody

Expand Down Expand Up @@ -93,7 +94,7 @@ define SetupTestFilesCompilationBody
$$(eval $$(call SetupNativeCompilation, BUILD_TEST_$$(name), \
NAME := $$(unprefixed_name), \
TYPE := $$($1_COMPILATION_TYPE), \
EXTRA_FILES := $$(file), \
EXTRA_FILES := $$(file) $$($1_EXTRA_FILES), \
OBJECT_DIR := $$($1_OUTPUT_DIR)/support/$$(name), \
OUTPUT_DIR := $$($1_OUTPUT_DIR)/$$($1_OUTPUT_SUBDIR), \
CFLAGS := $$($1_BASE_CFLAGS) $$($1_CFLAGS) $$($1_CFLAGS_$$(name)), \
Expand Down
30 changes: 30 additions & 0 deletions make/data/asan/asan_default_options.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2022, 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.
*/

extern "C" {

#include "./asan_default_options.c"

} // extern "C"
4 changes: 4 additions & 0 deletions make/hotspot/lib/CompileGtest.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ $(eval $(call IncludeCustomExtension, hotspot/lib/CompileGtest.gmk))
GTEST_TEST_SRC += $(TOPDIR)/test/hotspot/gtest
GTEST_LAUNCHER_SRC := $(TOPDIR)/test/hotspot/gtest/gtestLauncher.cpp

ifeq ($(ASAN_ENABLED), true)
GTEST_LAUNCHER_SRC += $(TOPDIR)/make/data/asan/asan_default_options.cpp
endif

# On Windows, there are no internal debug symbols so must set copying to true
# to get any at all.
ifeq ($(call isTargetOs, windows), true)
Expand Down
7 changes: 7 additions & 0 deletions make/test/JtregNativeHotspot.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -1518,6 +1518,12 @@ else
BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libnativeStack += -lpthread
endif

ifeq ($(ASAN_ENABLED), true)
# Any executable which launches the JVM and uses a custom launcher needs to explicitly link in the
# default ASan options.
BUILD_HOTSPOT_JTREG_EXTRA_FILES := $(TOPDIR)/make/data/asan/asan_default_options.c
endif

# This evaluation is expensive and should only be done if this target was
# explicitly called.
ifneq ($(filter build-test-hotspot-jtreg-native, $(MAKECMDGOALS)), )
Expand All @@ -1533,6 +1539,7 @@ ifneq ($(filter build-test-hotspot-jtreg-native, $(MAKECMDGOALS)), )
SOURCE_DIRS := $(BUILD_HOTSPOT_JTREG_NATIVE_SRC), \
OUTPUT_DIR := $(BUILD_HOTSPOT_JTREG_OUTPUT_DIR), \
EXCLUDE := $(BUILD_HOTSPOT_JTREG_EXCLUDE), \
EXTRA_FILES := $(BUILD_HOTSPOT_JTREG_EXTRA_FILES), \
))
endif

Expand Down
7 changes: 7 additions & 0 deletions make/test/JtregNativeJdk.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ ifeq ($(call isTargetOs, linux), true)
BUILD_JDK_JTREG_LIBRARIES_STRIP_SYMBOLS_libFib := false
endif

ifeq ($(ASAN_ENABLED), true)
# Any executable which launches the JVM and uses a custom launcher needs to explicitly link in the
# default ASan options.
BUILD_JDK_JTREG_EXTRA_FILES := $(TOPDIR)/make/data/asan/asan_default_options.c
endif

# This evaluation is expensive and should only be done if this target was
# explicitly called.
ifneq ($(filter build-test-jdk-jtreg-native, $(MAKECMDGOALS)), )
Expand All @@ -147,6 +153,7 @@ ifneq ($(filter build-test-jdk-jtreg-native, $(MAKECMDGOALS)), )
SOURCE_DIRS := $(BUILD_JDK_JTREG_NATIVE_SRC), \
OUTPUT_DIR := $(BUILD_JDK_JTREG_OUTPUT_DIR), \
EXCLUDE := $(BUILD_JDK_JTREG_EXCLUDE), \
EXTRA_FILES := $(BUILD_JDK_JTREG_EXTRA_FILES), \
))
endif

Expand Down

0 comments on commit edf1e1a

Please sign in to comment.