Skip to content

Commit f74269c

Browse files
Andrew Leonardadinn
Andrew Leonard
authored andcommitted
8288399: MacOS debug symbol files not always deterministic in reproducible builds
Backport-of: 6633855ca78ff0f5f1213a2a1424436678a30e55
1 parent 9168aa2 commit f74269c

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

make/autoconf/flags-cflags.m4

+12
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,18 @@ AC_DEFUN([FLAGS_SETUP_DEBUG_SYMBOLS],
116116
CFLAGS_DEBUG_SYMBOLS="-g"
117117
ASFLAGS_DEBUG_SYMBOLS="-g"
118118
elif test "x$TOOLCHAIN_TYPE" = xclang; then
119+
if test "x$ALLOW_ABSOLUTE_PATHS_IN_OUTPUT" = "xfalse"; then
120+
# Check if compiler supports -fdebug-prefix-map. If so, use that to make
121+
# the debug symbol paths resolve to paths relative to the workspace root.
122+
workspace_root_trailing_slash="${WORKSPACE_ROOT%/}/"
123+
DEBUG_PREFIX_CFLAGS="-fdebug-prefix-map=${workspace_root_trailing_slash}="
124+
FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${DEBUG_PREFIX_CFLAGS}],
125+
IF_FALSE: [
126+
DEBUG_PREFIX_CFLAGS=
127+
]
128+
)
129+
fi
130+
119131
CFLAGS_DEBUG_SYMBOLS="-g"
120132
ASFLAGS_DEBUG_SYMBOLS="-g"
121133
elif test "x$TOOLCHAIN_TYPE" = xxlc; then

make/common/NativeCompilation.gmk

+5-4
Original file line numberDiff line numberDiff line change
@@ -359,9 +359,9 @@ define SetupCompileNativeFileBody
359359
$1_FLAGS := $(BASIC_ASFLAGS) $$($1_BASE_ASFLAGS)
360360
$1_COMPILER := $(AS)
361361

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

0 commit comments

Comments
 (0)