diff --git a/Source/WTF/wtf/bun/BannedIncludes/iostream b/Source/WTF/wtf/bun/BannedIncludes/iostream new file mode 100644 index 0000000000000..ddfe8423927e9 --- /dev/null +++ b/Source/WTF/wtf/bun/BannedIncludes/iostream @@ -0,0 +1,17 @@ +// This directory is placed first on the include search path for non-Debug +// builds when USE_BUN_JSC_ADDITIONS is on, so `#include ` resolves +// here instead of the toolchain header. +// +// is unlike //: on libstdc++ it emits a +// reference to std::ios_base_library_init in every translation unit that +// includes it. One such reference anywhere in the link pulls globals_io.o from +// libstdc++, whose static initializer constructs cin/cout/cerr/clog and their +// wchar_t siblings before main, dragging the full std::locale facet set in +// with it. Bun never touches C++ iostreams at runtime. +// +// Use WTF::dataLog()/dataLogLn() or fputs/fprintf for diagnostics. +#ifndef BUN_ALLOW_IOSTREAM +#error " is banned in Bun WebKit release builds: it forces std::ios_base::Init and the full std::locale facet set to run before main in every bun process. Use WTF::dataLog() or . See Source/WTF/wtf/bun/BannedIncludes/iostream." +#else +#include_next +#endif diff --git a/Source/WTF/wtf/simdutf/simdutf_impl.h b/Source/WTF/wtf/simdutf/simdutf_impl.h index 10110d1a703af..da723062681e8 100644 --- a/Source/WTF/wtf/simdutf/simdutf_impl.h +++ b/Source/WTF/wtf/simdutf/simdutf_impl.h @@ -9942,11 +9942,9 @@ static_assert(to_base64_url_value[uint8_t('_')] == 63, #ifndef SIMDUTF_BASE64_H #define SIMDUTF_BASE64_H -#include #include #include #include -#include namespace simdutf { namespace scalar { diff --git a/Source/cmake/OptionsJSCOnly.cmake b/Source/cmake/OptionsJSCOnly.cmake index dc25e8945abbd..988efb83e1533 100644 --- a/Source/cmake/OptionsJSCOnly.cmake +++ b/Source/cmake/OptionsJSCOnly.cmake @@ -46,6 +46,16 @@ if(USE_BUN_JSC_ADDITIONS) # Causing test/cli/test/bun-test.test.ts to fail. SET_AND_EXPOSE_TO_BUILD(BUSE_TZONE 0) SET_AND_EXPOSE_TO_BUILD(USE_TZONE_MALLOC 0) + + # Shadow with a #error shim in non-Debug builds. On libstdc++ a + # single include anywhere emits a reference to + # std::ios_base_library_init, which pulls globals_io.o (the + # cin/cout/cerr/clog + full std::locale facet static initializer) into the + # final Bun link. // are unaffected. Debug + # builds keep the real header for ad-hoc dataLog-style debugging. + if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") + include_directories(BEFORE "${WTF_DIR}/wtf/bun/BannedIncludes") + endif() endif() # Only works on macOS for now.