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

wip use wrapper for managing process #8456

Merged
merged 462 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
462 commits
Select commit Hold shift + click to select a range
e28d379
WIP sync close (shows ref count bug in stream)
cirospaciari Feb 20, 2024
0aeb500
fix closing on PipeWriter and PipeReader
cirospaciari Feb 20, 2024
5d26789
remove old todos
cirospaciari Feb 20, 2024
65b1477
join
cirospaciari Feb 20, 2024
7cd9af1
Some shell changes
zackradisic Feb 21, 2024
dc09803
Merge branch 'jarred/process-change' of github.com:oven-sh/bun into j…
zackradisic Feb 21, 2024
e44fc06
fix some compile errors
cirospaciari Feb 21, 2024
11c6288
fix ref/unref server on windows
cirospaciari Feb 21, 2024
a626bf6
Merge branch 'jarred/process-change' of github.com:oven-sh/bun into j…
cirospaciari Feb 21, 2024
30951d7
actually use the ref count in this places
cirospaciari Feb 21, 2024
a329375
make windows compile again
cirospaciari Feb 21, 2024
411c787
more tests passing
cirospaciari Feb 21, 2024
3ee74c4
Make shell compile again
zackradisic Feb 21, 2024
893d2f0
Merge branch 'jarred/process-change' of github.com:oven-sh/bun into j…
Feb 21, 2024
2092e99
Slowly remove some `@panic("TODO SHELL")`
zackradisic Feb 21, 2024
c6df32d
Merge branch 'jarred/process-change' of github.com:oven-sh/bun into j…
Feb 21, 2024
436621e
Eliminate `@panic("TODO SHELL")` for BufferedWriter
zackradisic Feb 22, 2024
b166e8a
Holy cleansing of `@panic("TODO SHELL")`
zackradisic Feb 22, 2024
afbc997
Okay now the shell compiles, but segfaults
zackradisic Feb 22, 2024
2d71bce
Merge branch 'main' into jarred/process-change
Jarred-Sumner Feb 22, 2024
dfab13e
Fix compiler errors
Jarred-Sumner Feb 22, 2024
0a42ac0
more stable stream and now Content-Range pass
cirospaciari Feb 22, 2024
fe01d9b
make windows compile again
cirospaciari Feb 22, 2024
a70d0df
revert stuff until the fix is actually ready
cirospaciari Feb 22, 2024
8694668
revert onDone thing
zackradisic Feb 22, 2024
e2ef561
Merge branch 'jarred/process-change' of github.com:oven-sh/bun into j…
zackradisic Feb 22, 2024
f56c625
Fix buffered writer for shell
zackradisic Feb 22, 2024
d8646a0
Fix buffered writer + shell/subproc.zig and windows build
zackradisic Feb 23, 2024
a687eb1
Fix for #8982 got lost in the merge
zackradisic Feb 23, 2024
d0ee302
Actually buffer subproc output
zackradisic Feb 23, 2024
c367ce1
Fix some stuff shell
zackradisic Feb 23, 2024
6d22838
oops
cirospaciari Feb 23, 2024
85b6320
fix context deinit
cirospaciari Feb 23, 2024
dcbb8d9
fix renderMissing
cirospaciari Feb 23, 2024
2a8bfbe
shell: Fix array buffer
zackradisic Feb 23, 2024
bcf7b16
more stable streams (#9053)
cirospaciari Feb 23, 2024
4c3598f
wip
cirospaciari Feb 23, 2024
008a3c6
Remove `@panic("TODO")` on shell event loop tasks and Redirect open …
zackradisic Feb 23, 2024
23e9eef
Support redirects
zackradisic Feb 24, 2024
468b21f
Merge branch 'jarred/process-change' of github.com:oven-sh/bun into j…
zackradisic Feb 24, 2024
c954be2
Merge branch 'main' into jarred/process-change
Jarred-Sumner Feb 26, 2024
17a46e5
fixes
Jarred-Sumner Feb 26, 2024
2f1550d
Update ReadableStreamInternals.ts
Jarred-Sumner Feb 26, 2024
67e89fe
Fix spurious error
Jarred-Sumner Feb 26, 2024
ebce8e8
Update stream.js
Jarred-Sumner Feb 26, 2024
1900656
leak
Jarred-Sumner Feb 26, 2024
56d936b
Merge branch 'main' into jarred/process-change
Jarred-Sumner Feb 27, 2024
49e1c5c
Fix UAF
Jarred-Sumner Feb 27, 2024
abf3dcc
Fix memory leaks
Jarred-Sumner Feb 27, 2024
ee6f2c8
HOLY FUCK big refactor
zackradisic Feb 27, 2024
379abb4
Merge branch 'jarred/process-change' of github.com:oven-sh/bun into j…
zackradisic Feb 27, 2024
021b185
misc cleanup
Jarred-Sumner Feb 27, 2024
f3c494f
Merge branch 'main' into jarred/process-change
Jarred-Sumner Feb 28, 2024
f653963
shell: Fix a bunch of tests
zackradisic Feb 28, 2024
6fd8d13
Merge branch 'jarred/process-change' of github.com:oven-sh/bun into j…
zackradisic Feb 28, 2024
dc78bb6
clean up
Jarred-Sumner Feb 28, 2024
7200d34
Merge branch 'main' into jarred/process-change
Jarred-Sumner Feb 28, 2024
d1035a0
gitignore: fix ending newline
nektro Feb 28, 2024
bce7f82
get windows compiling again
nektro Feb 28, 2024
955d139
tidy
nektro Feb 28, 2024
ee650fa
hide linker warn with icu
nektro Feb 28, 2024
3812335
closeIfPossible
Jarred-Sumner Feb 28, 2024
baa6f54
Merge branch 'jarred/process-change' of github.com:oven-sh/bun into j…
zackradisic Feb 28, 2024
ec07710
Better leak test
Jarred-Sumner Feb 28, 2024
11c7265
Fix forgetting to decrement reference count
zackradisic Feb 28, 2024
0b27f74
Merge branch 'jarred/process-change' of github.com:oven-sh/bun into j…
zackradisic Feb 28, 2024
a0030cf
Update stdio.zig
Jarred-Sumner Feb 28, 2024
bf3dbda
Fix shell windows build
zackradisic Feb 28, 2024
639e972
Merge branch 'main' into jarred/process-change
Jarred-Sumner Feb 28, 2024
52b8f84
Merge branch 'main' into jarred/process-change
Jarred-Sumner Feb 28, 2024
2223b4a
Stupid unreachable
zackradisic Feb 28, 2024
703d6fc
Merge branch 'main' into jarred/process-change
Jarred-Sumner Feb 28, 2024
4fe0bfd
Woops
Jarred-Sumner Feb 28, 2024
435b68e
basic echo hi works on windows
zackradisic Feb 29, 2024
6901640
Fix flaky test on Windows
Jarred-Sumner Feb 29, 2024
607facb
Fix windows regression in Bun.main (#9156)
Jarred-Sumner Feb 29, 2024
16814cd
Make this test less flaky on Windows
Jarred-Sumner Feb 29, 2024
8b51b08
Merge branch 'main' into jarred/process-change
Jarred-Sumner Feb 29, 2024
dd884ce
Fixup
Jarred-Sumner Feb 29, 2024
1609bb9
Cygwin
Jarred-Sumner Feb 29, 2024
ce63926
Support signal codes in subprocess.kill(), resolve file path
Jarred-Sumner Feb 29, 2024
69d9759
Treat null as ignore
Jarred-Sumner Feb 29, 2024
bd6ea2c
Ignore carriage returns
Jarred-Sumner Feb 29, 2024
9f3623f
Fixup
Jarred-Sumner Feb 29, 2024
3382305
shell: Fix IOWriter bug
zackradisic Feb 29, 2024
604272b
shell: Use custom `open()`/`openat()`
zackradisic Feb 29, 2024
1fb2329
windows shell subproc works
zackradisic Feb 29, 2024
3a63e77
zack commit
zackradisic Feb 29, 2024
f50996e
I think I understand WindowsStreamingWriter
zackradisic Mar 1, 2024
dd67995
fix thing
zackradisic Mar 1, 2024
27aa8d6
Merge branch 'main' into jarred/process-change
Jarred-Sumner Mar 1, 2024
cd438a2
why were we doing this in tests
Jarred-Sumner Mar 1, 2024
feb61af
shell: Fix rm
zackradisic Mar 1, 2024
af41de4
shell: Add rm -rf node_modules/ test
zackradisic Mar 1, 2024
acb25ab
shell: use `.runAsTest()` in some places to make it easier to determi…
zackradisic Mar 1, 2024
0265b92
Merge branch 'jarred/process-change' of https://github.com/oven-sh/bu…
zackradisic Mar 1, 2024
071c3ca
[autofix.ci] apply automated fixes
autofix-ci[bot] Mar 1, 2024
13ab463
woopsie
zackradisic Mar 1, 2024
713f36f
Various changes
Jarred-Sumner Feb 29, 2024
b67db00
Fix
Jarred-Sumner Mar 1, 2024
7b595f9
shell: abstract output task logic
zackradisic Mar 1, 2024
8656c80
shell: mkdir builtin
zackradisic Mar 1, 2024
10ec437
fixup
Jarred-Sumner Mar 1, 2024
694fcf5
Merge remote-tracking branch 'origin/main' into jarred/process-change
Jarred-Sumner Mar 1, 2024
7fcb133
stuff
zackradisic Mar 1, 2024
d19f44e
shell: Make writing length of 0 in IOWriter immediately resolve
zackradisic Mar 2, 2024
9de29bd
shell: Implement `touch`
zackradisic Mar 2, 2024
8cac8ba
shell: basic `cat` working
zackradisic Mar 4, 2024
31ae6fb
Make it compile on windows
zackradisic Mar 4, 2024
34c0cfb
shell: Fix IOReader bug
zackradisic Mar 4, 2024
24c44c6
Merge branch 'main' into jarred/process-change
Jarred-Sumner Mar 4, 2024
3edb632
[autofix.ci] apply automated fixes
autofix-ci[bot] Mar 4, 2024
c57afe9
fix windows kill on subprocess/process
cirospaciari Mar 4, 2024
d6ad653
fix dns tests to match behavior on windows (same as nodejs)
cirospaciari Mar 4, 2024
3234d52
Merge branch 'main' into jarred/process-change
Jarred-Sumner Mar 5, 2024
8fc9f32
fix windows ci
Jarred-Sumner Mar 5, 2024
f47a59b
again
Jarred-Sumner Mar 5, 2024
f79f0d0
move `close_handle` to flags in `PipeWriter` and fix shell hanging
zackradisic Mar 5, 2024
719c2f1
Fix `ls` not giving non-zero exit code on error
zackradisic Mar 5, 2024
d69398d
Handle edgecase in is_atty
Jarred-Sumner Mar 5, 2024
32310ed
Fix writer.flush() when there's no data
Jarred-Sumner Mar 5, 2024
ef9c800
Fix some tests
Jarred-Sumner Mar 5, 2024
9a17dcb
Disable uv_unref on uv_process_t on Windows, for now.
Jarred-Sumner Mar 5, 2024
e532014
fix writer.end
cirospaciari Mar 5, 2024
d1f799c
fix stdout.write
cirospaciari Mar 5, 2024
247d82d
fix child-process on win32
cirospaciari Mar 5, 2024
a96a744
Make this test less flaky on Windows
Jarred-Sumner Mar 5, 2024
c37afe0
Add assertion
Jarred-Sumner Mar 5, 2024
1c9d2be
Merge branch 'main' into jarred/process-change
Jarred-Sumner Mar 5, 2024
133c809
Make these the same
Jarred-Sumner Mar 5, 2024
a934592
Make it pass on windows
Jarred-Sumner Mar 5, 2024
c5f6f26
Don't commit
Jarred-Sumner Mar 5, 2024
fed091f
Log the test name
Jarred-Sumner Mar 6, 2024
4ce5506
Make this test less flaky on windows
Jarred-Sumner Mar 6, 2024
76ed325
Make this test less flaky on windows
Jarred-Sumner Mar 6, 2024
f64b1cf
Print which test is taking awhile in the runner
Jarred-Sumner Mar 6, 2024
b8a2ef8
Merge branch 'main' into jarred/process-change
Jarred-Sumner Mar 6, 2024
b9ceca7
fixups
Jarred-Sumner Mar 6, 2024
09e7aaa
Fixups
Jarred-Sumner Mar 6, 2024
0eadf40
Add some assertions
Jarred-Sumner Mar 6, 2024
746b3f7
Bring back test concurrency
Jarred-Sumner Mar 6, 2024
7c7d5f0
shell: bring back redirect stdin
zackradisic Mar 6, 2024
f280a69
make it compile again cc @zackradisic
cirospaciari Mar 6, 2024
335c957
initialize env map with capacity
zackradisic Mar 6, 2024
b113490
some fixes
cirospaciari Mar 6, 2024
dd50fe5
cleanup
cirospaciari Mar 6, 2024
ce82aec
oops
cirospaciari Mar 6, 2024
28e2fd7
fix leak, fix done
cirospaciari Mar 6, 2024
eac1765
fix unconsumedPromises on events
cirospaciari Mar 7, 2024
0f223cb
always run expect
cirospaciari Mar 7, 2024
2c0e8c9
Merge branch 'main' into jarred/process-change
Jarred-Sumner Mar 7, 2024
f601c39
Update child_process.test.ts
Jarred-Sumner Mar 6, 2024
0584306
fix reading special files
paperdave Mar 7, 2024
20bb1c2
Fix a test
Jarred-Sumner Mar 7, 2024
2f76619
Deflake this test
Jarred-Sumner Mar 7, 2024
2236f15
Make these comparisons easier
Jarred-Sumner Mar 7, 2024
e067d99
Won't really fix it but slightly cleaner
Jarred-Sumner Mar 7, 2024
7cd3507
Update serve.test.ts
Jarred-Sumner Mar 7, 2024
bdc94aa
Make the checks for if the body is already used more resilient
Jarred-Sumner Mar 7, 2024
3e5f6b1
Move this to the harness
Jarred-Sumner Mar 7, 2024
12ed874
Make this test not hang in development
Jarred-Sumner Mar 7, 2024
b2cc1a9
Fix this test
Jarred-Sumner Mar 7, 2024
7ca1139
Make the logs better
Jarred-Sumner Mar 7, 2024
0f48e4a
zero init some things
Jarred-Sumner Mar 7, 2024
5027877
Make this test better
Jarred-Sumner Mar 7, 2024
4235e2f
Fix readSocket
Jarred-Sumner Mar 7, 2024
d2968ee
Parallelize this test
Jarred-Sumner Mar 7, 2024
a74c44b
Handle EPipe and avoid big data
Jarred-Sumner Mar 7, 2024
7a26d18
This was a mistake
Jarred-Sumner Mar 7, 2024
abdedcb
Fix a bunch of things
Jarred-Sumner Mar 7, 2024
c83002c
Fix memory leak
Jarred-Sumner Mar 7, 2024
9fe8844
Avoid sigpipe + optimize + delete dead code
Jarred-Sumner Mar 7, 2024
1ef9879
Make this take less time
Jarred-Sumner Mar 7, 2024
73890cb
Make it bigger
Jarred-Sumner Mar 7, 2024
16a9ea8
Remove some redundant code
Jarred-Sumner Mar 7, 2024
e0af083
Update process.zig
Jarred-Sumner Mar 7, 2024
ad13b04
Merge and hopefully don't breka things along teh way
Jarred-Sumner Mar 7, 2024
69c2a9b
Silence build warning
Jarred-Sumner Mar 7, 2024
e29a54b
Uncomment on posix
Jarred-Sumner Mar 7, 2024
53792f3
Skip test on windows
Jarred-Sumner Mar 7, 2024
28259ca
windows
Jarred-Sumner Mar 7, 2024
3106aef
Cleanup test
Jarred-Sumner Mar 7, 2024
7367d76
Update
Jarred-Sumner Mar 7, 2024
76e6141
Deflake
Jarred-Sumner Mar 7, 2024
f8aceb1
always
Jarred-Sumner Mar 7, 2024
3300e9d
less flaky test
cirospaciari Mar 7, 2024
ee4602b
Merge branch 'main' into jarred/process-change
Jarred-Sumner Mar 7, 2024
e1bbb1e
[autofix.ci] apply automated fixes
autofix-ci[bot] Mar 7, 2024
819b9b4
logs
zackradisic Mar 6, 2024
fe8b034
fix uaf on shell IOReader
zackradisic Mar 6, 2024
005be7c
stuff to make it work with mini event loop
zackradisic Mar 7, 2024
f64470e
fix 2 double free scenarios, support redirections on windows
zackradisic Mar 7, 2024
32f4a1e
shell: Make `1>&2` and `2>&1` work with libuv
zackradisic Mar 7, 2024
1934f1f
yoops
zackradisic Mar 7, 2024
5398208
Merge remote-tracking branch 'origin/main' into jarred/process-change
paperdave Mar 7, 2024
f253d89
Partial fix
Jarred-Sumner Mar 7, 2024
f03e374
Partial fix
Jarred-Sumner Mar 7, 2024
f11ff13
fix build
paperdave Mar 7, 2024
071771e
fix build
paperdave Mar 7, 2024
cecea3d
ok
paperdave Mar 8, 2024
e69e7e9
Make a couple shell tests pass
Jarred-Sumner Mar 8, 2024
5913d71
More logging
Jarred-Sumner Mar 8, 2024
d14c2f8
Merge branch 'main' into jarred/process-change
dylan-conway Mar 8, 2024
a559f02
fix
Jarred-Sumner Mar 8, 2024
acd9c7f
fix
Jarred-Sumner Mar 8, 2024
d897bb4
Fix build issue
Jarred-Sumner Mar 8, 2024
234155a
more tests pass
Jarred-Sumner Mar 8, 2024
f72bfa8
Deflake
Jarred-Sumner Mar 8, 2024
0b27a64
Deflake
Jarred-Sumner Mar 8, 2024
eb5c1e1
Use Output.panic instead of garbled text
Jarred-Sumner Mar 8, 2024
8d07bd9
Formatting
Jarred-Sumner Mar 8, 2024
b4318ed
Introduce `bun.sys.File`, use it for `Output.Source.StreamType`, fix …
Jarred-Sumner Mar 8, 2024
6d7a63c
Fix closing undefined memory file descriptors in spawn
Jarred-Sumner Mar 8, 2024
7d9ba47
pause instead of close
Jarred-Sumner Mar 8, 2024
f3e4912
Fix poorly-written test
Jarred-Sumner Mar 8, 2024
e3d0f0c
We don't need big numbers for this test
Jarred-Sumner Mar 8, 2024
2f2fcd0
sad workaround
Jarred-Sumner Mar 8, 2024
05d3d3e
fixup
Jarred-Sumner Mar 8, 2024
cd72100
Clearer error handling for this test
Jarred-Sumner Mar 8, 2024
c555ea0
Fix incorrect test
Jarred-Sumner Mar 8, 2024
530cb8d
Fix build
Jarred-Sumner Mar 8, 2024
fa12b00
Remove known failing on windows
Jarred-Sumner Mar 8, 2024
49bcae6
Deflake
Jarred-Sumner Mar 8, 2024
94341f7
Mark no longer failing
Jarred-Sumner Mar 8, 2024
f0ba2bb
show all the failing tests
Jarred-Sumner Mar 8, 2024
a82d610
Sort the list of tests
Jarred-Sumner Mar 8, 2024
5b3c504
fix argument handling
paperdave Mar 8, 2024
466428d
dont show "posix_spawn" as an error code on windows
paperdave Mar 8, 2024
935b3c0
make bun-upgrade.test.ts pass on windows
paperdave Mar 8, 2024
5b37133
fix bunx and bun create again sorry
paperdave Mar 8, 2024
c75304e
a
paperdave Mar 9, 2024
da47cf8
fix invalidexe because we should not be running javascript files as i…
paperdave Mar 9, 2024
4213f65
Concurrency in test runner + better logging
Jarred-Sumner Mar 9, 2024
cb4e009
Revert "fix invalidexe because we should not be running javascript fi…
Jarred-Sumner Mar 9, 2024
f2a69ef
WIP: Unix fixes (#9322)
cirospaciari Mar 9, 2024
7da411a
Merge branch 'main' into jarred/process-change
Jarred-Sumner Mar 9, 2024
6c7bd40
Merge branch 'main' into jarred/process-change
Jarred-Sumner Mar 9, 2024
74ce523
Update runner.node.mjs
Jarred-Sumner Mar 9, 2024
7a63a15
Update runner.node.mjs
Jarred-Sumner Mar 9, 2024
0555cce
Document some environment variables
Jarred-Sumner Mar 9, 2024
978752a
Merge branch 'main' into jarred/process-change
Jarred-Sumner Mar 9, 2024
dddfc5f
shell: Make `Response` work with builtins
zackradisic Mar 9, 2024
c1804b1
Make it compile
zackradisic Mar 9, 2024
9f38973
make pwd test pass
zackradisic Mar 10, 2024
fcbf196
[autofix.ci] apply automated fixes
autofix-ci[bot] Mar 10, 2024
8e91bbe
Fix printing garbage for source code previews
Jarred-Sumner Mar 10, 2024
30f4b9d
Update javascript.zig
Jarred-Sumner Mar 10, 2024
2c71bb2
Fix posix test failures
Jarred-Sumner Mar 11, 2024
17311f2
Fix signal dispatch
Jarred-Sumner Mar 11, 2024
efb9a86
windows
Jarred-Sumner Mar 11, 2024
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
3 changes: 0 additions & 3 deletions .github/workflows/bun-linux-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,6 @@ jobs:
TLS_POSTGRES_DATABASE_URL: ${{ secrets.TLS_POSTGRES_DATABASE_URL }}
# if: ${{github.event.inputs.use_bun == 'false'}}
run: |
ulimit -c unlimited
ulimit -c

node packages/bun-internal-test/src/runner.node.mjs || true
# - uses: actions/upload-artifact@v4
# if: steps.test.outputs.failing_tests != ''
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/bun-mac-aarch64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ jobs:

cmake -S $SOURCE_DIR -B $OBJ_DIR \
-G Ninja \
-DUSE_LTO=ON \
-DCMAKE_BUILD_TYPE=Release \
-DBUN_CPP_ONLY=1 \
-DNO_CONFIGURE_DEPENDS=1
Expand Down Expand Up @@ -308,6 +309,7 @@ jobs:
cmake $SRC_DIR \
-G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DUSE_LTO=ON \
-DBUN_LINK_ONLY=1 \
-DBUN_ZIG_OBJ="${{ runner.temp }}/release/bun-zig.o" \
-DBUN_CPP_ARCHIVE="${{ runner.temp }}/bun-cpp-obj/bun-cpp-objects.a" \
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/bun-mac-x64-baseline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ jobs:

cmake -S $SOURCE_DIR -B $OBJ_DIR \
-G Ninja \
-DUSE_LTO=ON \
-DCMAKE_BUILD_TYPE=Release \
-DBUN_CPP_ONLY=1 \
-DNO_CONFIGURE_DEPENDS=1
Expand Down Expand Up @@ -293,6 +294,7 @@ jobs:
cd ${{runner.temp}}/link-build
cmake $SRC_DIR \
-G Ninja \
-DUSE_LTO=ON \
-DCMAKE_BUILD_TYPE=Release \
-DBUN_LINK_ONLY=1 \
-DBUN_ZIG_OBJ="${{ runner.temp }}/release/bun-zig.o" \
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/bun-mac-x64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ jobs:
cmake -S $SOURCE_DIR -B $OBJ_DIR \
-G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DUSE_LTO=ON \
-DBUN_CPP_ONLY=1 \
-DNO_CONFIGURE_DEPENDS=1

Expand Down Expand Up @@ -292,6 +293,7 @@ jobs:
cmake $SRC_DIR \
-G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DUSE_LTO=ON \
-DBUN_LINK_ONLY=1 \
-DBUN_ZIG_OBJ="${{ runner.temp }}/release/bun-zig.o" \
-DBUN_CPP_ARCHIVE="${{ runner.temp }}/bun-cpp-obj/bun-cpp-objects.a" \
Expand Down
13 changes: 8 additions & 5 deletions .github/workflows/bun-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,9 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: 20
- uses: secondlife/setup-cygwin@v1
with:
packages: bash
- name: Install dependencies
run: |
# bun install --verbose
Expand All @@ -434,12 +437,12 @@ jobs:
TMPDIR: ${{runner.temp}}
TLS_MONGODB_DATABASE_URL: ${{ secrets.TLS_MONGODB_DATABASE_URL }}
TLS_POSTGRES_DATABASE_URL: ${{ secrets.TLS_POSTGRES_DATABASE_URL }}
SHELLOPTS: igncr
BUN_PATH_BASE: ${{runner.temp}}
BUN_PATH: release/${{env.tag}}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}-profile/bun.exe
run: |
try {
$ErrorActionPreference = "SilentlyContinue"
$null = node packages/bun-internal-test/src/runner.node.mjs ${{runner.temp}}/release/${{env.tag}}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}-profile/bun.exe || $true
} catch {}
$ErrorActionPreference = "Stop"
node packages/bun-internal-test/src/runner.node.mjs || true
shell: bash
- uses: sarisia/actions-status-discord@v1
if: always() && steps.test.outputs.failing_tests != '' && github.event_name == 'pull_request'
with:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,10 @@ x64
/.cache
/src/deps/libuv
/build-*/
/kcov-out

.vs

**/.verdaccio-db.json
/test-report.md
/test-report.json
/test-report.json
38 changes: 37 additions & 1 deletion .vscode/launch.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 41 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
# it is enabled for the time being to make sure to catch more bugs in the experimental windows builds
set(DEFAULT_ZIG_OPTIMIZE "ReleaseSafe")
else()
set(bun "bun-profile")
if(ZIG_OPTIMIZE STREQUAL "Debug")
set(bun "bun-debug")
else()
set(bun "bun-profile")
endif()
endif()
endif()

Expand Down Expand Up @@ -227,6 +231,13 @@ set(DEFAULT_USE_DEBUG_JSC, OFF)

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(DEFAULT_USE_DEBUG_JSC ON)
set(DEFAULT_LTO OFF)
elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
if(CI)
set(DEFAULT_LTO ON)
else()
set(DEFAULT_LTO OFF)
endif()
endif()

if(WIN32)
Expand Down Expand Up @@ -263,6 +274,8 @@ option(USE_DEBUG_JSC "Enable assertions and use a debug build of JavaScriptCore"
option(USE_UNIFIED_SOURCES "Use unified sources to speed up the build" OFF)
option(USE_STATIC_LIBATOMIC "Statically link libatomic, requires the presence of libatomic.a" ${DEFAULT_USE_STATIC_LIBATOMIC})

option(USE_LTO "Enable Link-Time Optimization" ${DEFAULT_LTO})

if(USE_VALGRIND)
# Disable SIMD
set(USE_BASELINE_BUILD ON)
Expand Down Expand Up @@ -430,7 +443,13 @@ if(NOT WEBKIT_DIR)
set(BUN_WEBKIT_PACKAGE_NAME_SUFFIX "-debug")
set(ASSERT_ENABLED "1")
elseif(NOT DEBUG AND NOT WIN32)
set(BUN_WEBKIT_PACKAGE_NAME_SUFFIX "-lto")
# Avoid waiting for LTO in local release builds outside of CI
if(USE_LTO)
set(BUN_WEBKIT_PACKAGE_NAME_SUFFIX "-lto")
else()
set(BUN_WEBKIT_PACKAGE_NAME_SUFFIX "")
endif()

set(ASSERT_ENABLED "0")
endif()

Expand Down Expand Up @@ -958,15 +977,28 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug")

add_compile_definitions("BUN_DEBUG=1")
elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
set(LTO_FLAG "")

if(NOT WIN32)
target_compile_options(${bun} PUBLIC -O3 -flto=full -emit-llvm -g1
if(USE_LTO)
list(APPEND LTO_FLAG "-flto=full" "-emit-llvm")
endif()

target_compile_options(${bun} PUBLIC -O3 ${LTO_FLAG} -g1
-Werror=return-type
-Werror=return-stack-address
-Werror=implicit-function-declaration
)
else()
target_compile_options(${bun} PUBLIC /O2 -flto=full /DEBUG /Z7)
target_link_options(${bun} PUBLIC /LTCG /DEBUG)
set(LTO_LINK_FLAG "")

if(USE_LTO)
list(APPEND LTO_FLAG "-flto=full" "-emit-llvm")
list(APPEND LTO_LINK_FLAG "/LTCG")
endif()

target_compile_options(${bun} PUBLIC /O2 ${LTO_FLAG} /DEBUG /Z7)
target_link_options(${bun} PUBLIC ${LTO_LINK_FLAG} /DEBUG)
endif()
endif()

Expand Down Expand Up @@ -1018,11 +1050,15 @@ else()
endif()

if(APPLE)
# this is gated to avoid the following warning when developing on modern versions of macOS.
# ld: warning: object file (/opt/homebrew/opt/icu4c/lib/libicudata.a[2](icudt73l_dat.o)) was built for newer 'macOS' version (14.0) than being linked (11.0)
if(DEFINED ENV{CI})
if(ARCH STREQUAL "x86_64")
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14")
else()
set(CMAKE_OSX_DEPLOYMENT_TARGET "11.0")
endif()
endif()

target_link_options(${bun} PUBLIC "-dead_strip")
target_link_options(${bun} PUBLIC "-dead_strip_dylibs")
Expand Down
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ ENV CCACHE_DIR=/ccache
RUN --mount=type=cache,target=/ccache mkdir ${BUN_DIR}/build \
&& cd ${BUN_DIR}/build \
&& mkdir -p tmp_modules tmp_functions js codegen \
&& cmake .. -GNinja -DCMAKE_BUILD_TYPE=Release -DUSE_DEBUG_JSC=${ASSERTIONS} -DBUN_CPP_ONLY=1 -DWEBKIT_DIR=/build/bun/bun-webkit -DCANARY=${CANARY} -DZIG_COMPILER=system \
&& cmake .. -GNinja -DCMAKE_BUILD_TYPE=Release -DUSE_LTO=ON -DUSE_DEBUG_JSC=${ASSERTIONS} -DBUN_CPP_ONLY=1 -DWEBKIT_DIR=/build/bun/bun-webkit -DCANARY=${CANARY} -DZIG_COMPILER=system \
&& bash compile-cpp-only.sh -v

FROM bun-base-with-zig as bun-codegen-for-zig
Expand Down Expand Up @@ -419,6 +419,7 @@ RUN mkdir -p build \
&& cmake .. \
-G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DUSE_LTO=ON \
-DZIG_OPTIMIZE="${ZIG_OPTIMIZE}" \
-DCPU_TARGET="${CPU_TARGET}" \
-DZIG_TARGET="${TRIPLET}" \
Expand Down Expand Up @@ -476,6 +477,7 @@ RUN cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DBUN_LINK_ONLY=1 \
-DBUN_ZIG_OBJ="${BUN_DIR}/build/bun-zig.o" \
-DUSE_LTO=ON \
-DUSE_DEBUG_JSC=${ASSERTIONS} \
-DBUN_CPP_ARCHIVE="${BUN_DIR}/build/bun-cpp-objects.a" \
-DWEBKIT_DIR="${BUN_DIR}/bun-webkit" \
Expand Down Expand Up @@ -540,6 +542,7 @@ RUN cmake .. \
-DNO_CONFIGURE_DEPENDS=1 \
-DCANARY="${CANARY}" \
-DZIG_COMPILER=system \
-DUSE_LTO=ON \
&& ninja -v \
&& ./bun --revision \
&& mkdir -p /build/out \
Expand Down
16 changes: 16 additions & 0 deletions cp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const { spawn } = require("child_process");
console.clear();
console.log("--start--");
const proc = spawn("sleep", ["0.5"], { stdio: ["ignore", "ignore", "ignore"] });

console.time("Elapsed");
process.on("exit", () => {
console.timeEnd("Elapsed");
});
proc.on("exit", (code, signal) => {
console.log(`child process terminated with code ${code} and signal ${signal}`);
timer.unref();
});
proc.unref();

var timer = setTimeout(() => {}, 1000);
10 changes: 10 additions & 0 deletions docs/runtime/env.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,16 @@ These environment variables are read by Bun and configure aspects of its behavio

---

- `BUN_CONFIG_MAX_HTTP_REQUESTS`
- Control the maximum number of concurrent HTTP requests sent by fetch and `bun install`. Defaults to `256`. If you are running into rate limits or connection issues, you can reduce this number.

---

- `BUN_CONFIG_NO_CLEAR_TERMINAL_ON_RELOAD`
- If `BUN_CONFIG_NO_CLEAR_TERMINAL_ON_RELOAD=1`, then `bun --watch` will not clear the console on reload

---

- `DO_NOT_TRACK`
- Telemetry is not sent yet as of November 28th, 2023, but we are planning to add telemetry in the coming months. If `DO_NOT_TRACK=1`, then analytics are [disabled](https://do-not-track.dev/). Bun records bundle timings (so we can answer with data, "is Bun getting faster?") and feature usage (e.g., "are people actually using macros?"). The request body size is about 60 bytes, so it's not a lot of data. Equivalent of `telemetry=false` in bunfig.

Expand Down
25 changes: 13 additions & 12 deletions docs/runtime/shell.md
Original file line number Diff line number Diff line change
Expand Up @@ -400,25 +400,26 @@ await $`echo ${{ raw: '$(foo) `bar` "baz"' }}`
// => baz
```

## .bun.sh file loader
## .sh file loader

For simple shell scripts, instead of `sh`, you can use Bun Shell to run shell scripts.
For simple shell scripts, instead of `/bin/sh`, you can use Bun Shell to run shell scripts.

To do that, run any file with bun that ends with `.bun.sh`:
To do so, just run the script with `bun` on a file with the `.sh` extension.

```sh
$ echo "echo Hello World!" > script.bun.sh
$ bun ./script.bun.sh
> Hello World!
```sh#script.sh
echo "Hello World! pwd=$(pwd)"
```

On Windows, Bun Shell is used automatically to run `.sh` files when using Bun:

```sh
$ echo "echo Hello World!" > script.sh
# On windows, .bun.sh is not needed, just .sh
$ bun ./script.sh
> Hello World!
Hello World! pwd=/home/demo
```

Scripts with Bun Shell are cross platform, which means they work on Windows:

```
PS C:\Users\Demo> bun .\script.sh
Hello World! pwd=C:\Users\Demo
```

## Credits
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"build": "if [ ! -e build ]; then bun setup; fi && ninja -C build",
"build:valgrind": "cmake . -DZIG_OPTIMIZE=Debug -DUSE_DEBUG_JSC=ON -DCMAKE_BUILD_TYPE=Debug -GNinja -Bbuild-valgrind && ninja -Cbuild-valgrind",
"build:release": "cmake . -DCMAKE_BUILD_TYPE=Release -GNinja -Bbuild-release && ninja -Cbuild-release",
"build:debug-zig-release": "cmake . -DCMAKE_BUILD_TYPE=Release -DZIG_OPTIMIZE=Debug -GNinja -Bbuild-debug-zig-release && ninja -Cbuild-debug-zig-release",
"build:safe": "cmake . -DZIG_OPTIMIZE=ReleaseSafe -DUSE_DEBUG_JSC=ON -DCMAKE_BUILD_TYPE=Release -GNinja -Bbuild-safe && ninja -Cbuild-safe",
"typecheck": "tsc --noEmit && cd test && bun run typecheck",
"fmt": "prettier --write --cache './{.vscode,src,test,bench,packages/{bun-types,bun-inspector-*,bun-vscode,bun-debug-adapter-protocol}}/**/*.{mjs,ts,tsx,js,jsx}'",
Expand Down
Binary file modified packages/bun-inspector-frontend/bun.lockb
Binary file not shown.
Binary file modified packages/bun-internal-test/bun.lockb
Binary file not shown.
1 change: 1 addition & 0 deletions packages/bun-internal-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"p-queue": "^8.0.1"
},
"devDependencies": {
"@types/p-queue": "^3.2.1",
"bun-types": "canary",
"prettier": "^2.8.2"
},
Expand Down
Loading
Loading