moz.build (3881B)
1 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- 2 # vim: set filetype=python: 3 # This Source Code Form is subject to the terms of the Mozilla Public 4 # License, v. 2.0. If a copy of the MPL was not distributed with this 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 6 7 Program("logalloc-replay") 8 9 SOURCES += [ 10 "/mfbt/Assertions.cpp", 11 "/mfbt/Poison.cpp", 12 "/mfbt/RandomNum.cpp", 13 "/mfbt/RefCounted.cpp", 14 "/mfbt/TaggedAnonymousMemory.cpp", 15 "/mozglue/misc/StackWalk.cpp", 16 "Replay.cpp", 17 ] 18 19 if CONFIG["OS_TARGET"] == "WINNT": 20 SOURCES += [ 21 "/mozglue/misc/ProcessType.cpp", 22 ] 23 24 if CONFIG["OS_TARGET"] == "Linux": 25 LDFLAGS += ["-static-libstdc++"] 26 27 if CONFIG["OS_TARGET"] == "Darwin": 28 # Work around "warning: 'aligned_alloc' is only available on macOS 10.15 or newer" 29 # when building with MACOSX_DEPLOYMENT_TARGET < 10.15 with >= 10.15 SDK. 30 # We have our own definition of the function, so it doesn't matter what the SDK says. 31 SOURCES["Replay.cpp"].flags += ["-Wno-unguarded-availability-new"] 32 elif CONFIG["OS_TARGET"] == "Android": 33 # Work around "warning: 'aligned_alloc' is only available on Android 27 or 34 # lower. We have our own definition of the function, so it doesn't matter. 35 SOURCES["Replay.cpp"].flags += ["-Wno-unguarded-availability"] 36 37 38 if CONFIG["MOZ_REPLACE_MALLOC_STATIC"] and (CONFIG["MOZ_DMD"] or CONFIG["MOZ_PHC"]): 39 UNIFIED_SOURCES += [ 40 "/mfbt/HashFunctions.cpp", 41 ] 42 43 if CONFIG["OS_ARCH"] == "WINNT": 44 OS_LIBS += [ 45 "advapi32", 46 "dbghelp", 47 ] 48 49 if CONFIG["MOZ_LINKER"] and CONFIG["MOZ_WIDGET_TOOLKIT"] == "android": 50 LOCAL_INCLUDES += [ 51 "/mozglue/linker", 52 ] 53 DEFINES["__wrap_dladdr"] = "dladdr" 54 55 56 if CONFIG["MOZ_BUILD_APP"] == "memory": 57 EXPORTS.mozilla += [ 58 "/mozglue/misc/StackWalk.h", 59 ] 60 61 if CONFIG["MOZ_BUILD_APP"] == "memory" or CONFIG["MOZ_REPLACE_MALLOC_STATIC"]: 62 UNIFIED_SOURCES += [ 63 "/mfbt/double-conversion/double-conversion/bignum-dtoa.cc", 64 "/mfbt/double-conversion/double-conversion/bignum.cc", 65 "/mfbt/double-conversion/double-conversion/cached-powers.cc", 66 "/mfbt/double-conversion/double-conversion/double-to-string.cc", 67 "/mfbt/double-conversion/double-conversion/fast-dtoa.cc", 68 "/mfbt/double-conversion/double-conversion/fixed-dtoa.cc", 69 "/mfbt/double-conversion/double-conversion/string-to-double.cc", 70 "/mfbt/double-conversion/double-conversion/strtod.cc", 71 "/mozglue/misc/Printf.cpp", 72 ] 73 74 LOCAL_INCLUDES += [ 75 "/memory/build", 76 ] 77 78 # Link replace-malloc and the default allocator. 79 USE_LIBS += [ 80 "memory", 81 ] 82 83 # The memory library defines this, so it's needed here too. 84 DEFINES["IMPL_MFBT"] = True 85 86 DEFINES["MOZ_SUPPORT_LEAKCHECKING"] = True 87 88 OS_LIBS += CONFIG["LIBATOMIC_LIBS"] 89 90 OS_LIBS += CONFIG["DL_LIBS"] 91 92 DisableStlWrapping() 93 94 include("/mozglue/build/replace_malloc.mozbuild") 95 include("/mozglue/misc/timestamp.mozbuild") 96 97 98 if not CONFIG["MOZ_CODE_COVERAGE"] and not CONFIG["CROSS_COMPILE"]: 99 if not CONFIG["MOZ_REPLACE_MALLOC_STATIC"]: 100 if CONFIG["OS_TARGET"] == "WINNT": 101 logalloc_var = "MOZ_REPLACE_MALLOC_LIB" 102 elif CONFIG["OS_TARGET"] == "Darwin": 103 logalloc_var = "DYLD_INSERT_LIBRARIES" 104 else: 105 logalloc_var = "LD_PRELOAD" 106 logalloc = f"--logalloc={logalloc_var}={OBJDIR}/../{CONFIG['DLL_PREFIX']}logalloc{CONFIG['DLL_SUFFIX']}" 107 else: 108 logalloc = "--logalloc=" 109 110 LegacyTest( 111 "test_logalloc.sh", 112 logalloc, 113 f"!/{FINAL_TARGET}/{PROGRAM}{CONFIG['BIN_SUFFIX']}", 114 ".", 115 f"%{CONFIG['PYTHON3']}", 116 depends=[ 117 f"!/{FINAL_TARGET}/{PROGRAM}{CONFIG['BIN_SUFFIX']}", 118 "logalloc_munge.py", 119 "expected_output_minimal.log", 120 "replay.log", 121 ], 122 )