react-nitro-hermes 0.0.1-alpha.8 → 0.0.1-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/hermes/CMakeLists.txt +874 -0
- package/hermes/android/HostObjectJniTest.cpp +178 -0
- package/hermes/android/build-logic/build.gradle.kts +31 -0
- package/hermes/android/build-logic/settings.gradle.kts +17 -0
- package/hermes/android/build-logic/src/main/kotlin/com/facebook/hermes/helpers/internal/SerializeHermesCompilerPackageJson.kt +33 -0
- package/hermes/android/build-logic/src/main/kotlin/com/facebook/hermes/plugins/internal/TestUtilsPlugin.kt +80 -0
- package/hermes/android/build-logic/src/main/kotlin/com/facebook/hermes/tasks/internal/CustomExecTask.kt +46 -0
- package/hermes/android/build-logic/src/main/kotlin/publish.gradle.kts +82 -0
- package/hermes/android/build.gradle.kts +332 -0
- package/hermes/android/cppruntime/build.gradle +72 -0
- package/hermes/android/cppruntime/src/main/AndroidManifest.xml +2 -0
- package/hermes/android/cppruntime/src/main/cpp/CMakeLists.txt +8 -0
- package/hermes/android/cppruntime/src/main/cpp/stub.cpp +12 -0
- package/hermes/android/cross-compile/swift-libicu.patch +13 -0
- package/hermes/android/cross-compile/toolchain-android-arm-api13-gnustl.cmake +13 -0
- package/hermes/android/cross-compile/toolchain-android-arm-api15-gnustl.cmake +14 -0
- package/hermes/android/gradle/libs.versions.toml +30 -0
- package/hermes/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/hermes/android/gradle/wrapper/gradle-wrapper.properties +7 -0
- package/hermes/android/gradle.properties +3 -0
- package/hermes/android/gradlew +248 -0
- package/hermes/android/gradlew.bat +93 -0
- package/hermes/android/intltest/build.gradle +147 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/CMakeLists.txt +45 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/HermesEpilogue.cpp +68 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/HermesEpilogue.h +44 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/HermesEpilogue.java +45 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/HermesEpilogueTestData.java +32 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/HermesInstrumentationTest.java +150 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/HermesIntlAndroidTest.java +147 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/HermesIntlTest262.java +470 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/HermesRuntimeFactory.cpp +73 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/JSRuntime.cpp +90 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/JSRuntime.h +62 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/JSRuntime.java +155 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/MappedFileBuffer.cpp +48 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/MappedFileBuffer.h +36 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/OnLoad.cpp +13 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/OnLoadEpilogue.cpp +13 -0
- package/hermes/android/intltest/src/main/AndroidManifest.xml +2 -0
- package/hermes/android/ios-artifacts/build.gradle.kts +65 -0
- package/hermes/android/settings.gradle.kts +27 -0
- package/hermes/cmake/modules/Hermes.cmake +481 -0
- package/hermes/cmake/modules/Lit.cmake +96 -0
- package/hermes/doc/Branches.md +38 -0
- package/hermes/doc/BuildingAndRunning.md +121 -0
- package/hermes/doc/CodingStandards.md +112 -0
- package/hermes/doc/CrossCompilation.md +79 -0
- package/hermes/doc/Design.md +217 -0
- package/hermes/doc/Emscripten.md +156 -0
- package/hermes/doc/Features.md +143 -0
- package/hermes/doc/GCSafeCoding.md +563 -0
- package/hermes/doc/GenGC.md +300 -0
- package/hermes/doc/Hades.md +344 -0
- package/hermes/doc/HighLevelOptimizations.md +37 -0
- package/hermes/doc/IR.md +1306 -0
- package/hermes/doc/IntlAPIs.md +196 -0
- package/hermes/doc/JIT.md +999 -0
- package/hermes/doc/LazyEvalCompilation.md +84 -0
- package/hermes/doc/MemoryProfilers.md +316 -0
- package/hermes/doc/Modules.md +144 -0
- package/hermes/doc/Optimizer.md +83 -0
- package/hermes/doc/PerfProfiling.md +29 -0
- package/hermes/doc/ProhibitInvoke.md +329 -0
- package/hermes/doc/ReactNative.md +40 -0
- package/hermes/doc/ReactNativeIntegration.md +94 -0
- package/hermes/doc/RegExp.md +24 -0
- package/hermes/doc/SpecIncompat.md +85 -0
- package/hermes/doc/Strings.md +140 -0
- package/hermes/doc/TypedLanguage.md +432 -0
- package/hermes/doc/VM.md +174 -0
- package/hermes/doc/blog/2024-11-09-octane-benchmark-jit-progress.md +17 -0
- package/hermes/doc/blog/2024-12-19-static-hermes-update-dec-2024.md +47 -0
- package/hermes/doc/blog/2024-12-23-compiling-javascript-to-wasm.md +267 -0
- package/hermes/doc/blog/2025-06-09-jsi-runtime-data-apis.md +23 -0
- package/hermes/doc/blog/2025-07-15-static-h-performance-june-2025.md +18 -0
- package/hermes/doc/blog/2025-11-02-hermes-compilation-runtime-modes.md +23 -0
- package/hermes/doc/blog/2025-11-06-hermes-memory-modes.md +35 -0
- package/hermes/doc/blog/2025-11-24-json-parsing-performance.md +17 -0
- package/hermes/doc/blog/2025-12-02-iserialization.md +11 -0
- package/hermes/doc/blog/2025-12-12-new-way-to-contribute.md +68 -0
- package/hermes/doc/blog/2026-06-05-new-hermes-stable-release.md +51 -0
- package/hermes/doc/blog/README.md +25 -0
- package/hermes/doc/blog/images/2024-11-09-octane-pi3.jpeg +0 -0
- package/hermes/doc/blog/images/2024-11-09-octane-pi5.jpeg +0 -0
- package/hermes/doc/blog/images/2025-07-15-perf-hv32-interpreter.jpeg +0 -0
- package/hermes/doc/blog/images/2025-07-15-perf-hv32-jit.jpeg +0 -0
- package/hermes/doc/icu_license.txt +420 -0
- package/hermes/doc/img/heap_snapshot_retainers.png +0 -0
- package/hermes/doc/img/logo.svg +1 -0
- package/hermes/doc/img/object_captured_by_environment.png +0 -0
- package/hermes/doc/img/root_categories.png +0 -0
- package/hermes/doc/plans/ir-type/flow-type-system.md +324 -0
- package/hermes/doc/plans/ir-type/ir-type-system-v2-design.md +652 -0
- package/hermes/doc/plans/ir-type/ir-type-system.md +220 -0
- package/hermes/doc/plans/ir-type/ir-type-v2-implementation.md +1187 -0
- package/hermes/doc/plans/ir-type/memory.md +48 -0
- package/hermes/doc/plans/ir-type/phase1-steps.md +512 -0
- package/hermes/doc/plans/ir-type/progress.md +239 -0
- package/hermes/doc/plans/ir-type/typeinference-primitive-fastpath-design.md +203 -0
- package/hermes/doc/plans/ir-type/typeinference-primitive-fastpath-results.md +71 -0
- package/hermes/doc/superpowers/plans/2026-07-28-worker-arraybuffer-input.md +597 -0
- package/hermes/doc/superpowers/plans/2026-08-18-jitemitter-split.md +1149 -0
- package/hermes/doc/superpowers/plans/2026-08-20-jit-type-asserts.md +969 -0
- package/hermes/doc/superpowers/plans/2026-08-23-jit-shared-compiler-driver.md +478 -0
- package/hermes/doc/superpowers/plans/2026-08-23-x86-64-jit-skeleton.md +797 -0
- package/hermes/doc/superpowers/plans/2026-08-24-x86-64-jit-arith.md +444 -0
- package/hermes/doc/superpowers/plans/2026-08-24-x86-64-jit-calls.md +261 -0
- package/hermes/doc/superpowers/plans/2026-08-24-x86-64-jit-props.md +240 -0
- package/hermes/doc/superpowers/plans/2026-10-26-regexp-bytecode-sharing.md +2197 -0
- package/hermes/doc/superpowers/plans/2026-10-28-regexp-start-filter-and-exec-fast-paths.md +3981 -0
- package/hermes/doc/superpowers/specs/2026-07-28-worker-arraybuffer-input-design.md +206 -0
- package/hermes/doc/superpowers/specs/2026-08-18-jitemitter-split-design.md +530 -0
- package/hermes/doc/superpowers/specs/2026-08-20-jit-type-asserts-design.md +360 -0
- package/hermes/doc/superpowers/specs/2026-08-23-x86-64-jit-design.md +246 -0
- package/hermes/doc/superpowers/specs/2026-08-26-icu-free-normalize-design.md +355 -0
- package/hermes/doc/superpowers/specs/2026-08-27-icu-free-convert-to-case-design.md +305 -0
- package/hermes/doc/superpowers/specs/2026-08-27-icu-free-locale-compare-design.md +429 -0
- package/hermes/doc/superpowers/specs/2026-08-29-icu-free-date-format-design.md +297 -0
- package/hermes/doc/superpowers/specs/2026-10-26-regexp-bytecode-sharing-design.md +605 -0
- package/hermes/doc/superpowers/specs/2026-10-28-regexp-start-filter-and-exec-fast-paths-design.md +551 -0
- package/hermes/doc/typescript-stripping.md +90 -0
- package/hermes/external/CMakeLists.txt +20 -0
- package/hermes/utils/IntlGen/IntlGen.java +531 -0
- package/hermes/utils/bench_with_stats.py +827 -0
- package/hermes/utils/build-apple-framework.sh +323 -0
- package/hermes/utils/chrome_snapshot_parser.py +210 -0
- package/hermes/utils/cmake-dev-build.sh +18 -0
- package/hermes/utils/commons.sh +55 -0
- package/hermes/utils/dump-cpp-funcs.sh +3 -0
- package/hermes/utils/es5objects.js +198 -0
- package/hermes/utils/format.sh +145 -0
- package/hermes/utils/gen-promise-internal-bc.sh +66 -0
- package/hermes/utils/genUnicodeTable.py +2503 -0
- package/hermes/utils/hermes-lit/CMakeLists.txt +22 -0
- package/hermes/utils/hermes-lit/hermes-lit.in +15 -0
- package/hermes/utils/jit/README.md +134 -0
- package/hermes/utils/jit/jit-diff.sh +160 -0
- package/hermes/utils/jit/jit-dump.sh +193 -0
- package/hermes/utils/lit-expect-gen/generate.py +217 -0
- package/hermes/utils/promise/index.js +15 -0
- package/hermes/utils/promise/package.json +13 -0
- package/hermes/utils/promise/rollup.config.js +19 -0
- package/hermes/utils/promise/yarn.lock +247 -0
- package/hermes/utils/scripts/hermes/consts.js +26 -0
- package/hermes/utils/scripts/hermes/create-tarball.js +75 -0
- package/hermes/utils/scripts/hermes/get-hermes-version.js +57 -0
- package/hermes/utils/scripts/hermes/hermes-utils.js +122 -0
- package/hermes/utils/scripts/hermes/package.json +6 -0
- package/hermes/utils/scripts/hermes/prepare-artifacts.js +113 -0
- package/hermes/utils/scripts/hermes/publish-artifacts.js +109 -0
- package/hermes/utils/scripts/hermes/publish-npm.js +96 -0
- package/hermes/utils/scripts/hermes/scm-utils.js +41 -0
- package/hermes/utils/scripts/hermes/set-artifacts-version.js +64 -0
- package/hermes/utils/scripts/hermes/version-utils.js +98 -0
- package/hermes/utils/scripts/hermes/yarn.lock +240 -0
- package/hermes/utils/summarize_sizes.py +184 -0
- package/hermes/utils/symbolicate-nativecall-stats.py +112 -0
- package/hermes/utils/test_runner.py +13 -0
- package/hermes/utils/testsuite/README.facebook +3 -0
- package/hermes/utils/testsuite/README.md +69 -0
- package/hermes/utils/testsuite/cli.py +547 -0
- package/hermes/utils/testsuite/es_ast.py +337 -0
- package/hermes/utils/testsuite/external/LICENSE +28 -0
- package/hermes/utils/testsuite/external/README.facebook +8 -0
- package/hermes/utils/testsuite/external/__init__.py +0 -0
- package/hermes/utils/testsuite/external/_monkeyYaml.py +164 -0
- package/hermes/utils/testsuite/external/parse_test262.py +141 -0
- package/hermes/utils/testsuite/hermes.py +522 -0
- package/hermes/utils/testsuite/preprocess.py +365 -0
- package/hermes/utils/testsuite/progress.py +377 -0
- package/hermes/utils/testsuite/skiplist.json +4356 -0
- package/hermes/utils/testsuite/skiplist.py +270 -0
- package/hermes/utils/testsuite/test_run_defs.py +435 -0
- package/hermes/utils/testsuite/typing_defs.py +52 -0
- package/hermes/utils/testsuite/utils.py +214 -0
- package/hermes/utils/tidy.sh +22 -0
- package/hermes/utils/update-fbcode-hermes.sh +53 -0
- package/hermes/utils/updateErrorTest.py +193 -0
- package/hermes/utils/wasm-compile.sh +65 -0
- package/package.json +1 -1
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
#
|
|
3
|
+
# This source code is licensed under the MIT license found in the
|
|
4
|
+
# LICENSE file in the root directory of this source tree.
|
|
5
|
+
|
|
6
|
+
include(CheckCXXCompilerFlag)
|
|
7
|
+
include(CheckCCompilerFlag)
|
|
8
|
+
include(CheckCXXSourceCompiles)
|
|
9
|
+
include(CheckLinkerFlag)
|
|
10
|
+
include(CMakePrintHelpers)
|
|
11
|
+
|
|
12
|
+
set(HERMES_TOOLS_OUTPUT_DIR "${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}")
|
|
13
|
+
|
|
14
|
+
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
|
15
|
+
set(GCC 1)
|
|
16
|
+
set(GCC_COMPATIBLE 1)
|
|
17
|
+
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
|
18
|
+
set(CLANG 1)
|
|
19
|
+
set(GCC_COMPATIBLE 1)
|
|
20
|
+
if (CMAKE_CXX_SIMULATE_ID MATCHES "MSVC")
|
|
21
|
+
set(CLANG_CL 1)
|
|
22
|
+
endif ()
|
|
23
|
+
endif ()
|
|
24
|
+
|
|
25
|
+
# Emscripten with Fastcomp backend in WASM mode generates trapping conversions
|
|
26
|
+
# from float/double to int. We require non-trapping behavior.
|
|
27
|
+
if (EMSCRIPTEN AND EMSCRIPTEN_FASTCOMP)
|
|
28
|
+
# Note that this flag only affects Wasm, not Asm.js.
|
|
29
|
+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s BINARYEN_TRAP_MODE=clamp")
|
|
30
|
+
endif()
|
|
31
|
+
|
|
32
|
+
# set stack reserved size to ~10MB
|
|
33
|
+
if (MSVC)
|
|
34
|
+
# CMake previously automatically set this value for MSVC builds, but the
|
|
35
|
+
# behavior was changed in CMake 2.8.11 (Issue 12437) to use the MSVC default
|
|
36
|
+
# value (1 MB) which is not enough for some of our stack overflow tests.
|
|
37
|
+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:10000000")
|
|
38
|
+
elseif (MINGW) # FIXME: Also cygwin?
|
|
39
|
+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--stack,16777216")
|
|
40
|
+
endif ()
|
|
41
|
+
|
|
42
|
+
if (WIN32)
|
|
43
|
+
set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)
|
|
44
|
+
if (CYGWIN)
|
|
45
|
+
set(LLVM_ON_WIN32 0)
|
|
46
|
+
set(LLVM_ON_UNIX 1)
|
|
47
|
+
else (CYGWIN)
|
|
48
|
+
set(LLVM_ON_WIN32 1)
|
|
49
|
+
set(LLVM_ON_UNIX 0)
|
|
50
|
+
endif (CYGWIN)
|
|
51
|
+
else (WIN32)
|
|
52
|
+
if (FUCHSIA OR UNIX)
|
|
53
|
+
set(LLVM_ON_WIN32 0)
|
|
54
|
+
set(LLVM_ON_UNIX 1)
|
|
55
|
+
if (APPLE OR ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
|
|
56
|
+
set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)
|
|
57
|
+
else ()
|
|
58
|
+
set(LLVM_HAVE_LINK_VERSION_SCRIPT 1)
|
|
59
|
+
endif ()
|
|
60
|
+
else (FUCHSIA OR UNIX)
|
|
61
|
+
MESSAGE(SEND_ERROR "Unable to determine platform")
|
|
62
|
+
endif (FUCHSIA OR UNIX)
|
|
63
|
+
endif (WIN32)
|
|
64
|
+
|
|
65
|
+
# Set C++ exception handling and RTTI flags for a target.
|
|
66
|
+
# Uses generator expressions to apply flags only to C++ source files,
|
|
67
|
+
# so it works correctly even for targets with mixed C and C++ sources.
|
|
68
|
+
function(hermes_update_cxx_flags name)
|
|
69
|
+
set(flags "")
|
|
70
|
+
|
|
71
|
+
if (HERMES_ENABLE_EH)
|
|
72
|
+
if (GCC_COMPATIBLE)
|
|
73
|
+
list(APPEND flags -fexceptions)
|
|
74
|
+
elseif (MSVC)
|
|
75
|
+
list(APPEND flags /EHsc)
|
|
76
|
+
endif ()
|
|
77
|
+
else ()
|
|
78
|
+
if (GCC_COMPATIBLE)
|
|
79
|
+
list(APPEND flags -fno-exceptions)
|
|
80
|
+
elseif (MSVC)
|
|
81
|
+
list(APPEND flags /EHs-c-)
|
|
82
|
+
endif ()
|
|
83
|
+
endif ()
|
|
84
|
+
|
|
85
|
+
if (HERMES_ENABLE_RTTI)
|
|
86
|
+
if (GCC_COMPATIBLE)
|
|
87
|
+
list(APPEND flags -frtti)
|
|
88
|
+
elseif (MSVC)
|
|
89
|
+
list(APPEND flags /GR)
|
|
90
|
+
endif ()
|
|
91
|
+
else ()
|
|
92
|
+
if (GCC_COMPATIBLE)
|
|
93
|
+
list(APPEND flags -fno-rtti)
|
|
94
|
+
elseif (MSVC)
|
|
95
|
+
list(APPEND flags /GR-)
|
|
96
|
+
endif ()
|
|
97
|
+
endif ()
|
|
98
|
+
|
|
99
|
+
# Use generator expression to apply flags only to C++ files.
|
|
100
|
+
target_compile_options(${name} PRIVATE
|
|
101
|
+
"$<$<COMPILE_LANGUAGE:CXX>:${flags}>")
|
|
102
|
+
endfunction()
|
|
103
|
+
|
|
104
|
+
# LINK_OBJLIBS links in object libraries created by Hermes
|
|
105
|
+
# LINK_LIBS links in regular libraries
|
|
106
|
+
function(add_hermes_library name)
|
|
107
|
+
cmake_parse_arguments(ARG "OBJECT;STATIC;SHARED" "" "LINK_OBJLIBS;LINK_LIBS" ${ARGN})
|
|
108
|
+
|
|
109
|
+
if(ARG_STATIC OR ARG_SHARED)
|
|
110
|
+
if(ARG_SHARED)
|
|
111
|
+
add_library(${name} SHARED ${ARG_UNPARSED_ARGUMENTS})
|
|
112
|
+
else()
|
|
113
|
+
add_library(${name} STATIC ${ARG_UNPARSED_ARGUMENTS})
|
|
114
|
+
endif()
|
|
115
|
+
target_link_libraries(${name} ${ARG_LINK_OBJLIBS} ${ARG_LINK_LIBS})
|
|
116
|
+
set_property(TARGET ${name} PROPERTY POSITION_INDEPENDENT_CODE ON)
|
|
117
|
+
hermes_update_cxx_flags(${name})
|
|
118
|
+
else()
|
|
119
|
+
# When asking to link an OBJECT library (the default), we create an OBJECT
|
|
120
|
+
# library with a suffix _obj, which depends on all object libraries in
|
|
121
|
+
# LINK_OBJLIBS with added suffixes and the static libraries in LINK_LIBS.
|
|
122
|
+
# Then we create a static library which depends on name_obj and the libraries
|
|
123
|
+
# in LINK_OBJLIBS, but without the suffixes.
|
|
124
|
+
#
|
|
125
|
+
# In this way, "name_obj" pulls in all interface settings from the other _obj
|
|
126
|
+
# libraries, while "name.a" contains the files from "name_obj" and depends
|
|
127
|
+
# on the other *static* libraries.
|
|
128
|
+
#
|
|
129
|
+
# The static library "name.a" can be used as before. Note that all this
|
|
130
|
+
# avoids compiling an object file more than once (ordinarily an object file
|
|
131
|
+
# is compiled for every target that includes it).
|
|
132
|
+
add_library(${name}_obj OBJECT ${ARG_UNPARSED_ARGUMENTS})
|
|
133
|
+
foreach(lib ${ARG_LINK_OBJLIBS})
|
|
134
|
+
target_link_libraries(${name}_obj ${lib}_obj)
|
|
135
|
+
endforeach(lib)
|
|
136
|
+
target_link_libraries(${name}_obj ${ARG_LINK_LIBS})
|
|
137
|
+
set_property(TARGET ${name}_obj PROPERTY POSITION_INDEPENDENT_CODE ON)
|
|
138
|
+
hermes_update_cxx_flags(${name}_obj)
|
|
139
|
+
|
|
140
|
+
add_library(${name} STATIC)
|
|
141
|
+
target_link_libraries(${name} ${name}_obj ${ARG_LINK_OBJLIBS})
|
|
142
|
+
endif()
|
|
143
|
+
endfunction(add_hermes_library)
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
function(add_hermes_executable name)
|
|
147
|
+
cmake_parse_arguments(ARG "" "" "LINK_OBJLIBS;LINK_LIBS" ${ARGN})
|
|
148
|
+
add_executable(${name} ${ARG_UNPARSED_ARGUMENTS})
|
|
149
|
+
target_link_libraries(${name} ${ARG_LINK_OBJLIBS} ${ARG_LINK_LIBS})
|
|
150
|
+
target_link_options(${name} PRIVATE ${HERMES_EXTRA_LINKER_FLAGS})
|
|
151
|
+
hermes_update_cxx_flags(${name})
|
|
152
|
+
endfunction(add_hermes_executable)
|
|
153
|
+
|
|
154
|
+
function(add_hermes_tool name)
|
|
155
|
+
add_hermes_executable(${name} ${ARGN})
|
|
156
|
+
|
|
157
|
+
# In multi-config build systems, remove the per-config directory and let
|
|
158
|
+
# CMake automatically add it in the component.
|
|
159
|
+
if (NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".")
|
|
160
|
+
string(REPLACE ${CMAKE_CFG_INTDIR} "" HERMES_TOOLS_OUTPUT_DIR "${HERMES_TOOLS_OUTPUT_DIR}")
|
|
161
|
+
endif ()
|
|
162
|
+
|
|
163
|
+
set_property(TARGET ${name} PROPERTY RUNTIME_OUTPUT_DIRECTORY
|
|
164
|
+
"${HERMES_TOOLS_OUTPUT_DIR}")
|
|
165
|
+
|
|
166
|
+
if (HERMES_ENABLE_ADDRESS_SANITIZER AND MSVC)
|
|
167
|
+
# Copy ASAN DLL to the executable's directory after building.
|
|
168
|
+
add_custom_command(TARGET ${name} POST_BUILD
|
|
169
|
+
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
170
|
+
"$<$<CONFIG:Debug>:${ASAN_DEBUG_DLL}>$<$<NOT:$<CONFIG:Debug>>:${ASAN_RELEASE_DLL}>"
|
|
171
|
+
"$<TARGET_FILE_DIR:${name}>"
|
|
172
|
+
COMMENT "Copying ASan DLL: ${ASAN_DLL} -> $<TARGET_FILE_DIR:${name}>"
|
|
173
|
+
)
|
|
174
|
+
endif()
|
|
175
|
+
endfunction(add_hermes_tool)
|
|
176
|
+
|
|
177
|
+
# find_package()is not able to find packages specified with <name>_DIR if
|
|
178
|
+
# CMAKE_SYSROOT or CMAKE_FIND_ROOT_PATH is set, because find_file() is being
|
|
179
|
+
# restricted in where it looks.
|
|
180
|
+
# This wrapper adds <name>_DIR to CMAKE_FIND_ROOT_PATH so find_package() can
|
|
181
|
+
# find it.
|
|
182
|
+
macro(find_global_package name)
|
|
183
|
+
# If we have a CMAKE_SYSROOT or CMAKE_FIND_ROOT_PATH and <name>_ROOT is set,
|
|
184
|
+
# temporarily add <name>_ROOT to the search path
|
|
185
|
+
if (((NOT "${CMAKE_SYSROOT}" STREQUAL "") OR
|
|
186
|
+
(NOT "${CMAKE_FIND_ROOT_PATH}" STREQUAL "")) AND
|
|
187
|
+
(NOT "${${name}_ROOT}" STREQUAL ""))
|
|
188
|
+
|
|
189
|
+
list(APPEND CMAKE_FIND_ROOT_PATH "${${name}_ROOT}")
|
|
190
|
+
find_package(${name} ${ARGN})
|
|
191
|
+
list(REMOVE_AT CMAKE_FIND_ROOT_PATH -1)
|
|
192
|
+
|
|
193
|
+
else ()
|
|
194
|
+
|
|
195
|
+
find_package(${name} ${ARGN})
|
|
196
|
+
|
|
197
|
+
endif ()
|
|
198
|
+
endmacro(find_global_package)
|
|
199
|
+
|
|
200
|
+
function(append value)
|
|
201
|
+
foreach (variable ${ARGN})
|
|
202
|
+
set(${variable} "${${variable}} ${value}" PARENT_SCOPE)
|
|
203
|
+
endforeach (variable)
|
|
204
|
+
endfunction()
|
|
205
|
+
|
|
206
|
+
function(append_if condition value)
|
|
207
|
+
if (${condition})
|
|
208
|
+
foreach (variable ${ARGN})
|
|
209
|
+
set(${variable} "${${variable}} ${value}" PARENT_SCOPE)
|
|
210
|
+
endforeach (variable)
|
|
211
|
+
endif ()
|
|
212
|
+
endfunction()
|
|
213
|
+
|
|
214
|
+
macro(add_flag_if_supported flag name)
|
|
215
|
+
check_c_compiler_flag("-Werror ${flag}" "C_SUPPORTS_${name}")
|
|
216
|
+
append_if("C_SUPPORTS_${name}" "${flag}" CMAKE_C_FLAGS)
|
|
217
|
+
check_cxx_compiler_flag("-Werror ${flag}" "CXX_SUPPORTS_${name}")
|
|
218
|
+
append_if("CXX_SUPPORTS_${name}" "${flag}" CMAKE_CXX_FLAGS)
|
|
219
|
+
endmacro()
|
|
220
|
+
|
|
221
|
+
function(add_flag_or_print_warning flag name)
|
|
222
|
+
check_c_compiler_flag("-Werror ${flag}" "C_SUPPORTS_${name}")
|
|
223
|
+
check_cxx_compiler_flag("-Werror ${flag}" "CXX_SUPPORTS_${name}")
|
|
224
|
+
if (C_SUPPORTS_${name} AND CXX_SUPPORTS_${name})
|
|
225
|
+
message(STATUS "Building with ${flag}")
|
|
226
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}" PARENT_SCOPE)
|
|
227
|
+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}" PARENT_SCOPE)
|
|
228
|
+
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} ${flag}" PARENT_SCOPE)
|
|
229
|
+
else ()
|
|
230
|
+
message(WARNING "${flag} is not supported.")
|
|
231
|
+
endif ()
|
|
232
|
+
endfunction()
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
#
|
|
236
|
+
# Enable warnings
|
|
237
|
+
#
|
|
238
|
+
if (XCODE)
|
|
239
|
+
# For Xcode enable several build settings that correspond to
|
|
240
|
+
# many warnings that are on by default in Clang but are
|
|
241
|
+
# not enabled for historical reasons. For versions of Xcode
|
|
242
|
+
# that do not support these options they will simply
|
|
243
|
+
# be ignored.
|
|
244
|
+
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_ABOUT_RETURN_TYPE "YES")
|
|
245
|
+
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_ABOUT_MISSING_NEWLINE "YES")
|
|
246
|
+
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNUSED_VALUE "YES")
|
|
247
|
+
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNUSED_VARIABLE "YES")
|
|
248
|
+
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_SIGN_COMPARE "YES")
|
|
249
|
+
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNUSED_FUNCTION "YES")
|
|
250
|
+
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED "YES")
|
|
251
|
+
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS "YES")
|
|
252
|
+
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNINITIALIZED_AUTOS "YES")
|
|
253
|
+
set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_BOOL_CONVERSION "YES")
|
|
254
|
+
set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_EMPTY_BODY "YES")
|
|
255
|
+
set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_ENUM_CONVERSION "YES")
|
|
256
|
+
set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_INT_CONVERSION "YES")
|
|
257
|
+
set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_CONSTANT_CONVERSION "YES")
|
|
258
|
+
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_NON_VIRTUAL_DESTRUCTOR "YES")
|
|
259
|
+
endif ()
|
|
260
|
+
|
|
261
|
+
if (MSVC)
|
|
262
|
+
# Remove CMake's default exception handling flags to avoid D9025 warnings
|
|
263
|
+
# when we set our own in hermes_update_cxx_flags()
|
|
264
|
+
string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
|
265
|
+
string(REPLACE "/EHsc" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
|
266
|
+
|
|
267
|
+
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0)
|
|
268
|
+
# For MSVC 2013, disable iterator null pointer checking in debug mode,
|
|
269
|
+
# especially so std::equal(nullptr, nullptr, nullptr) will not assert.
|
|
270
|
+
add_definitions("-D_DEBUG_POINTER_IMPL=")
|
|
271
|
+
endif ()
|
|
272
|
+
|
|
273
|
+
if (MSVC11)
|
|
274
|
+
add_definitions(-D_VARIADIC_MAX=10)
|
|
275
|
+
endif ()
|
|
276
|
+
|
|
277
|
+
# Add definitions that make MSVC much less annoying.
|
|
278
|
+
add_definitions(
|
|
279
|
+
# For some reason MS wants to deprecate a bunch of standard functions...
|
|
280
|
+
-D_CRT_SECURE_NO_DEPRECATE
|
|
281
|
+
-D_CRT_SECURE_NO_WARNINGS
|
|
282
|
+
-D_CRT_NONSTDC_NO_DEPRECATE
|
|
283
|
+
-D_CRT_NONSTDC_NO_WARNINGS
|
|
284
|
+
-D_SCL_SECURE_NO_DEPRECATE
|
|
285
|
+
-D_SCL_SECURE_NO_WARNINGS
|
|
286
|
+
)
|
|
287
|
+
|
|
288
|
+
# Tell MSVC to use the Unicode version of the Win32 APIs instead of ANSI.
|
|
289
|
+
# add_definitions(
|
|
290
|
+
# -DUNICODE
|
|
291
|
+
# -D_UNICODE
|
|
292
|
+
# )
|
|
293
|
+
|
|
294
|
+
# Turn warnings into errors.
|
|
295
|
+
# append("/WX" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
|
|
296
|
+
|
|
297
|
+
# Remove unreferenced data or functions that are COMDATs, or that only have
|
|
298
|
+
# internal linkage.
|
|
299
|
+
append("/Zc:inline" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
|
|
300
|
+
|
|
301
|
+
# "Generate Intrinsic Functions".
|
|
302
|
+
append("/Oi" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
|
|
303
|
+
|
|
304
|
+
# "Enforce type conversion rules".
|
|
305
|
+
append("/Zc:rvalueCast" CMAKE_CXX_FLAGS)
|
|
306
|
+
|
|
307
|
+
if (NOT CLANG_CL)
|
|
308
|
+
set(msvc_warning_flags
|
|
309
|
+
# Disabled warnings.
|
|
310
|
+
-wd4141 # Suppress ''modifier' : used more than once' (because of __forceinline combined with inline)
|
|
311
|
+
-wd4146 # Suppress 'unary minus operator applied to unsigned type, result still unsigned'
|
|
312
|
+
-wd4180 # Suppress 'qualifier applied to function type has no meaning; ignored'
|
|
313
|
+
-wd4244 # Suppress ''argument' : conversion from 'type1' to 'type2', possible loss of data'
|
|
314
|
+
-wd4258 # Suppress ''var' : definition from the for loop is ignored; the definition from the enclosing scope is used'
|
|
315
|
+
-wd4267 # Suppress ''var' : conversion from 'size_t' to 'type', possible loss of data'
|
|
316
|
+
-wd4291 # Suppress ''declaration' : no matching operator delete found; memory will not be freed if initialization throws an exception'
|
|
317
|
+
-wd4345 # Suppress 'behavior change: an object of POD type constructed with an initializer of the form () will be default-initialized'
|
|
318
|
+
-wd4351 # Suppress 'new behavior: elements of array 'array' will be default initialized'
|
|
319
|
+
-wd4355 # Suppress ''this' : used in base member initializer list'
|
|
320
|
+
-wd4456 # Suppress 'declaration of 'var' hides local variable'
|
|
321
|
+
-wd4457 # Suppress 'declaration of 'var' hides function parameter'
|
|
322
|
+
-wd4458 # Suppress 'declaration of 'var' hides class member'
|
|
323
|
+
-wd4459 # Suppress 'declaration of 'var' hides global declaration'
|
|
324
|
+
-wd4503 # Suppress ''identifier' : decorated name length exceeded, name was truncated'
|
|
325
|
+
-wd4624 # Suppress ''derived class' : destructor could not be generated because a base class destructor is inaccessible'
|
|
326
|
+
-wd4722 # Suppress 'function' : destructor never returns, potential memory leak
|
|
327
|
+
-wd4800 # Suppress ''type' : forcing value to bool 'true' or 'false' (performance warning)'
|
|
328
|
+
-wd4100 # Suppress 'unreferenced formal parameter'
|
|
329
|
+
-wd4127 # Suppress 'conditional expression is constant'
|
|
330
|
+
-wd4512 # Suppress 'assignment operator could not be generated'
|
|
331
|
+
-wd4505 # Suppress 'unreferenced local function has been removed'
|
|
332
|
+
-wd4610 # Suppress '<class> can never be instantiated'
|
|
333
|
+
-wd4510 # Suppress 'default constructor could not be generated'
|
|
334
|
+
-wd4702 # Suppress 'unreachable code'
|
|
335
|
+
-wd4245 # Suppress 'signed/unsigned mismatch'
|
|
336
|
+
-wd4706 # Suppress 'assignment within conditional expression'
|
|
337
|
+
-wd4310 # Suppress 'cast truncates constant value'
|
|
338
|
+
-wd4701 # Suppress 'potentially uninitialized local variable'
|
|
339
|
+
-wd4703 # Suppress 'potentially uninitialized local pointer variable'
|
|
340
|
+
-wd4389 # Suppress 'signed/unsigned mismatch'
|
|
341
|
+
-wd4611 # Suppress 'interaction between '_setjmp' and C++ object destruction is non-portable'
|
|
342
|
+
-wd4805 # Suppress 'unsafe mix of type <type> and type <type> in operation'
|
|
343
|
+
-wd4204 # Suppress 'nonstandard extension used : non-constant aggregate initializer'
|
|
344
|
+
-wd4577 # Suppress 'noexcept used with no exception handling mode specified; termination on exception is not guaranteed'
|
|
345
|
+
-wd4091 # Suppress 'typedef: ignored on left of '' when no variable is declared'
|
|
346
|
+
# C4592 is disabled because of false positives in Visual Studio 2015
|
|
347
|
+
# Update 1. Re-evaluate the usefulness of this diagnostic with Update 2.
|
|
348
|
+
-wd4592 # Suppress ''var': symbol will be dynamically initialized (implementation limitation)
|
|
349
|
+
-wd4319 # Suppress ''operator' : zero extending 'type' to 'type' of greater size'
|
|
350
|
+
-wd4576 # Suppress 'a parenthesized type followed by an initializer list is a non-standard explicit type conversion syntax'
|
|
351
|
+
|
|
352
|
+
# Ideally, we'd like this warning to be enabled, but MSVC 2013 doesn't
|
|
353
|
+
# support the 'aligned' attribute in the way that clang sources requires (for
|
|
354
|
+
# any code that uses the LLVM_ALIGNAS macro), so this is must be disabled to
|
|
355
|
+
# avoid unwanted alignment warnings.
|
|
356
|
+
# When we switch to requiring a version of MSVC that supports the 'alignas'
|
|
357
|
+
# specifier (MSVC 2015?) this warning can be re-enabled.
|
|
358
|
+
-wd4324 # Suppress 'structure was padded due to __declspec(align())'
|
|
359
|
+
|
|
360
|
+
# Promoted warnings.
|
|
361
|
+
-w14062 # Promote 'enumerator in switch of enum is not handled' to level 1 warning.
|
|
362
|
+
|
|
363
|
+
# Promoted warnings to errors.
|
|
364
|
+
-we4238 # Promote 'nonstandard extension used : class rvalue used as lvalue' to error.
|
|
365
|
+
)
|
|
366
|
+
endif (NOT CLANG_CL)
|
|
367
|
+
foreach (flag ${msvc_warning_flags})
|
|
368
|
+
append("${flag}" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
|
|
369
|
+
endforeach (flag)
|
|
370
|
+
endif (MSVC)
|
|
371
|
+
|
|
372
|
+
# Enable -Werror=undef for Hermes-owned directories to catch missing config
|
|
373
|
+
# includes. Called from subdirectory CMakeLists.txt files (lib/, tools/, etc.).
|
|
374
|
+
# On GCC < 13 C++, #pragma GCC diagnostic ignored "-Wundef" doesn't suppress
|
|
375
|
+
# -Werror=undef (compiler bug fixed in GCC 13), so we only enable it for C++
|
|
376
|
+
# when the compiler is not affected.
|
|
377
|
+
macro(hermes_enable_werror_undef)
|
|
378
|
+
if (GCC_COMPATIBLE)
|
|
379
|
+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=undef")
|
|
380
|
+
if (NOT (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND
|
|
381
|
+
CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13))
|
|
382
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=undef")
|
|
383
|
+
endif()
|
|
384
|
+
endif()
|
|
385
|
+
endmacro()
|
|
386
|
+
|
|
387
|
+
if (GCC_COMPATIBLE)
|
|
388
|
+
# Don't add -Wall for clang-cl, because it maps -Wall to -Weverything for
|
|
389
|
+
# MSVC compatibility. /W4 is added above instead.
|
|
390
|
+
if (NOT CLANG_CL)
|
|
391
|
+
append("-Wall" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
|
|
392
|
+
endif ()
|
|
393
|
+
|
|
394
|
+
append("-Wextra -Wno-unused-parameter -Wwrite-strings" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
|
|
395
|
+
append("-Wcast-qual" CMAKE_CXX_FLAGS)
|
|
396
|
+
append("-Wno-invalid-offsetof" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
|
|
397
|
+
|
|
398
|
+
# Turn off missing field initializer warnings for gcc to avoid noise from
|
|
399
|
+
# false positives with empty {}. Turn them on otherwise (they're off by
|
|
400
|
+
# default for clang).
|
|
401
|
+
check_cxx_compiler_flag("-Wmissing-field-initializers" CXX_SUPPORTS_MISSING_FIELD_INITIALIZERS_FLAG)
|
|
402
|
+
if (CXX_SUPPORTS_MISSING_FIELD_INITIALIZERS_FLAG)
|
|
403
|
+
if (CMAKE_COMPILER_IS_GNUCXX)
|
|
404
|
+
append("-Wno-missing-field-initializers" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
|
|
405
|
+
else ()
|
|
406
|
+
append("-Wmissing-field-initializers" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
|
|
407
|
+
endif ()
|
|
408
|
+
endif ()
|
|
409
|
+
|
|
410
|
+
# Disable gcc's potentially uninitialized use analysis as it presents lots of
|
|
411
|
+
# false positives.
|
|
412
|
+
if (CMAKE_COMPILER_IS_GNUCXX)
|
|
413
|
+
check_cxx_compiler_flag("-Wmaybe-uninitialized" MAYBE_UNINITIALIZED_FLAG)
|
|
414
|
+
append_if(MAYBE_UNINITIALIZED_FLAG "-Wno-maybe-uninitialized" CMAKE_CXX_FLAGS)
|
|
415
|
+
if (NOT MAYBE_UNINITIALIZED_FLAG)
|
|
416
|
+
# Only recent versions of gcc make the distinction between -Wuninitialized
|
|
417
|
+
# and -Wmaybe-uninitialized. If -Wmaybe-uninitialized isn't supported, just
|
|
418
|
+
# turn off all uninitialized use warnings.
|
|
419
|
+
check_cxx_compiler_flag("-Wuninitialized" UNINITIALIZED_FLAG)
|
|
420
|
+
append_if(UNINITIALIZED_FLAG "-Wno-uninitialized" CMAKE_CXX_FLAGS)
|
|
421
|
+
endif ()
|
|
422
|
+
|
|
423
|
+
# Suppress uninteresting warnings about initializing ArrayRef from initializer lists.
|
|
424
|
+
check_cxx_compiler_flag("-Winit-list-lifetime" INIT_LIST_LIFETIME_FLAG)
|
|
425
|
+
append_if(INIT_LIST_LIFETIME_FLAG "-Wno-init-list-lifetime" CMAKE_CXX_FLAGS)
|
|
426
|
+
|
|
427
|
+
# Suppress the redundant move warnings in GCC 9, because it leads to suboptimal
|
|
428
|
+
# recommendations for older compilers that do not implement C++ Core Issue 1579.
|
|
429
|
+
check_cxx_compiler_flag("-Wredundant-move" REDUNDANT_MOVE_FLAG)
|
|
430
|
+
append_if(REDUNDANT_MOVE_FLAG "-Wno-redundant-move" CMAKE_CXX_FLAGS)
|
|
431
|
+
endif ()
|
|
432
|
+
|
|
433
|
+
# This warning generates a lot of noise in gtest.
|
|
434
|
+
check_cxx_compiler_flag("-Wdeprecated-copy" DEPRECATED_COPY_FLAG)
|
|
435
|
+
append_if(DEPRECATED_COPY_FLAG "-Wno-deprecated-copy" CMAKE_CXX_FLAGS)
|
|
436
|
+
|
|
437
|
+
# Disable -Wclass-memaccess, a C++-only warning from GCC 8 that fires on
|
|
438
|
+
# LLVM's ADT classes.
|
|
439
|
+
check_cxx_compiler_flag("-Wclass-memaccess" CXX_SUPPORTS_CLASS_MEMACCESS_FLAG)
|
|
440
|
+
append_if(CXX_SUPPORTS_CLASS_MEMACCESS_FLAG "-Wno-class-memaccess" CMAKE_CXX_FLAGS)
|
|
441
|
+
|
|
442
|
+
# The LLVM libraries have no stable C++ API, so -Wnoexcept-type is not useful.
|
|
443
|
+
check_cxx_compiler_flag("-Wnoexcept-type" CXX_SUPPORTS_NOEXCEPT_TYPE_FLAG)
|
|
444
|
+
append_if(CXX_SUPPORTS_NOEXCEPT_TYPE_FLAG "-Wno-noexcept-type" CMAKE_CXX_FLAGS)
|
|
445
|
+
|
|
446
|
+
# Check if -Wnon-virtual-dtor warns even though the class is marked final.
|
|
447
|
+
# If it does, don't add it. So it won't be added on clang 3.4 and older.
|
|
448
|
+
# This also catches cases when -Wnon-virtual-dtor isn't supported by
|
|
449
|
+
# the compiler at all. This flag is not activated for gcc since it will
|
|
450
|
+
# incorrectly identify a protected non-virtual base when there is a friend
|
|
451
|
+
# declaration. Don't activate this in general on Windows as this warning has
|
|
452
|
+
# too many false positives on COM-style classes, which are destroyed with
|
|
453
|
+
# Release() (PR32286).
|
|
454
|
+
if (NOT CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32)
|
|
455
|
+
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
|
|
456
|
+
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++17 -Werror=non-virtual-dtor")
|
|
457
|
+
CHECK_CXX_SOURCE_COMPILES("class base {public: virtual void anchor();protected: ~base();};
|
|
458
|
+
class derived final : public base { public: ~derived();};
|
|
459
|
+
int main() { return 0; }"
|
|
460
|
+
CXX_WONT_WARN_ON_FINAL_NONVIRTUALDTOR)
|
|
461
|
+
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
|
|
462
|
+
append_if(CXX_WONT_WARN_ON_FINAL_NONVIRTUALDTOR
|
|
463
|
+
"-Wnon-virtual-dtor" CMAKE_CXX_FLAGS)
|
|
464
|
+
endif ()
|
|
465
|
+
|
|
466
|
+
# Enable -Wdelete-non-virtual-dtor if available.
|
|
467
|
+
add_flag_if_supported("-Wdelete-non-virtual-dtor" DELETE_NON_VIRTUAL_DTOR_FLAG)
|
|
468
|
+
|
|
469
|
+
# Avoid triggering arbitrary UB when converting doubles to ints.
|
|
470
|
+
# TODO(T108716033) Evaluate adding this flag back in once a new clang is
|
|
471
|
+
# released or XCode is fixed.
|
|
472
|
+
# add_flag_if_supported("-fno-strict-float-cast-overflow" NO_STRICT_FLOAT_CAST_OVERFLOW_FLAG)
|
|
473
|
+
|
|
474
|
+
# GCC uses fp-contract=fast by default, use "on" instead so that we can
|
|
475
|
+
# control it in source where needed.
|
|
476
|
+
add_flag_if_supported("-ffp-contract=on" FP_CONTRACT_FLAG)
|
|
477
|
+
|
|
478
|
+
# Disable range loop analysis warnings.
|
|
479
|
+
check_cxx_compiler_flag("-Wrange-loop-analysis" RANGE_ANALYSIS_FLAG)
|
|
480
|
+
append_if(RANGE_ANALYSIS_FLAG "-Wno-range-loop-analysis" CMAKE_CXX_FLAGS)
|
|
481
|
+
endif (GCC_COMPATIBLE)
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
#
|
|
3
|
+
# This source code is licensed under the MIT license found in the
|
|
4
|
+
# LICENSE file in the root directory of this source tree.
|
|
5
|
+
|
|
6
|
+
set(HERMES_LIT_PATH "${HERMES_TOOLS_OUTPUT_DIR}/hermes-lit")
|
|
7
|
+
if (CMAKE_HOST_WIN32 AND NOT CYGWIN)
|
|
8
|
+
# llvm-lit needs suffix.py for multiprocess to find a main module.
|
|
9
|
+
set(HERMES_LIT_PATH "${HERMES_LIT_PATH}.py")
|
|
10
|
+
endif ()
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
# A raw function to create a lit target. This is used to implement the testuite
|
|
14
|
+
# management functions.
|
|
15
|
+
function(add_lit_target target comment)
|
|
16
|
+
cmake_parse_arguments(ARG "" "" "PARAMS;DEPENDS;ARGS" ${ARGN})
|
|
17
|
+
set(LIT_ARGS "${ARG_ARGS} ${LLVH_LIT_ARGS}")
|
|
18
|
+
separate_arguments(LIT_ARGS)
|
|
19
|
+
|
|
20
|
+
set(LIT_COMMAND "${Python_EXECUTABLE};${HERMES_LIT_PATH}")
|
|
21
|
+
list(APPEND LIT_COMMAND ${LIT_ARGS})
|
|
22
|
+
foreach(param ${ARG_PARAMS})
|
|
23
|
+
list(APPEND LIT_COMMAND --param ${param})
|
|
24
|
+
endforeach()
|
|
25
|
+
if (ARG_UNPARSED_ARGUMENTS)
|
|
26
|
+
add_custom_target(${target}
|
|
27
|
+
COMMAND ${LIT_COMMAND} ${ARG_UNPARSED_ARGUMENTS}
|
|
28
|
+
COMMENT "${comment}"
|
|
29
|
+
USES_TERMINAL
|
|
30
|
+
)
|
|
31
|
+
else()
|
|
32
|
+
add_custom_target(${target}
|
|
33
|
+
COMMAND ${CMAKE_COMMAND} -E echo "${target} does nothing, no tools built.")
|
|
34
|
+
message(STATUS "${target} does nothing.")
|
|
35
|
+
endif()
|
|
36
|
+
|
|
37
|
+
# Add lit test dependencies.
|
|
38
|
+
set(llvm_utils_deps
|
|
39
|
+
FileCheck count not
|
|
40
|
+
)
|
|
41
|
+
foreach(dep ${llvm_utils_deps})
|
|
42
|
+
if (TARGET ${dep})
|
|
43
|
+
add_dependencies(${target} ${dep})
|
|
44
|
+
endif()
|
|
45
|
+
endforeach()
|
|
46
|
+
|
|
47
|
+
if (ARG_DEPENDS)
|
|
48
|
+
add_dependencies(${target} ${ARG_DEPENDS})
|
|
49
|
+
endif()
|
|
50
|
+
|
|
51
|
+
# Tests should be excluded from "Build Solution".
|
|
52
|
+
set_target_properties(${target} PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD ON)
|
|
53
|
+
endfunction()
|
|
54
|
+
|
|
55
|
+
# A function to add a set of lit test suites to be driven through 'check-*' targets.
|
|
56
|
+
function(add_lit_testsuite target comment)
|
|
57
|
+
cmake_parse_arguments(ARG "" "" "PARAMS;DEPENDS;ARGS" ${ARGN})
|
|
58
|
+
|
|
59
|
+
# Produce a specific suffixed check rule.
|
|
60
|
+
add_lit_target(${target} ${comment}
|
|
61
|
+
${ARG_UNPARSED_ARGUMENTS}
|
|
62
|
+
PARAMS ${ARG_PARAMS}
|
|
63
|
+
DEPENDS ${ARG_DEPENDS}
|
|
64
|
+
ARGS ${ARG_ARGS}
|
|
65
|
+
)
|
|
66
|
+
endfunction()
|
|
67
|
+
|
|
68
|
+
function(add_unittest test_suite test_name)
|
|
69
|
+
# Our current version of gtest does not properly recognize C++11 support
|
|
70
|
+
# with MSVC, so it falls back to tr1 / experimental classes. Since LLVM
|
|
71
|
+
# itself requires C++11, we can safely force it on unconditionally so that
|
|
72
|
+
# we don't have to fight with the buggy gtest check.
|
|
73
|
+
add_definitions(-DGTEST_LANG_CXX11=1)
|
|
74
|
+
add_definitions(-DGTEST_HAS_TR1_TUPLE=0)
|
|
75
|
+
|
|
76
|
+
include_directories(${LLVH_SOURCE_DIR}/utils/unittest/googletest/include)
|
|
77
|
+
include_directories(${LLVH_SOURCE_DIR}/utils/unittest/googlemock/include)
|
|
78
|
+
|
|
79
|
+
# if (SUPPORTS_VARIADIC_MACROS_FLAG)
|
|
80
|
+
# list(APPEND LLVM_COMPILE_FLAGS "-Wno-variadic-macros")
|
|
81
|
+
# endif ()
|
|
82
|
+
# # Some parts of gtest rely on this GNU extension, don't warn on it.
|
|
83
|
+
# if(SUPPORTS_GNU_ZERO_VARIADIC_MACRO_ARGUMENTS_FLAG)
|
|
84
|
+
# list(APPEND LLVM_COMPILE_FLAGS "-Wno-gnu-zero-variadic-macro-arguments")
|
|
85
|
+
# endif()
|
|
86
|
+
|
|
87
|
+
add_hermes_executable(${test_name} ${ARGN})
|
|
88
|
+
|
|
89
|
+
target_link_libraries(${test_name} llvh-gtest_main)
|
|
90
|
+
|
|
91
|
+
add_dependencies(${test_suite} ${test_name})
|
|
92
|
+
get_target_property(test_suite_folder ${test_suite} FOLDER)
|
|
93
|
+
if (NOT ${test_suite_folder} STREQUAL "NOTFOUND")
|
|
94
|
+
set_property(TARGET ${test_name} PROPERTY FOLDER "${test_suite_folder}")
|
|
95
|
+
endif ()
|
|
96
|
+
endfunction()
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: branches
|
|
3
|
+
title: Branches and Releases
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
The branch layout of this repository reflects its history more than a plan,
|
|
7
|
+
so here is a map.
|
|
8
|
+
|
|
9
|
+
## `static_h`: active development
|
|
10
|
+
|
|
11
|
+
All development happens on `static_h`. Pull requests are opened against it
|
|
12
|
+
(see [CONTRIBUTING.md](../CONTRIBUTING.md)). The name is a leftover from the
|
|
13
|
+
"Static Hermes" project that started on this branch; see the README for the
|
|
14
|
+
history. Everything described in this documentation refers to `static_h`
|
|
15
|
+
unless it says otherwise.
|
|
16
|
+
|
|
17
|
+
## `main`: the legacy line
|
|
18
|
+
|
|
19
|
+
`main` carries the original Hermes, the engine that shipped in React Native
|
|
20
|
+
for years with 0.x version numbers. It receives few changes and no new
|
|
21
|
+
features. It is not the base for new work.
|
|
22
|
+
|
|
23
|
+
## Release branches
|
|
24
|
+
|
|
25
|
+
Releases from `static_h` are the ones React Native calls **Hermes V1**. They
|
|
26
|
+
are versioned independently of React Native. A release lives on a pair of
|
|
27
|
+
branches named after its version:
|
|
28
|
+
|
|
29
|
+
* `<version>-staging`: where a release is prepared.
|
|
30
|
+
* `<version>-stable`: the released line. Fixes are grafted onto it from
|
|
31
|
+
`static_h` as needed, and patch releases are cut from it.
|
|
32
|
+
|
|
33
|
+
For example, `260318099.0.0-stable` is the stable branch of release
|
|
34
|
+
260318099.0.0. The leading number encodes the date the release was branched
|
|
35
|
+
and the bytecode version it ships, so `260318099` is 2026-03-18 with
|
|
36
|
+
bytecode version 99.
|
|
37
|
+
|
|
38
|
+
The older `release-v0.x` branches and `v0.x` tags belong to the legacy line.
|