Skip to content

Commit

Permalink
Merge branch 'main' into pfg/e-string-changes-2
Browse files Browse the repository at this point in the history
  • Loading branch information
pfgithub committed Jan 9, 2025
2 parents 3d1cf02 + 5e003dc commit 344c9ea
Show file tree
Hide file tree
Showing 630 changed files with 53,298 additions and 28,079 deletions.
7 changes: 7 additions & 0 deletions .cursorignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Add directories or file patterns to ignore during indexing (e.g. foo/ or *.csv)
bench
vendor
*-fixture.{js,ts}
zig-cache
packages/bun-uws/fuzzing
build
26 changes: 26 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Lint

on:
pull_request:
workflow_dispatch:

env:
BUN_VERSION: "1.1.38"
OXLINT_VERSION: "0.15.0"

jobs:
lint-js:
name: "Lint JavaScript"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Bun
uses: ./.github/actions/setup-bun
with:
bun-version: ${{ env.BUN_VERSION }}
- name: Lint
run: bunx oxlint --config oxlint.json --quiet --format github




19 changes: 19 additions & 0 deletions .github/workflows/typos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Typos

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Spellcheck
uses: crate-ci/[email protected]
with:
files: docs/**/*
2 changes: 1 addition & 1 deletion .lldbinit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
command script import vendor/zig/tools/lldb_pretty_printers.py
# command script import vendor/zig/tools/lldb_pretty_printers.py
command script import vendor/WebKit/Tools/lldb/lldb_webkit.py

# type summary add --summary-string "${var} | inner=${var[0-30]}, source=${var[33-64]}, tag=${var[31-32]}" "unsigned long"
2 changes: 2 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# To learn more about git's mailmap: https://ntietz.com/blog/git-mailmap-for-name-changes
chloe caruso <[email protected]> <[email protected]>
2 changes: 2 additions & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[type.md]
extend-ignore-words-re = ["^ba"]
24 changes: 11 additions & 13 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Configuring a development environment for Bun can take 10-30 minutes depending on your internet connection and computer speed. You will need ~10GB of free disk space for the repository and build artifacts.

