8288399: MacOS debug symbol files not always deterministic in reproducible builds

Reviewed-by: erikj
This commit is contained in:
Andrew Leonard 2022-06-15 14:00:20 +00:00
parent d5cd2f2caa
commit 6633855ca7
2 changed files with 17 additions and 4 deletions

View File

@ -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

View File

@ -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)
@ -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