Compare commits

...

3 Commits

Author SHA1 Message Date
DonIsaac
0fec40ad52 bun run prettier:extra 2025-02-28 23:43:36 +00:00
Don Isaac
28ec398137 disable logging for safe builds 2025-02-28 15:42:10 -08:00
Don Isaac
0657304773 ci: build with runtime safety checks for PRs 2025-02-28 15:16:57 -08:00
7 changed files with 29 additions and 5 deletions

View File

@@ -35,7 +35,7 @@ import {
* @typedef {"musl"} Abi
* @typedef {"debian" | "ubuntu" | "alpine" | "amazonlinux"} Distro
* @typedef {"latest" | "previous" | "oldest" | "eol"} Tier
* @typedef {"release" | "assert" | "debug"} Profile
* @typedef {"release" | "safe" | "assert" | "debug"} Profile
*/
/**
@@ -380,6 +380,7 @@ function getTestAgent(platform, options) {
function getBuildEnv(target, options) {
const { profile, baseline, abi } = target;
const release = !profile || profile === "release";
const safe = profile === "safe";
const { canary } = options;
const revision = typeof canary === "number" ? canary : 1;
@@ -389,7 +390,7 @@ function getBuildEnv(target, options) {
ENABLE_CANARY: revision > 0 ? "ON" : "OFF",
CANARY_REVISION: revision,
ENABLE_ASSERTIONS: release ? "OFF" : "ON",
ENABLE_LOGS: release ? "OFF" : "ON",
ENABLE_LOGS: release || safe ? "OFF" : "ON",
ABI: abi === "musl" ? "musl" : undefined,
CMAKE_TLS_VERIFY: "0",
@@ -817,6 +818,10 @@ function getOptionsStep() {
label: `${getEmoji("assert")} Release with Assertions`,
value: "assert",
},
{
label: `${getEmoji("safe")} Release with Runtime Safety Checks`,
value: "safe",
},
{
label: `${getEmoji("debug")} Debug`,
value: "debug",
@@ -997,6 +1002,8 @@ async function getPipelineOptions() {
return false;
};
const isOnMain = isMainBranch();
const isCanary =
!parseBoolean(getEnv("RELEASE", false) || "false") &&
!/\[(release|build release|release build)\]/i.test(commitMessage);
@@ -1011,7 +1018,7 @@ async function getPipelineOptions() {
publishImages: parseOption(/\[(publish images?)\]/i),
buildPlatforms: Array.from(buildPlatformsMap.values()),
testPlatforms: Array.from(testPlatformsMap.values()),
buildProfiles: ["release"],
buildProfiles: isOnMain ? ["release"] : ["safe"],
};
}

View File

@@ -218,6 +218,13 @@ if(ENABLE_ASSERTIONS)
)
endif()
else()
if(ENABLE_SAFE)
register_compiler_flags(
DESCRIPTION "Do not eliminate null-pointer checks"
-fno-delete-null-pointer-checks
)
endif()
register_compiler_definitions(
DESCRIPTION "Disable debug assertions"
NDEBUG=1

View File

@@ -30,6 +30,10 @@ if(CMAKE_BUILD_TYPE MATCHES "MinSizeRel")
setx(ENABLE_SMOL ON)
endif()
if(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
setx(ENABLE_SAFE ON)
endif()
if(APPLE)
setx(OS "darwin")
elseif(WIN32)
@@ -86,6 +90,7 @@ optionx(ENABLE_LTO BOOL "If LTO (link-time optimization) should be used" DEFAULT
if(LINUX)
optionx(ENABLE_VALGRIND BOOL "If Valgrind support should be enabled" DEFAULT OFF)
endif()
if(DEBUG AND APPLE AND CMAKE_SYSTEM_PROCESSOR MATCHES "arm64|aarch64")
optionx(ENABLE_ASAN BOOL "If ASAN support should be enabled" DEFAULT ON)
else()
@@ -109,6 +114,7 @@ else()
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
if(NOT DEFAULT_REVISION AND NOT DEFINED ENV{GIT_SHA} AND NOT DEFINED ENV{GITHUB_SHA})
set(DEFAULT_REVISION "unknown")
endif()
@@ -139,6 +145,7 @@ if(CMAKE_HOST_LINUX AND NOT WIN32 AND NOT APPLE)
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
if(LINUX_DISTRO MATCHES "NAME=\"(Arch|Manjaro|Artix) Linux( ARM)?\"|NAME=\"openSUSE Tumbleweed\"")
set(DEFAULT_STATIC_LIBATOMIC OFF)
endif()

View File

@@ -1,5 +1,7 @@
if(DEBUG)
set(bun bun-debug)
elseif(ENABLE_SAFE)
set(bun bun-safe)
elseif(ENABLE_SMOL)
set(bun bun-smol-profile)
set(bunStrip bun-smol)

View File

@@ -34,10 +34,10 @@
"build:debug": "bun ./scripts/build.mjs -GNinja -DCMAKE_BUILD_TYPE=Debug -B build/debug",
"build:valgrind": "bun ./scripts/build.mjs -GNinja -DCMAKE_BUILD_TYPE=Debug -DENABLE_BASELINE=ON -ENABLE_VALGRIND=ON -B build/debug-valgrind",
"build:release": "bun ./scripts/build.mjs -GNinja -DCMAKE_BUILD_TYPE=Release -B build/release",
"build:safe": "bun ./scripts/build.mjs -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -B build/release-safe",
"build:ci": "bun ./scripts/build.mjs -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILE=ON -DCI=true -B build/release-ci --verbose --fresh",
"build:assert": "bun ./scripts/build.mjs -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_ASSERTIONS=ON -DENABLE_LOGS=ON -B build/release-assert",
"build:logs": "bun ./scripts/build.mjs -GNinja -DCMAKE_BUILD_TYPE=Release -DENABLE_LOGS=ON -B build/release-logs",
"build:safe": "bun ./scripts/build.mjs -GNinja -DCMAKE_BUILD_TYPE=Release -DZIG_OPTIMIZE=ReleaseSafe -B build/release-safe",
"build:smol": "bun ./scripts/build.mjs -GNinja -DCMAKE_BUILD_TYPE=MinSizeRel -B build/release-smol",
"build:local": "bun ./scripts/build.mjs -GNinja -DCMAKE_BUILD_TYPE=Debug -DWEBKIT_LOCAL=ON -B build/debug-local",
"build:release:local": "bun ./scripts/build.mjs -GNinja -DCMAKE_BUILD_TYPE=Release -DWEBKIT_LOCAL=ON -B build/release-local",

View File

@@ -2777,6 +2777,7 @@ const emojiMap = {
false: ["❌", "x"],
debug: ["🐞", "bug"],
assert: ["🔍", "mag"],
safe: ["🔒", "lock"],
release: ["🏆", "trophy"],
gear: ["⚙️", "gear"],
clipboard: ["📋", "clipboard"],

View File

@@ -4263,7 +4263,7 @@ JSC::JSInternalPromise* GlobalObject::moduleLoaderImportModule(JSGlobalObject* j
BunString moduleNameZ;
String moduleName = moduleNameValue->value(globalObject);
#if BUN_DEBUG
#if BUN_DEBUG || ASSERT_ENABLED
auto startRefCount = moduleName.impl()->refCount();
#endif
if (moduleName.startsWith("file://"_s)) {