If you are using Windows, please refer to [this guide](/docs/project/building-windows.md)
If you are using Windows, please refer to [this guide](https://bun.sh/docs/project/building-windows)

## Install Dependencies

Expand Down Expand Up @@ -63,31 +63,29 @@ $ brew install llvm@18

```bash#Ubuntu/Debian
$ # LLVM has an automatic installation script that is compatible with all versions of Ubuntu
$ wget https://apt.llvm.org/llvm.sh -O - | sudo bash -s -- 16 all
$ wget https://apt.llvm.org/llvm.sh -O - | sudo bash -s -- 18 all
```

```bash#Arch
$ sudo pacman -S llvm clang lld
```

```bash#Fedora
$ sudo dnf install 'dnf-command(copr)'
$ sudo dnf copr enable -y @fedora-llvm-team/llvm17
$ sudo dnf install llvm16 clang16 lld16-devel
$ sudo dnf install llvm18 clang18 lld18-devel
```

```bash#openSUSE Tumbleweed
$ sudo zypper install clang16 lld16 llvm16
$ sudo zypper install clang18 lld18 llvm18
```

{% /codetabs %}

If none of the above solutions apply, you will have to install it [manually](https://github.com/llvm/llvm-project/releases/tag/llvmorg-16.0.6).
If none of the above solutions apply, you will have to install it [manually](https://github.com/llvm/llvm-project/releases/tag/llvmorg-18.1.8).

Make sure Clang/LLVM 18 is in your path:

```bash
$ which clang-16
$ which clang-18
```

If not, run this to manually add it:
Expand All @@ -96,13 +94,13 @@ If not, run this to manually add it:

```bash#macOS (Homebrew)
# use fish_add_path if you're using fish
# use path+="$(brew --prefix llvm@16)/bin" if you are using zsh
$ export PATH="$(brew --prefix llvm@16)/bin:$PATH"
# use path+="$(brew --prefix llvm@18)/bin" if you are using zsh
$ export PATH="$(brew --prefix llvm@18)/bin:$PATH"
```

```bash#Arch
# use fish_add_path if you're using fish
$ export PATH="$PATH:/usr/lib/llvm16/bin"
$ export PATH="$PATH:/usr/lib/llvm18/bin"
```

{% /codetabs %}
Expand Down Expand Up @@ -163,7 +161,7 @@ The binary will be located at `./build/release/bun` and `./build/release/bun-pro

### Download release build from pull requests

To save you time spent building a release build locally, we provide a way to run release builds from pull requests. This is useful for manully testing changes in a release build before they are merged.
To save you time spent building a release build locally, we provide a way to run release builds from pull requests. This is useful for manually testing changes in a release build before they are merged.

To run a release build from a pull request, you can use the `bun-pr` npm package:

Expand Down Expand Up @@ -240,7 +238,7 @@ The issue may manifest when initially running `bun setup` as Clang being unable
```
The C++ compiler
"/usr/bin/clang++-16"
"/usr/bin/clang++-18"
is not able to compile a simple test program.
```
Expand Down
2 changes: 1 addition & 1 deletion LATEST
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.39
1.1.42
Binary file modified bench/bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion bench/hot-module-reloading/css-stress-test/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ReactDOM from "react-dom";
import { Main } from "./main";

const Base = ({}) => {
const Base = () => {
const name = typeof location !== "undefined" ? decodeURIComponent(location.search.substring(1)) : null;
return <Main productName={name} />;
};
Expand Down
2 changes: 1 addition & 1 deletion bench/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"execa": "^8.0.1",
"fast-glob": "3.3.1",
"fdir": "^6.1.0",
"mitata": "^1.0.10",
"mitata": "^1.0.25",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"string-width": "7.1.0",
Expand Down
27 changes: 27 additions & 0 deletions bench/snippets/byteLength.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Buffer } from "node:buffer";
import { bench, run } from "../runner.mjs";

const variations = [
["latin1", "hello world"],
["utf16", "hello emoji 🤔"],
];

for (const [label, string] of variations) {
const big = Buffer.alloc(1000000, string).toString();
const small = Buffer.from(string).toString();
const substring = big.slice(0, big.length - 2);

bench(`${substring.length}`, () => {
return Buffer.byteLength(substring, "utf8");
});

bench(`${small.length}`, () => {
return Buffer.byteLength(small);
});

bench(`${big.length}`, () => {
return Buffer.byteLength(big);
});
}

await run();
8 changes: 1 addition & 7 deletions bench/snippets/native-overhead.mjs
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
import { noOpForTesting as noop } from "bun:internal-for-testing";
import { bench, run } from "../runner.mjs";

// These are no-op C++ functions that are exported to JS.
const lazy = globalThis[Symbol.for("Bun.lazy")];
const noop = lazy("noop");
const fn = noop.function;
const regular = noop.functionRegular;
const callback = noop.callback;

bench("C++ callback into JS", () => {
callback(() => {});
});

bench("C++ fn regular", () => {
regular();
});

bench("C++ fn", () => {
fn();
});
Expand Down
37 changes: 37 additions & 0 deletions bench/snippets/node-zlib-brotli.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { bench, run } from "../runner.mjs";
import { brotliCompress, brotliDecompress, createBrotliCompress, createBrotliDecompress } from "node:zlib";
import { promisify } from "node:util";
import { pipeline } from "node:stream/promises";
import { Readable } from "node:stream";
import { readFileSync } from "node:fs";

const brotliCompressAsync = promisify(brotliCompress);
const brotliDecompressAsync = promisify(brotliDecompress);

const testData =
process.argv.length > 2
? readFileSync(process.argv[2])
: Buffer.alloc(1024 * 1024 * 16, "abcdefghijklmnopqrstuvwxyz");
let compressed;

bench("brotli compress", async () => {
compressed = await brotliCompressAsync(testData);
});

bench("brotli decompress", async () => {
await brotliDecompressAsync(compressed);
});

bench("brotli compress stream", async () => {
const source = Readable.from([testData]);
const compress = createBrotliCompress();
await pipeline(source, compress);
});

bench("brotli decompress stream", async () => {
const source = Readable.from([compressed]);
const decompress = createBrotliDecompress();
await pipeline(source, decompress);
});

await run();
1 change: 0 additions & 1 deletion bench/snippets/urlsearchparams.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ bench("new URLSearchParams(obj)", () => {
"Content-Length": "123",
"User-Agent": "node-fetch/1.0",
"Accept-Encoding": "gzip,deflate",
"Content-Length": "0",
"Content-Range": "bytes 0-9/10",
});
});
Expand Down
62 changes: 62 additions & 0 deletions bench/snippets/zlib.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { bench, run } from "../runner.mjs";
import zlib from "node:zlib";
import { promisify } from "node:util";

const deflate = promisify(zlib.deflate);
const inflate = promisify(zlib.inflate);

const short = "Hello World!";
const long = "Hello World!".repeat(1024);
const veryLong = "Hello World!".repeat(10240);

// Pre-compress some data for decompression tests
const shortBuf = Buffer.from(short);
const longBuf = Buffer.from(long);
const veryLongBuf = Buffer.from(veryLong);

let [shortCompressed, longCompressed, veryLongCompressed] = await Promise.all([
deflate(shortBuf, { level: 6 }),
deflate(longBuf, { level: 6 }),
deflate(veryLongBuf, { level: 6 }),
]);

const format = new Intl.NumberFormat("en-US", { notation: "compact", unit: "byte" });
// Compression tests at different levels
bench(`deflate ${format.format(short.length)}B (level 1)`, async () => {
await deflate(shortBuf, { level: 1 });
});

bench(`deflate ${format.format(short.length)} (level 6)`, async () => {
await deflate(shortBuf, { level: 6 });
});

bench(`deflate ${format.format(long.length)} (level 1)`, async () => {
await deflate(longBuf, { level: 1 });
});

bench(`deflate ${format.format(long.length)} (level 6)`, async () => {
await deflate(longBuf, { level: 6 });
});

bench(`deflate ${format.format(veryLong.length)} (level 1)`, async () => {
await deflate(veryLongBuf, { level: 1 });
});

bench(`deflate ${format.format(veryLong.length)} (level 6)`, async () => {
await deflate(veryLongBuf, { level: 6 });
});

// Decompression tests
bench(`inflate ${format.format(short.length)}`, async () => {
await inflate(shortCompressed);
});

bench(`inflate ${format.format(long.length)}`, async () => {
await inflate(longCompressed);
});

bench(`inflate ${format.format(veryLong.length)}`, async () => {
await inflate(veryLongCompressed);
});

await run();
19 changes: 14 additions & 5 deletions cmake/targets/BuildBun.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,8 @@ file(GLOB BUN_C_SOURCES ${CONFIGURE_DEPENDS}
)

if(WIN32)
list(APPEND BUN_C_SOURCES ${CWD}/src/bun.js/bindings/windows/musl-memmem.c)
list(APPEND BUN_CXX_SOURCES ${CWD}/src/bun.js/bindings/windows/rescle.cpp)
list(APPEND BUN_CXX_SOURCES ${CWD}/src/bun.js/bindings/windows/rescle-binding.cpp)
endif()

register_repository(
Expand Down Expand Up @@ -650,19 +651,27 @@ if(WIN32)
set(Bun_VERSION_WITH_TAG ${VERSION})
endif()
set(BUN_ICO_PATH ${CWD}/src/bun.ico)
configure_file(${CWD}/src/bun.ico ${CODEGEN_PATH}/bun.ico COPYONLY)
configure_file(
${CWD}/src/windows-app-info.rc
${CODEGEN_PATH}/windows-app-info.rc
@ONLY
)
list(APPEND BUN_CPP_SOURCES ${CODEGEN_PATH}/windows-app-info.rc)
add_custom_command(
OUTPUT ${CODEGEN_PATH}/windows-app-info.res
COMMAND rc.exe /fo ${CODEGEN_PATH}/windows-app-info.res ${CODEGEN_PATH}/windows-app-info.rc
DEPENDS ${CODEGEN_PATH}/windows-app-info.rc ${CODEGEN_PATH}/bun.ico
COMMENT "Adding Windows resource file ${CODEGEN_PATH}/windows-app-info.res with ico in ${CODEGEN_PATH}/bun.ico"
)
set(WINDOWS_RESOURCES ${CODEGEN_PATH}/windows-app-info.res)
endif()

# --- Executable ---

set(BUN_CPP_OUTPUT ${BUILD_PATH}/${CMAKE_STATIC_LIBRARY_PREFIX}${bun}${CMAKE_STATIC_LIBRARY_SUFFIX})

if(BUN_LINK_ONLY)
add_executable(${bun} ${BUN_CPP_OUTPUT} ${BUN_ZIG_OUTPUT})
add_executable(${bun} ${BUN_CPP_OUTPUT} ${BUN_ZIG_OUTPUT} ${WINDOWS_RESOURCES})
set_target_properties(${bun} PROPERTIES LINKER_LANGUAGE CXX)
target_link_libraries(${bun} PRIVATE ${BUN_CPP_OUTPUT})
elseif(BUN_CPP_ONLY)
Expand All @@ -680,7 +689,7 @@ elseif(BUN_CPP_ONLY)
${BUN_CPP_OUTPUT}
)
else()
add_executable(${bun} ${BUN_CPP_SOURCES})
add_executable(${bun} ${BUN_CPP_SOURCES} ${WINDOWS_RESOURCES})
target_link_libraries(${bun} PRIVATE ${BUN_ZIG_OUTPUT})
endif()

Expand Down Expand Up @@ -850,7 +859,7 @@ endif()

if(WIN32)
target_link_options(${bun} PUBLIC
/STACK:0x1200000,0x100000
/STACK:0x1200000,0x200000
/errorlimit:0
)
if(RELEASE)
Expand Down
2 changes: 1 addition & 1 deletion cmake/targets/BuildLibDeflate.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ register_repository(
REPOSITORY
ebiggers/libdeflate
COMMIT
9d624d1d8ba82c690d6d6be1d0a961fc5a983ea4
733848901289eca058804ca0737f8796875204c8
)

register_cmake_command(
Expand Down
Loading

0 comments on commit 344c9ea

Please sign in to comment.