mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 23:02:20 +00:00
Bug 1420355 - Statically link DMD. r=njn
--HG-- extra : rebase_source : 8e7cf975d096116b666532f3fe8aa5a7f61b5725
This commit is contained in:
parent
50d09b60b0
commit
2b2a874b47
@ -68,9 +68,6 @@
|
||||
#ifndef MOZ_STATIC_JS
|
||||
@BINPATH@/@DLL_PREFIX@mozjs@DLL_SUFFIX@
|
||||
#endif
|
||||
#ifdef MOZ_DMD
|
||||
@BINPATH@/@DLL_PREFIX@dmd@DLL_SUFFIX@
|
||||
#endif
|
||||
#ifndef MOZ_SYSTEM_NSPR
|
||||
#ifndef MOZ_FOLD_LIBS
|
||||
@BINPATH@/@DLL_PREFIX@nspr4@DLL_SUFFIX@
|
||||
|
@ -183,33 +183,22 @@ class Automation(object):
|
||||
else:
|
||||
os.kill(self.pid, signal.SIGKILL)
|
||||
|
||||
def environment(self, env=None, xrePath=None, crashreporter=True, debugger=False, dmdPath=None, lsanPath=None, ubsanPath=None):
|
||||
def environment(self, env=None, xrePath=None, crashreporter=True, debugger=False, lsanPath=None, ubsanPath=None):
|
||||
if xrePath == None:
|
||||
xrePath = self.DIST_BIN
|
||||
if env == None:
|
||||
env = dict(os.environ)
|
||||
|
||||
ldLibraryPath = os.path.abspath(os.path.join(SCRIPT_DIR, xrePath))
|
||||
dmdLibrary = None
|
||||
preloadEnvVar = None
|
||||
if self.UNIXISH or self.IS_MAC:
|
||||
envVar = "LD_LIBRARY_PATH"
|
||||
preloadEnvVar = "LD_PRELOAD"
|
||||
if self.IS_MAC:
|
||||
envVar = "DYLD_LIBRARY_PATH"
|
||||
dmdLibrary = "libdmd.dylib"
|
||||
else: # unixish
|
||||
dmdLibrary = "libdmd.so"
|
||||
if envVar in env:
|
||||
ldLibraryPath = ldLibraryPath + ":" + env[envVar]
|
||||
env[envVar] = ldLibraryPath
|
||||
elif self.IS_WIN32:
|
||||
env["PATH"] = env["PATH"] + ";" + str(ldLibraryPath)
|
||||
dmdLibrary = "dmd.dll"
|
||||
preloadEnvVar = "MOZ_REPLACE_MALLOC_LIB"
|
||||
|
||||
if dmdPath and dmdLibrary and preloadEnvVar:
|
||||
env[preloadEnvVar] = os.path.join(dmdPath, dmdLibrary)
|
||||
|
||||
if crashreporter and not debugger:
|
||||
env['MOZ_CRASHREPORTER_NO_REPORT'] = '1'
|
||||
|
@ -60,15 +60,12 @@ class RemoteAutomation(Automation):
|
||||
self._remoteLog = logfile
|
||||
|
||||
# Set up what we need for the remote environment
|
||||
def environment(self, env=None, xrePath=None, crashreporter=True, debugger=False, dmdPath=None, lsanPath=None, ubsanPath=None):
|
||||
def environment(self, env=None, xrePath=None, crashreporter=True, debugger=False, lsanPath=None, ubsanPath=None):
|
||||
# Because we are running remote, we don't want to mimic the local env
|
||||
# so no copying of os.environ
|
||||
if env is None:
|
||||
env = {}
|
||||
|
||||
if dmdPath:
|
||||
env['MOZ_REPLACE_MALLOC_LIB'] = os.path.join(dmdPath, 'libdmd.so')
|
||||
|
||||
# Except for the mochitest results table hiding option, which isn't
|
||||
# passed to runtestsremote.py as an actual option, but through the
|
||||
# MOZ_HIDE_RESULTS_TABLE environment variable.
|
||||
|
@ -4877,6 +4877,9 @@ replace_malloc_init_funcs();
|
||||
#ifdef MOZ_REPLACE_MALLOC_STATIC
|
||||
extern "C" void
|
||||
logalloc_init(malloc_table_t*, ReplaceMallocBridge**);
|
||||
|
||||
extern "C" void
|
||||
dmd_init(malloc_table_t*, ReplaceMallocBridge**);
|
||||
#endif
|
||||
|
||||
bool
|
||||
@ -4913,6 +4916,11 @@ init()
|
||||
if (Equals(initialTable, gReplaceMallocTable)) {
|
||||
logalloc_init(&gReplaceMallocTable, &gReplaceMallocBridge);
|
||||
}
|
||||
#ifdef MOZ_DMD
|
||||
if (Equals(initialTable, gReplaceMallocTable)) {
|
||||
dmd_init(&gReplaceMallocTable, &gReplaceMallocBridge);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
replace_malloc_init_funcs();
|
||||
}
|
||||
|
@ -9,14 +9,18 @@ EXPORTS += [
|
||||
]
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
'../../../mfbt/HashFunctions.cpp',
|
||||
'../../../mfbt/JSONWriter.cpp',
|
||||
'../../../mfbt/Poison.cpp',
|
||||
'../../../mozglue/misc/StackWalk.cpp',
|
||||
'DMD.cpp',
|
||||
]
|
||||
|
||||
SharedLibrary('dmd')
|
||||
if not CONFIG['MOZ_REPLACE_MALLOC_STATIC']:
|
||||
UNIFIED_SOURCES += [
|
||||
'/mfbt/HashFunctions.cpp',
|
||||
'/mfbt/JSONWriter.cpp',
|
||||
'/mfbt/Poison.cpp',
|
||||
'/mozglue/misc/StackWalk.cpp',
|
||||
]
|
||||
|
||||
ReplaceMalloc('dmd')
|
||||
|
||||
DEFINES['MOZ_NO_MOZALLOC'] = True
|
||||
DEFINES['IMPL_MFBT'] = True
|
||||
|
@ -137,7 +137,6 @@ function run_test() {
|
||||
// asynchronously.
|
||||
|
||||
gEnv.set('DMD', '1');
|
||||
gEnv.set(gEnv.get("DMD_PRELOAD_VAR"), gEnv.get("DMD_PRELOAD_VALUE"));
|
||||
|
||||
runProcess(gDmdTestFile, []);
|
||||
|
||||
|
@ -12,6 +12,14 @@ SOURCES += [
|
||||
'Replay.cpp',
|
||||
]
|
||||
|
||||
if CONFIG['MOZ_REPLACE_MALLOC_STATIC'] and CONFIG['MOZ_DMD']:
|
||||
UNIFIED_SOURCES += [
|
||||
'/mfbt/HashFunctions.cpp',
|
||||
'/mfbt/JSONWriter.cpp',
|
||||
'/mfbt/Poison.cpp',
|
||||
'/mozglue/misc/StackWalk.cpp',
|
||||
]
|
||||
|
||||
if not CONFIG['MOZ_REPLACE_MALLOC_STATIC']:
|
||||
SOURCES += [
|
||||
'../FdPrintf.cpp',
|
||||
|
@ -920,35 +920,10 @@ class RunProgram(MachCommandBase):
|
||||
if show_dump_stats:
|
||||
dmd_params.append('--show-dump-stats=yes')
|
||||
|
||||
bin_dir = os.path.dirname(binpath)
|
||||
lib_name = self.substs['DLL_PREFIX'] + 'dmd' + self.substs['DLL_SUFFIX']
|
||||
dmd_lib = os.path.join(bin_dir, lib_name)
|
||||
if not os.path.exists(dmd_lib):
|
||||
print("Please build with |--enable-dmd| to use DMD.")
|
||||
return 1
|
||||
|
||||
env_vars = {
|
||||
"Darwin": {
|
||||
"DYLD_INSERT_LIBRARIES": dmd_lib,
|
||||
"LD_LIBRARY_PATH": bin_dir,
|
||||
},
|
||||
"Linux": {
|
||||
"LD_PRELOAD": dmd_lib,
|
||||
"LD_LIBRARY_PATH": bin_dir,
|
||||
},
|
||||
"WINNT": {
|
||||
"MOZ_REPLACE_MALLOC_LIB": dmd_lib,
|
||||
},
|
||||
}
|
||||
|
||||
arch = self.substs['OS_ARCH']
|
||||
|
||||
if dmd_params:
|
||||
env_vars[arch]["DMD"] = " ".join(dmd_params)
|
||||
extra_env['DMD'] = ' '.join(dmd_params)
|
||||
else:
|
||||
env_vars[arch]["DMD"] = "1"
|
||||
|
||||
extra_env.update(env_vars.get(arch, {}))
|
||||
extra_env['DMD'] = '1'
|
||||
|
||||
return self.run_process(args=args, ensure_exit_code=False,
|
||||
pass_thru=True, append_env=extra_env)
|
||||
|
@ -144,32 +144,8 @@ class MachCommands(MachCommandBase):
|
||||
|
||||
# Setup DMD env vars if necessary.
|
||||
if kwargs['dmd']:
|
||||
dmd_params = []
|
||||
|
||||
bin_dir = os.path.dirname(binary)
|
||||
lib_name = self.substs['DLL_PREFIX'] + 'dmd' + self.substs['DLL_SUFFIX']
|
||||
dmd_lib = os.path.join(bin_dir, lib_name)
|
||||
if not os.path.exists(dmd_lib):
|
||||
print("Please build with |--enable-dmd| to use DMD.")
|
||||
return 1
|
||||
|
||||
env_vars = {
|
||||
"Darwin": {
|
||||
"DYLD_INSERT_LIBRARIES": dmd_lib,
|
||||
"LD_LIBRARY_PATH": bin_dir,
|
||||
},
|
||||
"Linux": {
|
||||
"LD_PRELOAD": dmd_lib,
|
||||
"LD_LIBRARY_PATH": bin_dir,
|
||||
},
|
||||
"WINNT": {
|
||||
"MOZ_REPLACE_MALLOC_LIB": dmd_lib,
|
||||
},
|
||||
}
|
||||
|
||||
arch = self.substs['OS_ARCH']
|
||||
for k, v in env_vars[arch].iteritems():
|
||||
os.environ[k] = v
|
||||
if 'DMD' not in os.environ:
|
||||
os.environ['DMD'] = '1'
|
||||
|
||||
|
@ -434,12 +434,6 @@ class MochitestArguments(ArgumentContainer):
|
||||
"default": False,
|
||||
"help": "Run tests with DMD active.",
|
||||
}],
|
||||
[["--dmd-path"],
|
||||
{"default": None,
|
||||
"dest": "dmdPath",
|
||||
"help": "Specifies the path to the directory containing the shared library for DMD.",
|
||||
"suppress": True,
|
||||
}],
|
||||
[["--dump-output-directory"],
|
||||
{"default": None,
|
||||
"dest": "dumpOutputDirectory",
|
||||
@ -701,16 +695,6 @@ class MochitestArguments(ArgumentContainer):
|
||||
if options.profilePath:
|
||||
options.profilePath = self.get_full_path(options.profilePath, parser.oldcwd)
|
||||
|
||||
if options.dmdPath:
|
||||
options.dmdPath = self.get_full_path(options.dmdPath, parser.oldcwd)
|
||||
|
||||
if options.dmd and not options.dmdPath:
|
||||
if build_obj:
|
||||
options.dmdPath = build_obj.bindir
|
||||
else:
|
||||
parser.error(
|
||||
"could not find dmd libraries, specify them with --dmd-path")
|
||||
|
||||
if options.utilityPath:
|
||||
options.utilityPath = self.get_full_path(options.utilityPath, parser.oldcwd)
|
||||
|
||||
|
@ -1622,7 +1622,6 @@ toolbar#nav-bar {
|
||||
xrePath=options.xrePath,
|
||||
env=env,
|
||||
debugger=debugger,
|
||||
dmdPath=options.dmdPath,
|
||||
lsanPath=lsanPath,
|
||||
ubsanPath=ubsanPath)
|
||||
|
||||
|
@ -356,13 +356,6 @@ def run_test_harness(parser, options):
|
||||
mozinfo.info['android_version'] = androidVersion
|
||||
|
||||
deviceRoot = dm.deviceRoot
|
||||
if options.dmdPath:
|
||||
dmdLibrary = "libdmd.so"
|
||||
dmdPathOnDevice = os.path.join(deviceRoot, dmdLibrary)
|
||||
dm.removeFile(dmdPathOnDevice)
|
||||
dm.pushFile(os.path.join(options.dmdPath, dmdLibrary), dmdPathOnDevice)
|
||||
options.dmdPath = deviceRoot
|
||||
|
||||
options.dumpOutputDirectory = deviceRoot
|
||||
|
||||
procName = options.app.split('/')[-1]
|
||||
|
@ -84,7 +84,7 @@ def _raw_log():
|
||||
|
||||
|
||||
def test_environment(xrePath, env=None, crashreporter=True, debugger=False,
|
||||
dmdPath=None, lsanPath=None, ubsanPath=None, log=None):
|
||||
lsanPath=None, ubsanPath=None, log=None):
|
||||
"""
|
||||
populate OS environment variables for mochitest and reftests.
|
||||
|
||||
@ -102,29 +102,18 @@ def test_environment(xrePath, env=None, crashreporter=True, debugger=False,
|
||||
ldLibraryPath = xrePath
|
||||
|
||||
envVar = None
|
||||
dmdLibrary = None
|
||||
preloadEnvVar = None
|
||||
if mozinfo.isUnix:
|
||||
envVar = "LD_LIBRARY_PATH"
|
||||
dmdLibrary = "libdmd.so"
|
||||
preloadEnvVar = "LD_PRELOAD"
|
||||
elif mozinfo.isMac:
|
||||
envVar = "DYLD_LIBRARY_PATH"
|
||||
dmdLibrary = "libdmd.dylib"
|
||||
preloadEnvVar = "DYLD_INSERT_LIBRARIES"
|
||||
elif mozinfo.isWin:
|
||||
envVar = "PATH"
|
||||
dmdLibrary = "dmd.dll"
|
||||
preloadEnvVar = "MOZ_REPLACE_MALLOC_LIB"
|
||||
if envVar:
|
||||
envValue = ((env.get(envVar), str(ldLibraryPath))
|
||||
if mozinfo.isWin
|
||||
else (ldLibraryPath, dmdPath, env.get(envVar)))
|
||||
else (ldLibraryPath, env.get(envVar)))
|
||||
env[envVar] = os.path.pathsep.join([path for path in envValue if path])
|
||||
|
||||
if dmdPath and dmdLibrary and preloadEnvVar:
|
||||
env[preloadEnvVar] = os.path.join(dmdPath, dmdLibrary)
|
||||
|
||||
# crashreporter
|
||||
env['GNOME_DISABLE_CRASH_DIALOG'] = '1'
|
||||
env['XRE_NO_WINDOWS_CRASH_DIALOG'] = '1'
|
||||
|
@ -653,23 +653,8 @@ class XPCShellTestThread(Thread):
|
||||
self.complete_command = cmdH + cmdT + cmdI + args
|
||||
|
||||
if self.test_object.get('dmd') == 'true':
|
||||
if sys.platform.startswith('linux'):
|
||||
preloadEnvVar = 'LD_PRELOAD'
|
||||
libdmd = os.path.join(self.xrePath, 'libdmd.so')
|
||||
elif sys.platform == 'osx' or sys.platform == 'darwin':
|
||||
preloadEnvVar = 'DYLD_INSERT_LIBRARIES'
|
||||
# self.xrePath is <prefix>/Contents/Resources.
|
||||
# We need <prefix>/Contents/MacOS/libdmd.dylib.
|
||||
contents_dir = os.path.dirname(self.xrePath)
|
||||
libdmd = os.path.join(contents_dir, 'MacOS', 'libdmd.dylib')
|
||||
elif sys.platform == 'win32':
|
||||
preloadEnvVar = 'MOZ_REPLACE_MALLOC_LIB'
|
||||
libdmd = os.path.join(self.xrePath, 'dmd.dll')
|
||||
|
||||
self.env['PYTHON'] = sys.executable
|
||||
self.env['BREAKPAD_SYMBOLS_PATH'] = self.symbolsPath
|
||||
self.env['DMD_PRELOAD_VAR'] = preloadEnvVar
|
||||
self.env['DMD_PRELOAD_VALUE'] = libdmd
|
||||
|
||||
if self.test_object.get('subprocess') == 'true':
|
||||
self.env['PYTHON'] = sys.executable
|
||||
|
Loading…
Reference in New Issue
Block a user