oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.47k stars 2.78k forks source link

Building Bun Requires glibc 2.34+ #9669

Closed dl-eric closed 8 months ago

dl-eric commented 8 months ago

What is the type of issue?

Documentation is missing

What is the issue?

Running bun run build produces the following error:

[2/161] Building CXX object CMakeFiles/bun-debug.dir/src/bun.js/bindings/c-bindings.cpp.o
FAILED: CMakeFiles/bun-debug.dir/src/bun.js/bindings/c-bindings.cpp.o
/usr/bin/ccache /usr/bin/clang++-16 -DASSERT_ENABLED=1 -DBUILDING_JSCONLY__ -DBUILDING_WITH_CMAKE=1 -DBUN_DEBUG=1 -DBUN_DYNAMIC_JS_LOAD_PATH=\"/home/dl-eric/bun/build/js\" -DBUN_SINGLE_THREADED_PER_VM_ENTRY_SCOPE=1 -DIS_BUILD -DJSC_OBJC_API_ENABLED=0 -DLAZY_LOAD_SQLITE=0 -DLIBUS_USE_BORINGSSL=1 -DLIBUS_USE_OPENSSL=1 -DNAPI_EXPERIMENTAL=ON -DNOMINMAX -DSTATICALLY_LINKED_WITH_BMALLOC=1 -DSTATICALLY_LINKED_WITH_JavaScriptCore=1 -DSTATICALLY_LINKED_WITH_WTF=1 -DUWS_HTTPRESPONSE_NO_WRITEMARK=1 -DWITH_BORINGSSL=1 -D_HAS_EXCEPTIONS=0 -I/home/dl-eric/bun/src/deps/brotli/include -I/home/dl-eric/bun/build/bun-webkit/include/wtf/unicode -I/home/dl-eric/bun/packages -I/home/dl-eric/bun/packages/bun-usockets -I/home/dl-eric/bun/packages/bun-usockets/src -I/home/dl-eric/bun/src/bun.js/bindings -I/home/dl-eric/bun/src/bun.js/bindings/webcore -I/home/dl-eric/bun/src/bun.js/bindings/webcrypto -I/home/dl-eric/bun/src/bun.js/bindings/sqlite -I/home/dl-eric/bun/src/bun.js/modules -I/home/dl-eric/bun/src/js/builtins -I/home/dl-eric/bun/src/napi -I/home/dl-eric/bun/src/deps -I/home/dl-eric/bun/src/deps/picohttpparser -I/home/dl-eric/bun/build/bun-webkit/include -I/home/dl-eric/bun/build/codegen -I/home/dl-eric/bun/src/deps/zlib -I/home/dl-eric/bun/src/deps/boringssl/include -I/home/dl-eric/bun/src/deps/libarchive/include -I/home/dl-eric/bun/src/deps/mimalloc/include -I/home/dl-eric/bun/src/deps/zstd/include -I/home/dl-eric/bun/src/deps/c-ares/include -I/home/dl-eric/bun/src/deps/base64/include -I/home/dl-eric/bun/src/deps/ls-hpack -std=c++2a -g -std=gnu++20 -fvisibility=hidden -fvisibility-inlines-hidden -fcolor-diagnostics -g3 -O0 -gdwarf-4 -Werror=return-type -Werror=return-stack-address -Werror=implicit-function-declaration -Werror=uninitialized -Werror=conditional-uninitialized -Werror=suspicious-memaccess -Werror=move -Werror=sometimes-uninitialized -Werror=unused -Wno-unused-function -Werror -fdiagnostics-color=always -march=haswell -ferror-limit=100 -fPIC -mtune=haswell -fconstexpr-steps=1271242 -fconstexpr-depth=27 -fno-exceptions -fvisibility=hidden -fvisibility-inlines-hidden -fno-rtti -fno-omit-frame-pointer -MD -MT CMakeFiles/bun-debug.dir/src/bun.js/bindings/c-bindings.cpp.o -MF CMakeFiles/bun-debug.dir/src/bun.js/bindings/c-bindings.cpp.o.d -o CMakeFiles/bun-debug.dir/src/bun.js/bindings/c-bindings.cpp.o -c /home/dl-eric/bun/src/bun.js/bindings/c-bindings.cpp
/home/dl-eric/bun/src/bun.js/bindings/c-bindings.cpp:197:20: error: use of undeclared identifier '__NR_close_range'
    return syscall(__NR_close_range, start, end, flags);

A comment in c-bindings.cpp hints at the issue:

// close_range is glibc > 2.33, which is very new
extern "C" ssize_t bun_close_range(unsigned int start, unsigned int end, unsigned int flags)
{
    return syscall(__NR_close_range, start, end, flags);
}

Upgrading to glibc 2.35 fixes this, so either this version dependency should be documented or asserted somewhere in the build process.

Where did you find it?

https://bun.sh/docs/project/contributing

Jarred-Sumner commented 8 months ago

This bug is not specifically caused by a glibc requirement - it's caused by a linux kernel version minimum. I have updated it to return ENOSYS if the system call number is not defined

dl-eric commented 8 months ago

Wow that was fast, thanks @Jarred-Sumner