Bug 1514965 - Part 2: Enable clang -ftrivial-auto-var-init to initialize local variables with 0xAA in debug builds. r=froydnj

Disable -ftrivial-auto-var-init for DllBLocklistWin.cpp with clang-cl because the file's interceptions happen so early in the main process that the loader hasn't yet resolved the import of memset (used by -ftrivial-auto-var-init) from vcruntime140.dll.

Disable -ftrivial-auto-var-init on Linux32 because it causes some xpcshell test failures.

Differential Revision: https://phabricator.services.mozilla.com/D42273

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Chris Peterson 2019-08-21 07:08:29 +00:00
Родитель 539da64637
Коммит 41241f3418
2 изменённых файлов: 28 добавлений и 2 удалений

Просмотреть файл

@ -32,6 +32,19 @@ if CONFIG['CC_TYPE'] == 'clang-cl':
else:
SOURCES['DllBlocklistWin.cpp'].flags += ['-ffreestanding']
# Disable -ftrivial-auto-var-init=pattern for DllBlocklistWin.cpp because
# the file's interceptions happen so early in the main process that the
# loader hasn't yet resolved the import of memset (used by
# -ftrivial-auto-var-init) from vcruntime140.dll.
if CONFIG['CC_TYPE'] == 'clang-cl':
SOURCES['DllBlocklistWin.cpp'].flags += [
'-Xclang', '-ftrivial-auto-var-init=uninitialized',
]
else:
SOURCES['DllBlocklistWin.cpp'].flags += [
'-ftrivial-auto-var-init=uninitialized',
]
OS_LIBS += [
'ntdll',
'oleaut32',

Просмотреть файл

@ -1545,8 +1545,9 @@ option('--enable-hardening', env='MOZ_SECURITY_HARDENING',
# possible security flags will be omitted by --disable-hardening, as many are
# compiler-default options we do not explicitly enable.)
@depends('--enable-hardening', '--enable-address-sanitizer',
'--enable-optimize', c_compiler, target)
def security_hardening_cflags(hardening_flag, asan, optimize, c_compiler, target):
'--enable-debug', '--enable-optimize', c_compiler, target)
def security_hardening_cflags(hardening_flag, asan, debug, optimize, c_compiler,
target):
compiler_is_gccish = c_compiler.type in ('gcc', 'clang')
flags = []
@ -1580,6 +1581,18 @@ def security_hardening_cflags(hardening_flag, asan, optimize, c_compiler, target
js_flags.append("-fstack-protector-strong")
js_ldflags.append("-fstack-protector-strong")
# ftrivial-auto-var-init ------------------------------
# Initialize local variables with a 0xAA pattern in clang debug builds.
# Linux32 fails some xpcshell tests with -ftrivial-auto-var-init
linux32 = target.kernel == 'Linux' and target.cpu == 'x86'
if (c_compiler.type == 'clang' or c_compiler.type == 'clang-cl') and \
c_compiler.version >= '8' and debug and not linux32:
if c_compiler.type == 'clang-cl':
flags.append('-Xclang')
js_flags.append('-Xclang')
flags.append('-ftrivial-auto-var-init=pattern')
js_flags.append('-ftrivial-auto-var-init=pattern')
# ASLR ------------------------------------------------
# ASLR (dynamicbase) is enabled by default in clang-cl; but the
# mingw-clang build requires it to be explicitly enabled