From c56e20c744a896764090d084d747b4aafe835c24 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Mon, 5 Sep 2022 04:58:15 -0700 Subject: [PATCH 1/4] fix: enable the cpp exception in the release build --- binding.gyp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/binding.gyp b/binding.gyp index 6ccb2149..f0196b80 100644 --- a/binding.gyp +++ b/binding.gyp @@ -85,7 +85,7 @@ 'configurations': { 'Debug': { - 'defines': ['NAPI_CPP_EXCEPTIONS', 'DEBUG', '_DEBUG'], + 'defines': ['NAPI_CPP_EXCEPTIONS', "-fexceptions", 'DEBUG', '_DEBUG'], 'conditions': [ ['OS == "linux" or OS == "freebsd" or OS == "openbsd" or OS == "solaris"', { 'cflags_cc!': [ @@ -161,7 +161,8 @@ 'Release': { 'defines': [ - 'NAPI_DISABLE_CPP_EXCEPTIONS', + 'NAPI_CPP_EXCEPTIONS', + "-fexceptions" ], 'conditions': [ ['OS == "linux" or OS == "freebsd" or OS == "openbsd" or OS == "solaris"', { @@ -200,6 +201,7 @@ 'RuntimeLibrary': 2, 'AdditionalOptions': [ '-std:c++17', + '/EHsc' ], }, 'VCLinkerTool': { From 2b723ce5f6ef689f7e6fbbe5d181b6e61a3017e9 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Mon, 5 Sep 2022 05:03:23 -0700 Subject: [PATCH 2/4] Revert "Revert "chore: add a separate debug build script"" This reverts commit 1aedf28493bd14f191835cbe81b74d39e8b4ec3d. --- package.json | 7 ++++--- tmp/.gitkeep | 0 2 files changed, 4 insertions(+), 3 deletions(-) delete mode 100644 tmp/.gitkeep diff --git a/package.json b/package.json index 729f3b24..72cf97bb 100644 --- a/package.json +++ b/package.json @@ -71,14 +71,15 @@ ], "scripts": { "install": "node-gyp-build", - "clean": "shx rm -rf build lib libzmq tmp zmq && shx mkdir -p tmp && shx touch tmp/.gitkeep", + "clean": "shx rm -rf build lib libzmq tmp zmq prebuilds && shx mkdir -p tmp && shx touch tmp/.gitkeep", "build.js": "tsc --project tsconfig-build.json && node script/ci/downlevel-dts.js", "build.doc": "typedoc --out docs --name zeromq.js --excludeProtected --excludePrivate --excludeNotExported --excludeExternals --externalPattern 'src/+(draft|native|compat).ts' --tsconfig tsconfig-build.json --mode file", "prebuild": "ts-node -P ./tsconfig.json ./script/prebuild.ts", - "build.native": "prebuildify --napi --build-from-source --debug", + "build.native": "prebuildify --napi --build-from-source", "build.native.debug": "npm run build.native -- --debug", "build": "npm run build.js && npm run build.native", - "test": "npm run build.js && mocha", + "build.debug": "npm run build.js && npm run build.native.debug", + "test": "npm run build.debug && mocha", "lint": "sh script/lint.sh", "bench": "node --expose-gc test/bench" }, diff --git a/tmp/.gitkeep b/tmp/.gitkeep deleted file mode 100644 index e69de29b..00000000 From e0b5423ab035ddefeda52816607fe94dc99fb337 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Mon, 5 Sep 2022 13:12:06 -0700 Subject: [PATCH 3/4] build: add -fexceptions to the cc flags --- binding.gyp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/binding.gyp b/binding.gyp index f0196b80..c678c0b2 100644 --- a/binding.gyp +++ b/binding.gyp @@ -85,7 +85,10 @@ 'configurations': { 'Debug': { - 'defines': ['NAPI_CPP_EXCEPTIONS', "-fexceptions", 'DEBUG', '_DEBUG'], + 'defines': ['NAPI_CPP_EXCEPTIONS', 'DEBUG', '_DEBUG'], + "cflags_cc": [ + "-fexceptions" + ], 'conditions': [ ['OS == "linux" or OS == "freebsd" or OS == "openbsd" or OS == "solaris"', { 'cflags_cc!': [ @@ -162,6 +165,8 @@ 'Release': { 'defines': [ 'NAPI_CPP_EXCEPTIONS', + ], + "cflags_cc": [ "-fexceptions" ], 'conditions': [ From 83bc414ee069a982741f10f16d851112ac279fff Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Mon, 5 Sep 2022 13:36:51 -0700 Subject: [PATCH 4/4] fix: exclude -fno-exceptions --- binding.gyp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/binding.gyp b/binding.gyp index c678c0b2..f64efe04 100644 --- a/binding.gyp +++ b/binding.gyp @@ -86,6 +86,9 @@ 'configurations': { 'Debug': { 'defines': ['NAPI_CPP_EXCEPTIONS', 'DEBUG', '_DEBUG'], + 'cflags_cc!': [ + "-fno-exceptions", + ], "cflags_cc": [ "-fexceptions" ], @@ -166,8 +169,11 @@ 'defines': [ 'NAPI_CPP_EXCEPTIONS', ], + 'cflags_cc!': [ + "-fno-exceptions", + ], "cflags_cc": [ - "-fexceptions" + "-fexceptions", ], 'conditions': [ ['OS == "linux" or OS == "freebsd" or OS == "openbsd" or OS == "solaris"', {