0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-21 12:39:08 +01:00

SERVER-82800 Port mozjs to Bazel (#27124)

GitOrigin-RevId: 5a5d11517f06052a43399376bf18a442bde4761c
This commit is contained in:
Zack Winter 2024-09-16 14:12:48 -07:00 committed by MongoDB Bot
parent eba18fa8eb
commit 32a982e23b
7 changed files with 332 additions and 350 deletions

View File

@ -4,7 +4,6 @@ src/third_party/abseil-cpp/dist
src/third_party/protobuf/dist src/third_party/protobuf/dist
src/third_party/re2/dist src/third_party/re2/dist
src/third_party/tcmalloc/dist src/third_party/tcmalloc/dist
src/third_party/mozjs
src/third_party/wiredtiger/dist src/third_party/wiredtiger/dist
# Ignore node_modules due to the following error # Ignore node_modules due to the following error

View File

@ -698,8 +698,6 @@ config_setting(
# Spider Monkey Debug options # Spider Monkey Debug options
# -------------------------------------- # --------------------------------------
# TODO(SERVER-82800): use this flag to enable/disable SpiderMonkey debug mode in mozjs when mozjs
# is ported over to bazel.
spider_monkey_dbg( spider_monkey_dbg(
name = "spider_monkey_dbg", name = "spider_monkey_dbg",
build_setting_default = False, build_setting_default = False,

View File

@ -1274,17 +1274,6 @@ def force_includes_copt(package_name, name):
"//conditions:default": ["-include", basic_h], "//conditions:default": ["-include", basic_h],
}) })
if package_name.startswith("src/third_party/mozjs"):
return select({
"//bazel/config:linux_aarch64": ["-include", "third_party/mozjs/platform/aarch64/linux/build/js-confdefs.h"],
"//bazel/config:linux_ppc64le": ["-include", "third_party/mozjs/platform/ppc64le/linux/build/js-confdefs.h"],
"//bazel/config:linux_s390x": ["-include", "third_party/mozjs/platform/s390x/linux/build/js-confdefs.h"],
"//bazel/config:linux_x86_64": ["-include", "third_party/mozjs/platform/x86_64/linux/build/js-confdefs.h"],
"//bazel/config:macos_aarch64": ["-include", "third_party/mozjs/platform/aarch64/macOS/build/js-confdefs.h"],
"//bazel/config:macos_x86_64": ["-include", "third_party/mozjs/platform/x86_64/macOS/build/js-confdefs.h"],
"//bazel/config:windows_x86_64": ["/FI", "third_party/mozjs/platform/x86_64/windows/build/js-confdefs.h"],
})
if name in ["scripting", "scripting_mozjs_test", "encrypted_dbclient"]: if name in ["scripting", "scripting_mozjs_test", "encrypted_dbclient"]:
return select({ return select({
"//bazel/config:linux_aarch64": ["-include", "third_party/mozjs/platform/aarch64/linux/build/js-config.h"], "//bazel/config:linux_aarch64": ["-include", "third_party/mozjs/platform/aarch64/linux/build/js-config.h"],
@ -1308,17 +1297,6 @@ def force_includes_hdr(package_name, name):
"//conditions:default": ["//src/mongo/platform:basic.h"], "//conditions:default": ["//src/mongo/platform:basic.h"],
}) })
if package_name.startswith("src/third_party/mozjs"):
return select({
"//bazel/config:linux_aarch64": ["//src/third_party/mozjs:platform/aarch64/linux/build/js-confdefs.h"],
"//bazel/config:linux_ppc64le": ["//src/third_party/mozjs:platform/ppc64le/linux/build/js-confdefs.h"],
"//bazel/config:linux_s390x": ["//src/third_party/mozjs:platform/s390x/linux/build/js-confdefs.h"],
"//bazel/config:linux_x86_64": ["//src/third_party/mozjs:platform/x86_64/linux/build/js-confdefs.h"],
"//bazel/config:macos_aarch64": ["//src/third_party/mozjs:platform/aarch64/macOS/build/js-confdefs.h"],
"//bazel/config:macos_x86_64": ["//src/third_party/mozjs:platform/x86_64/macOS/build/js-confdefs.h"],
"//bazel/config:windows_x86_64": ["//src/third_party/mozjs:/platform/x86_64/windows/build/js-confdefs.h"],
})
if name in ["scripting", "scripting_mozjs_test", "encrypted_dbclient"]: if name in ["scripting", "scripting_mozjs_test", "encrypted_dbclient"]:
return select({ return select({
"//bazel/config:linux_aarch64": ["//src/third_party/mozjs:platform/aarch64/linux/build/js-config.h"], "//bazel/config:linux_aarch64": ["//src/third_party/mozjs:platform/aarch64/linux/build/js-config.h"],
@ -1348,6 +1326,7 @@ def mongo_cc_library(
name, name,
srcs = [], srcs = [],
hdrs = [], hdrs = [],
textual_hdrs = [],
deps = [], deps = [],
header_deps = [], header_deps = [],
testonly = False, testonly = False,
@ -1372,6 +1351,8 @@ def mongo_cc_library(
name: The name of the library the target is compiling. name: The name of the library the target is compiling.
srcs: The source files to build. srcs: The source files to build.
hdrs: The headers files of the target library. hdrs: The headers files of the target library.
textual_hdrs: Textual headers. Might be used to include cpp files without
compiling them.
deps: The targets the library depends on. deps: The targets the library depends on.
header_deps: The targets the library depends on only for headers, omits header_deps: The targets the library depends on only for headers, omits
linking. linking.
@ -1491,6 +1472,7 @@ def mongo_cc_library(
srcs = srcs + SANITIZER_DENYLIST_HEADERS, srcs = srcs + SANITIZER_DENYLIST_HEADERS,
hdrs = hdrs + fincludes_hdr + MONGO_GLOBAL_ACCESSIBLE_HEADERS, hdrs = hdrs + fincludes_hdr + MONGO_GLOBAL_ACCESSIBLE_HEADERS,
deps = deps + [name + HEADER_DEP_SUFFIX], deps = deps + [name + HEADER_DEP_SUFFIX],
textual_hdrs = textual_hdrs,
visibility = visibility, visibility = visibility,
testonly = testonly, testonly = testonly,
copts = MONGO_GLOBAL_COPTS + package_specific_copts + copts + fincludes_copt, copts = MONGO_GLOBAL_COPTS + package_specific_copts + copts + fincludes_copt,
@ -1513,6 +1495,7 @@ def mongo_cc_library(
srcs = srcs + SANITIZER_DENYLIST_HEADERS, srcs = srcs + SANITIZER_DENYLIST_HEADERS,
hdrs = hdrs + fincludes_hdr + MONGO_GLOBAL_ACCESSIBLE_HEADERS, hdrs = hdrs + fincludes_hdr + MONGO_GLOBAL_ACCESSIBLE_HEADERS,
deps = deps + [name + HEADER_DEP_SUFFIX], deps = deps + [name + HEADER_DEP_SUFFIX],
textual_hdrs = textual_hdrs,
visibility = visibility, visibility = visibility,
testonly = testonly, testonly = testonly,
copts = MONGO_GLOBAL_COPTS + package_specific_copts + copts + fincludes_copt, copts = MONGO_GLOBAL_COPTS + package_specific_copts + copts + fincludes_copt,

View File

@ -300,7 +300,7 @@ tasks:
"incompatible_tsan", "incompatible_tsan",
"incompatible_aubsan", "incompatible_aubsan",
"requires_compile_variant", "requires_compile_variant",
"requires_large_host_debug_mode", "requires_large_host",
"crypt", "crypt",
"bazel_check", "bazel_check",
] ]

View File

@ -60,7 +60,6 @@ thirdPartyEnvironmentModifications = {
}, },
} }
def injectMozJS(thisEnv): def injectMozJS(thisEnv):
thisEnv.InjectThirdParty(libraries=['mozjs']) thisEnv.InjectThirdParty(libraries=['mozjs'])
@ -86,7 +85,6 @@ def injectMozJS(thisEnv):
'JS_GC_ZEAL' 'JS_GC_ZEAL'
]) ])
env.AddMethod(injectMozJS, 'InjectMozJS') env.AddMethod(injectMozJS, 'InjectMozJS')
if not use_system_version_of_library('tcmalloc-gperf'): if not use_system_version_of_library('tcmalloc-gperf'):
@ -358,7 +356,6 @@ env.AddMethod(shim_library, 'ShimLibrary')
if jsEngine: if jsEngine:
mozjsEnv = env.Clone() mozjsEnv = env.Clone()
mozjsEnv.SConscript('mozjs/SConscript', must_exist=1, exports={'env': mozjsEnv})
wiredtigerEnv = env.Clone() wiredtigerEnv = env.Clone()
if wiredtiger: if wiredtiger:

