Skip to content

Commit

Permalink
8288399: MacOS debug symbol files not always deterministic in reprodu…
Browse files Browse the repository at this point in the history
…cible builds

Backport-of: 6633855ca78ff0f5f1213a2a1424436678a30e55
  • Loading branch information
Andrew Leonard authored and adinn committed Aug 8, 2022
1 parent 9168aa2 commit f74269c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
12 changes: 12 additions & 0 deletions make/autoconf/flags-cflags.m4
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,18 @@ AC_DEFUN([FLAGS_SETUP_DEBUG_SYMBOLS],
CFLAGS_DEBUG_SYMBOLS="-g"
ASFLAGS_DEBUG_SYMBOLS="-g"
elif test "x$TOOLCHAIN_TYPE" = xclang; then
if test "x$ALLOW_ABSOLUTE_PATHS_IN_OUTPUT" = "xfalse"; then
# Check if compiler supports -fdebug-prefix-map. If so, use that to make
# the debug symbol paths resolve to paths relative to the workspace root.
workspace_root_trailing_slash="${WORKSPACE_ROOT%/}/"
DEBUG_PREFIX_CFLAGS="-fdebug-prefix-map=${workspace_root_trailing_slash}="
FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${DEBUG_PREFIX_CFLAGS}],
IF_FALSE: [
DEBUG_PREFIX_CFLAGS=
]
)
fi
CFLAGS_DEBUG_SYMBOLS="-g"
ASFLAGS_DEBUG_SYMBOLS="-g"
elif test "x$TOOLCHAIN_TYPE" = xxlc; then
Expand Down
9 changes: 5 additions & 4 deletions make/common/NativeCompilation.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,9 @@ define SetupCompileNativeFileBody
$1_FLAGS := $(BASIC_ASFLAGS) $$($1_BASE_ASFLAGS)
$1_COMPILER := $(AS)

# gcc assembly files must contain an appropriate relative .file
# gcc or clang assembly files must contain an appropriate relative .file
# path for reproducible builds.
ifeq ($(TOOLCHAIN_TYPE), gcc)
ifneq ($(findstring $(TOOLCHAIN_TYPE), gcc clang), )
# If no absolute paths allowed, work out relative source file path
# for assembly .file substitution, otherwise use full file path
ifeq ($(ALLOW_ABSOLUTE_PATHS_IN_OUTPUT), false)
Expand Down Expand Up @@ -403,8 +403,9 @@ define SetupCompileNativeFileBody
$1_OBJ_DEPS := $$($1_SRC_FILE) $$($$($1_BASE)_COMPILE_VARDEPS_FILE) \
$$($$($1_BASE)_EXTRA_DEPS) $$($1_VARDEPS_FILE)
$1_COMPILE_OPTIONS := $$($1_FLAGS) $(CC_OUT_OPTION)$$($1_OBJ) $$($1_SRC_FILE)
# For reproducible builds with gcc ensure random symbol generation is seeded deterministically
ifeq ($(TOOLCHAIN_TYPE), gcc)
# For reproducible builds with gcc and clang ensure random symbol generation is
# seeded deterministically
ifneq ($(findstring $(TOOLCHAIN_TYPE), gcc clang), )
ifeq ($$(ENABLE_REPRODUCIBLE_BUILD), true)
$1_COMPILE_OPTIONS += -frandom-seed="$$($1_FILENAME)"
endif
Expand Down

1 comment on commit f74269c

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.