Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: add undefined behaviour address sanitizer feature #686

Merged
merged 1 commit into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ macro(set_option_from_env OPTION_NAME)
if("$ENV{npm_config_${OPTION_NAME_LOWER}}" STREQUAL "true")
set("${OPTION_NAME}"
ON
CACHE BOOL "npm_config_${OPTION_NAME_LOWER}")
CACHE BOOL "npm_config_${OPTION_NAME_LOWER}" FORCE)
elseif("$ENV{npm_config_${OPTION_NAME_LOWER}}" STREQUAL "false")
set("${OPTION_NAME}"
OFF
CACHE BOOL "npm_config_${OPTION_NAME_LOWER}")
CACHE BOOL "npm_config_${OPTION_NAME_LOWER}" FORCE)
else()
set("${OPTION_NAME}"
"$ENV{npm_config_${OPTION_NAME_LOWER}}"
CACHE STRING "npm_config_${OPTION_NAME_LOWER}")
CACHE STRING "npm_config_${OPTION_NAME_LOWER}" FORCE)
endif()
endif()

Expand Down Expand Up @@ -56,6 +56,13 @@ if(APPLE)
set(CMAKE_OSX_DEPLOYMENT_TARGET ${MACOSX_DEPLOYMENT_TARGET})
endif()

option(ZMQ_ENABLE_SANITIZER_UNDEFINED "Enable undefined behavior sanitizer" OFF)
set_option_from_env(ZMQ_ENABLE_SANITIZER_UNDEFINED)

if(${ZMQ_ENABLE_SANITIZER_UNDEFINED})
set(ENABLE_SANITIZER_UNDEFINED "ENABLE_SANITIZER_UNDEFINED")
endif()

# target system on Windows (for cross-compiling x86) and static linking runtimes
if(WIN32)
if("$ENV{Platform}" STREQUAL "x86")
Expand Down Expand Up @@ -107,7 +114,11 @@ run_vcpkg(VCPKG_URL "https://github.com/microsoft/vcpkg.git" VCPKG_REV
# Name of the project (will be the name of the plugin)
project(addon LANGUAGES C CXX)

project_options(ENABLE_CACHE ENABLE_COMPILE_COMMANDS_SYMLINK)
project_options(
ENABLE_CACHE
ENABLE_COMPILE_COMMANDS_SYMLINK
${ENABLE_SANITIZER_UNDEFINED}
)

file(GLOB_RECURSE SOURCES "./src/*.cc")
add_library(addon SHARED ${SOURCES})
Expand Down
24 changes: 22 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
],
"scripts": {
"install": "node ./script/install.js",
"clean": "shx rm -rf ./build ./prebuilds && run-p clean.lib clean.temp",
"clean": "shx rm -rf ./build ./prebuilds ./staging && run-p clean.lib clean.temp",
"clean.lib": "shx rm -rf ./lib/",
"clean.release": "shx rm -rf ./build/Release",
"clean.temp": "shx rm -rf ./tmp && shx mkdir -p ./tmp",
Expand All @@ -100,11 +100,13 @@
"build.doc": "typedoc --options ./typedoc.json && minify-all -s docs-unminified -d docs --jsCompressor terser && shx rm -rf docs-unminified",
"deploy.doc": "run-s build.doc && gh-pages --dist \"./docs\"",
"build.native": "cmake-ts nativeonly",
"build.native.debug": "cmake-ts dev-os-only",
"build.native.debug": "cross-env npm_config_zmq_enable_sanitizer_undefined=true cmake-ts dev-os-only",
"build": "run-p build.js build.native",
"build.debug": "run-s build.js build.native.debug",
"test": "run-s test.unit",
"test.debug": "run-s test.unit.debug",
"test.unit": "run-s clean.temp build && mocha ./test/unit/*-test.ts",
"test.unit.debug": "run-s clean.temp build.debug && mocha ./test/unit/*-test.ts",
"test.unit.compat": "run-s clean.temp build && cross-env INCLUDE_COMPAT_TESTS=true mocha ./test/unit/compat/*-test.ts",
"test.unit.nogc": "run-s clean.temp build && cross-env SKIP_GC_TESTS=true mocha",
"test.electron.main": "run-s clean.temp build && electron-mocha ./test/unit/*-test.ts",
Expand Down Expand Up @@ -143,6 +145,24 @@
"runtime": "node",
"runtimeVersion": "12.22.12"
},
{
"name": "darwin-arm64-dev",
"dev": true,
"buildType": "Debug",
"os": "darwin",
"arch": "arm64",
"runtime": "node",
"runtimeVersion": "12.22.12"
},
{
"name": "windows-x64-dev",
"dev": true,
"buildType": "Debug",
"os": "win32",
"arch": "x64",
"runtime": "node",
"runtimeVersion": "12.22.12"
},
{
"name": "windows-x64",
"os": "win32",
Expand Down
Loading