View File

@ -1 +1,327 @@
load("//bazel:mongo_src_rules.bzl", "mongo_cc_library")
package(default_visibility = ["//visibility:public"]) package(default_visibility = ["//visibility:public"])
PLATFORMS = {
"//bazel/config:linux_aarch64": ("aarch64", "linux"),
"//bazel/config:linux_x86_64": ("x86_64", "linux"),
"//bazel/config:linux_ppc64le": ("ppc64le", "linux"),
"//bazel/config:linux_s390x": ("s390x", "linux"),
"//bazel/config:windows_x86_64": ("x86_64", "windows"),
"//bazel/config:macos_x86_64": ("x86_64", "macOS"),
"//bazel/config:macos_aarch64": ("aarch64", "macOS"),
}
PLATFORM_SRCS = select({
config: glob([
"platform/{}/{}/build/**/*.h".format(arch, os),
"platform/{}/{}/include/**/*.h".format(arch, os),
"platform/{}/{}/build/*.cpp".format(arch, os),
"platform/{}/{}/build/jit/*.cpp".format(arch, os),
"platform/{}/{}/build/gc/*.cpp".format(arch, os),
"platform/{}/{}/build/util/*.cpp".format(arch, os),
"platform/{}/{}/build/wasm/*.cpp".format(arch, os),
"platform/{}/{}/build/irregexp/*.cpp".format(arch, os),
"platform/{}/{}/build/debugger/*.cpp".format(arch, os),
"platform/{}/{}/build/frontend/*.cpp".format(arch, os),
]) + (
[
"extract/mozglue/misc/SIMD_avx2.cpp",
"extract/mozglue/misc/SSE.cpp",
] if arch == "x86_64" and os != "windows" else []
)
for config, (arch, os) in PLATFORMS.items()
} | {
"//conditions:default": ["//conditions:incompatible"],
})
PLATFORM_INCLUDES = select({
config: [
"platform/{}/{}/build".format(arch, os),
"platform/{}/{}/include".format(arch, os),
]
for config, (arch, os) in PLATFORMS.items()
} | {
"//conditions:default": ["//conditions:incompatible"],
})
PLATFORM_COPTS = select({
config: [
"/FI" if os == "windows" else "-include",
"$(location platform/{}/{}/build/js-confdefs.h)".format(arch, os),
] + (["-mavx2"] if arch == "x86_64" and os != "windows" else [])
for config, (arch, os) in PLATFORMS.items()
} | {
"//conditions:default": ["//conditions:incompatible"],
})
mongo_cc_library(
name = "mozjs",
srcs = [
"extract/js/src/builtin/RegExp.cpp",
"extract/js/src/frontend/Parser.cpp",
"extract/js/src/gc/StoreBuffer.cpp",
"extract/js/src/irregexp/RegExpNativeMacroAssembler.cpp",
"extract/js/src/irregexp/imported/regexp-ast.cc",
"extract/js/src/irregexp/imported/regexp-compiler.cc",
"extract/js/src/jsmath.cpp",
"extract/js/src/mfbt/Unified_cpp_mfbt0.cpp",
"extract/js/src/mfbt/Unified_cpp_mfbt1.cpp",
"extract/js/src/util/DoubleToString.cpp",
"extract/js/src/vm/Interpreter.cpp",
"extract/js/src/vm/ProfilingStack.cpp",
"extract/js/src/wasm/WasmCode-platform.cpp",
"extract/mfbt/lz4/lz4.c",
"extract/mfbt/lz4/lz4frame.c",
"extract/mfbt/lz4/lz4hc.c",
"extract/mfbt/lz4/xxhash.c",
"extract/mozglue/misc/AutoProfilerLabel.cpp",
"extract/mozglue/misc/AwakeTimeStamp.cpp",
"extract/mozglue/misc/MmapFaultHandler.cpp",
"extract/mozglue/misc/Printf.cpp",
"extract/mozglue/misc/SIMD.cpp",
"extract/mozglue/misc/StackWalk.cpp",
"extract/mozglue/misc/TimeStamp.cpp",
"extract/mozglue/misc/Uptime.cpp",
"mongo_sources/freeOpToJSContext.cpp",
"mongo_sources/mongoErrorReportToString.cpp",
] + select({
"//bazel/config:spider_monkey_dbg_enabled": ["extract/js/src/util/Utility.cpp"],
"//conditions:default": [],
}) + select({
"@platforms//os:windows": [
"extract/mozglue/misc/ConditionVariable_windows.cpp",
"extract/mozglue/misc/Mutex_windows.cpp",
"extract/mozglue/misc/TimeStamp_windows.cpp",
],
"//conditions:default": [
"extract/mozglue/misc/ConditionVariable_posix.cpp",
"extract/mozglue/misc/Mutex_posix.cpp",
"extract/mozglue/misc/TimeStamp_posix.cpp",
],
}) + ["extract/modules/fdlibm/" + f for f in [
"e_acos.cpp",
"e_acosf.cpp",
"e_acosh.cpp",
"e_asin.cpp",
"e_asinf.cpp",
"e_atan2.cpp",
"e_atanh.cpp",
"e_cosh.cpp",
"e_exp.cpp",
"e_expf.cpp",
"e_hypot.cpp",
"e_log.cpp",
"e_log10.cpp",
"e_log2.cpp",
"e_logf.cpp",
"e_pow.cpp",
"e_powf.cpp",
"e_sinh.cpp",
"e_sqrtf.cpp",
"k_cos.cpp",
"k_cosf.cpp",
"k_exp.cpp",
"k_expf.cpp",
"k_rem_pio2.cpp",
"k_sin.cpp",
"k_sinf.cpp",
"k_tan.cpp",
"k_tanf.cpp",
"s_asinh.cpp",
"s_atan.cpp",
"s_atanf.cpp",
"s_cbrt.cpp",
"s_ceil.cpp",
"s_ceilf.cpp",
"s_cos.cpp",
"s_cosf.cpp",
"s_exp2.cpp",
"s_exp2f.cpp",
"s_expm1.cpp",
"s_fabs.cpp",
"s_fabsf.cpp",
"s_floor.cpp",
"s_floorf.cpp",
"s_log1p.cpp",
"s_nearbyint.cpp",
"s_rint.cpp",
"s_rintf.cpp",
"s_scalbn.cpp",
"s_sin.cpp",
"s_sinf.cpp",
"s_tan.cpp",
"s_tanf.cpp",
"s_tanh.cpp",
"s_trunc.cpp",
"s_truncf.cpp",
# Unused: 's_copysign.cpp'
]] + glob([
"extract/js/src/**/*.h",
"extract/mfbt/**/*.h",
"extract/modules/fdlibm/**/*.h",
"mongo_sources/**/*.h",
]) + PLATFORM_SRCS,
hdrs = glob(["include/**/*.h"]),
copts = PLATFORM_COPTS + [
"-Isrc/third_party/mozjs/extract/intl/icu/source/common",
"-Isrc/third_party/mozjs/extract/js/src",
"-Isrc/third_party/mozjs/extract/js/src/gc",
"-Isrc/third_party/mozjs/extract/js/src/jit",
"-Isrc/third_party/mozjs/extract/mfbt",
] + select({
"@platforms//os:windows": [
# The default MSVC preprocessor elides commas in some cases as a
# convenience, but this behavior breaks compilation of jspubtd.h.
# Enabling the newer preprocessor fixes the problem.
"/Zc:preprocessor",
# Compiling with /Zc:preprocessor causes warnings for some
# non-standard behavior in Windows system header files. We ignore
# these warnings so that they don't cause the build to fail.
"/wd5104",
"/wd5105",
# 'declaration' : no matching operator delete found; memory will not
# be freed if initialization throws an exception
"/wd4291",
# name" : the inline specifier cannot be used when a friend
# declaration refers to a specialization of a function template
"/wd4396",
# nonstandard extension used : zero-sized array in struct/union
"/wd4200",
# 'identifier' : no suitable definition provided for explicit
# template instantiation request
"/wd4661",
# 'operation' : unsafe mix of type 'type' and type 'type' in
# operation
"/wd4805",
# 'reinterpret_cast': conversion from 'type' to 'type' of greater
# size
"/wd4312",
# 'operator': unsafe use of type 'type' in operation
"/wd4804",
# not enough arguments for function-like macro invocation
"/wd4003",
# C4996: '...': was declared deprecated
"/wd4996",
# C4305: 'initializing': truncation from '...' to '...'
"/wd4305",
# C4065: switch statement contains 'default' but no 'case' labels
"/wd4065",
# C4146: unary minus operator applied to unsigned type, result still unsigned
"/wd4146",
# C4309: '=': truncation of constant value
"/wd4309",
# C4723: potential divide by 0
"/wd4723",
# C4722: '...': destructor never returns, potential memory leak
"/wd4722",
# C4018: '<': signed/unsigned mismatch
"/wd4018",
# C4715: '...': not all control paths return a value
"/wd4715",
# C5101: use of preprocessor directive in function-like macro
# argument list is undefined behavior
"/wd5101",
],
"//conditions:default": [
"-Wno-sign-compare",
"-Wno-error=implicit-fallthrough",
# TODO(SERVER-77205): Review and Possibly Remove '-Wno-deprecated'
# after Mozjs Update
"-Wno-deprecated",
# Bazel doesn't differentiate between compile flags for C and C++.
# This leads to errors where certain flags are invalid under C
# compilation.
"-Wno-error",
],
}) + select({
"//bazel/config:linux_x86_64": ["-mavx2"],
"//bazel/config:macos_x86_64": ["-mavx2"],
"//conditions:default": [],
}) + select({
# Suppress `register` keyword warnings in FreeBSD builds
"@platforms//os:freebsd": [
"-Wno-error=register",
"-Wno-register",
],
"//conditions:default": [],
}),
defines = [
"JS_USE_CUSTOM_ALLOCATOR=1",
"STATIC_JS_API=1",
] + select({
"//bazel/config:spider_monkey_dbg_enabled": [
"DEBUG",
"JS_DEBUG",
"JS_GC_ZEAL",
],
"//conditions:default": [],
}) + select({
# These warnings are triggered by public headers. We pass them as
# defines so that depending targets don't need to set them manually.
"@platforms//os:windows": [
"_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING",
],
"//conditions:default": [
"__Wno_non_virtual_dtor__",
"__Wno_invalid_offsetof__",
],
}),
includes = [
"include",
"mongo_sources",
] + PLATFORM_INCLUDES,
local_defines = [
"IMPL_MFBT=1",
"U_NO_DEFAULT_INCLUDE_UTF_HEADERS=1",
"UCONFIG_NO_BREAK_ITERATION=1",
"UCONFIG_NO_FORMATTING=1",
"UCONFIG_NO_TRANSLITERATION=1",
"UCONFIG_NO_REGULAR_EXPRESSIONS=1",
"U_CHARSET_IS_UTF8=1",
"U_STATIC_IMPLEMENTATION=1",
"U_USING_ICU_NAMESPACE=0",
] + select({
"@platforms//os:windows": [
"_CRT_RAND_S=1",
"NO_COMPUTED_GOTO=1",
],
"//conditions:default": [],
}) + select({
"@platforms//cpu:x86_64": ["WASM_HUGE_MEMORY=1"],
"//conditions:default": [],
}),
textual_hdrs = glob([
# Not all files are meant to be compiled but still need to be available
# for inclusions like `#include "somefile.cpp"`.
"**/*.cpp",
"**/*.c",
"**/*.cc",
"**/*.msg",
"**/*.inc",
"**/*.tbl",
]),
deps = [
"//src/third_party/icu4c-57.1/source:icu_i18n",
"//src/third_party/zlib",
],
)

View File

@ -1,321 +0,0 @@
# -*- mode: python -*-
Import([
"get_option",
"env",
])
env = env.Clone()
env.InjectThirdParty(libraries=['zlib'])
env.InjectThirdParty(libraries=['icu'])
env['CCFLAGS_WERROR'] = []
def removeIfPresent(lst, item):
try:
lst.remove(item)
except ValueError:
pass
for to_remove in ['-Wall', '-W', '/W3', '-Wsign-compare', '/permissive-']:
removeIfPresent(env['CCFLAGS'], to_remove)
# See what -D's show up in make. The AB_CD one might change, but we're little
# endian only for now so I think it's sane
env.Prepend(CPPDEFINES=[
('IMPL_MFBT', 1),
('JS_USE_CUSTOM_ALLOCATOR', 1),
('STATIC_JS_API', 1),
('U_NO_DEFAULT_INCLUDE_UTF_HEADERS', 1),
('UCONFIG_NO_BREAK_ITERATION', 1),
('UCONFIG_NO_FORMATTING', 1),
('UCONFIG_NO_TRANSLITERATION', 1),
('UCONFIG_NO_REGULAR_EXPRESSIONS', 1),
('U_CHARSET_IS_UTF8', 1),
('U_STATIC_IMPLEMENTATION', 1),
('U_USING_ICU_NAMESPACE', 0),
])
if get_option('spider-monkey-dbg') == "on":
env.Prepend(CPPDEFINES=[
'DEBUG',
'JS_DEBUG',
'JS_GC_ZEAL',
])
env.Append(FORCEINCLUDES=['js-confdefs.h'], )
if env.TargetOSIs('windows'):
env.Append(
CCFLAGS=[
# The default MSVC preprocessor elides commas in some cases as a convenience, but this
# behavior breaks compilation of jspubtd.h. Enabling the newer preprocessor fixes the
# # problem.
'/Zc:preprocessor',
# Compiling with /Zc:preprocessor causes warnings for some non-standard behavior in
# # Windows system header files. We ignore these warnings so that they don't cause the
# build to fail.
'/wd5104',
'/wd5105',
# 'declaration' : no matching operator delete found; memory will not be freed if
# initialization throws an exception
'/wd4291',
# name" : the inline specifier cannot be used when a friend declaration refers to a
# specialization of a function template
'/wd4396',
# nonstandard extension used : zero-sized array in struct/union
'/wd4200',
# 'identifier' : no suitable definition provided for explicit template instantiation
# request
'/wd4661',
# 'operation' : unsafe mix of type 'type' and type 'type' in operation
'/wd4805',
# 'reinterpret_cast': conversion from 'type' to 'type' of greater size
'/wd4312',
# 'operator': unsafe use of type 'type' in operation
'/wd4804',
# not enough arguments for function-like macro invocation
'/wd4003',
], )
else:
env.Append(
CXXFLAGS=[
'-Wno-non-virtual-dtor',
'-Wno-invalid-offsetof',
'-Wno-sign-compare',
# TODO(SERVER-77205): Review and Possibly Remove '-Wno-deprecated' After Mozjs Update
'-Wno-deprecated',
], )
# js/src, js/public and mfbt are the only required sources right now, that
# could change in the future
#
# Also:
# We pre-generate configs for platforms and just check them in. Running
# mozilla's config requires a relatively huge portion of their tree.
env.Prepend(CPPPATH=[
'extract/js/src',
'extract/js/src/jit',
'extract/js/src/gc',
'extract/mfbt',
'extract/intl/icu/source/common',
'include',
'mongo_sources',
'platform/' + env["TARGET_ARCH"] + "/" + env["TARGET_OS"] + "/build",
'platform/' + env["TARGET_ARCH"] + "/" + env["TARGET_OS"] + "/include",
])
sources = [
"mongo_sources/mongoErrorReportToString.cpp",
"mongo_sources/freeOpToJSContext.cpp",
"extract/js/src/builtin/RegExp.cpp",
"extract/js/src/vm/ProfilingStack.cpp",
"extract/js/src/frontend/Parser.cpp",
"extract/js/src/gc/StoreBuffer.cpp",
"extract/js/src/jsmath.cpp",
"extract/js/src/mfbt/Unified_cpp_mfbt0.cpp",
"extract/js/src/mfbt/Unified_cpp_mfbt1.cpp",
"extract/js/src/util/DoubleToString.cpp",
"extract/js/src/vm/Interpreter.cpp",
"extract/mfbt/lz4/lz4.c",
"extract/mfbt/lz4/lz4frame.c",
"extract/mfbt/lz4/lz4hc.c",
"extract/mfbt/lz4/xxhash.c",
"extract/mozglue/misc/AutoProfilerLabel.cpp",
"extract/mozglue/misc/AwakeTimeStamp.cpp",
"extract/mozglue/misc/MmapFaultHandler.cpp",
"extract/mozglue/misc/Printf.cpp",
"extract/mozglue/misc/SIMD.cpp",
"extract/mozglue/misc/StackWalk.cpp",
"extract/mozglue/misc/TimeStamp.cpp",
"extract/mozglue/misc/Uptime.cpp",
"extract/js/src/irregexp/imported/regexp-ast.cc",
"extract/js/src/irregexp/imported/regexp-compiler.cc",
"extract/js/src/irregexp/RegExpNativeMacroAssembler.cpp",
"extract/js/src/wasm/WasmCode-platform.cpp",
]
if get_option('spider-monkey-dbg') == "on":
sources.extend(["extract/js/src/util/Utility.cpp"])
if env['TARGET_ARCH'] == 'x86_64' and not env.TargetOSIs('windows'):
env.Append(CCFLAGS=['-mavx2'])
sources.extend(["extract/mozglue/misc/SIMD_avx2.cpp", "extract/mozglue/misc/SSE.cpp"])
if env.TargetOSIs('windows'):
sources.extend([
"extract/mozglue/misc/ConditionVariable_windows.cpp",
"extract/mozglue/misc/Mutex_windows.cpp",
"extract/mozglue/misc/TimeStamp_windows.cpp",
])
else:
sources.extend([
"extract/mozglue/misc/ConditionVariable_posix.cpp",
"extract/mozglue/misc/Mutex_posix.cpp",
"extract/mozglue/misc/TimeStamp_posix.cpp",
])
sources.append([
"extract/modules/fdlibm/{}".format(f) for f in [
'e_acos.cpp',
'e_acosf.cpp',
'e_acosh.cpp',
'e_asin.cpp',
'e_asinf.cpp',
'e_atan2.cpp',
'e_atanh.cpp',
'e_cosh.cpp',
'e_exp.cpp',
'e_expf.cpp',
'e_hypot.cpp',
'e_log.cpp',
'e_log10.cpp',
'e_log2.cpp',
'e_logf.cpp',
'e_pow.cpp',
'e_powf.cpp',
'e_sinh.cpp',
'e_sqrtf.cpp',
'k_cos.cpp',
'k_cosf.cpp',
'k_exp.cpp',
'k_expf.cpp',
'k_rem_pio2.cpp',
'k_sin.cpp',
'k_sinf.cpp',
'k_tan.cpp',
'k_tanf.cpp',
's_asinh.cpp',
's_atan.cpp',
's_atanf.cpp',
's_cbrt.cpp',
's_ceil.cpp',
's_ceilf.cpp',
# 's_copysign.cpp', # Unused file.
's_cos.cpp',
's_cosf.cpp',
's_exp2.cpp',
's_exp2f.cpp',
's_expm1.cpp',
's_fabs.cpp',
's_fabsf.cpp',
's_floor.cpp',
's_floorf.cpp',
's_log1p.cpp',
's_nearbyint.cpp',
's_rint.cpp',
's_rintf.cpp',
's_scalbn.cpp',
's_sin.cpp',
's_sinf.cpp',
's_tan.cpp',
's_tanf.cpp',
's_tanh.cpp',
's_trunc.cpp',
's_truncf.cpp',
]
])
if env.TargetOSIs('windows'):
env.Prepend(CPPDEFINES=[
("_CRT_RAND_S", "1"),
("NO_COMPUTED_GOTO", 1),
])
if env['TARGET_ARCH'] == 'x86_64':
env.Prepend(CPPDEFINES=[("WASM_HUGE_MEMORY", "1")])
sourceFilePatterns = [
"/build/*.cpp",
"/build/jit/*.cpp",
"/build/gc/*.cpp",
"/build/util/*.cpp",
"/build/wasm/*.cpp",
"/build/irregexp/*.cpp",
"/build/debugger/*.cpp",
"/build/frontend/*.cpp",
]
for srcPattern in sourceFilePatterns:
sources.extend(Glob('platform/' + env["TARGET_ARCH"] + "/" + env["TARGET_OS"] + srcPattern))
# All of those unified sources come in from configure. The files don't
# actually build individually anymore.
env.Library(
target="mozjs",
source=sources,
LIBDEPS_TAGS=[
# Depends on allocation symbols defined elsewhere
'illegal_cyclic_or_unresolved_dependencies_allowlisted',
],
LIBDEPS=[
'$BUILD_DIR/third_party/icu4c-57.1/source/icu_i18n',
'$BUILD_DIR/third_party/zlib/zlib',
],
)
#########################
env = env.Clone()
# The below list of defines are used to configure ICU. They must be duplicated exactly in every
# library that injects the third-party ICU headers. If this list is changed here, it must be changed
# in other such libraries as well.
env.Append(
CPPDEFINES=[
('UCONFIG_NO_BREAK_ITERATION', 1),
('UCONFIG_NO_FORMATTING', 1),
('UCONFIG_NO_TRANSLITERATION', 1),
('UCONFIG_NO_REGULAR_EXPRESSIONS', 1),
('U_CHARSET_IS_UTF8', 1),
('U_STATIC_IMPLEMENTATION', 1),
('U_USING_ICU_NAMESPACE', 0),
], )
if env.TargetOSIs('solaris'):
# On Solaris, compile of certain files fails if the below define is not enabled. Specifically,
# files that include "source/common/uposixdefs.h" will have _XOPEN_SOURCE=600 and
# _XOPEN_SOURCE_EXTENDED=1 defined by default; if the file also includes <sys/feature_tests.h>,
# then the application is assumed to conform to the XPG4v2 specification, which generates an
# error because XPG4v2 programs are incompatible with C99. If we keep _XOPEN_SOURCE=600 but
# force _XOPEN_SOURCE_EXTENDED=0, then <sys/feature_tests.h> chooses XPG6, which resolves the
# error (since XPG6 is compatible with C99).
env.Append(CPPDEFINES=[
('_XOPEN_SOURCE_EXTENDED', 0),
], )
def removeIfPresent(lst, item):
try:
lst.remove(item)
except ValueError:
pass
env['CCFLAGS_WERROR'] = []
for to_remove in ['-Wall', '-W']:
removeIfPresent(env['CCFLAGS'], to_remove)
# Suppress sign-compare warnings.
if env.ToolchainIs('clang', 'GCC'):
env.Append(CCFLAGS=['-Wno-sign-compare'])
if env.TargetOSIs('windows'):
# C4996: '...': was declared deprecated
env.Append(CCFLAGS=['/wd4996'])
# Suppress `register` keyword warnings in FreeBSD builds
if env.TargetOSIs('freebsd'):
env.Append(CCFLAGS=['-Wno-error=register'])
env.Append(CCFLAGS=['-Wno-register'])