Open3
JavaScriptCoreのREPLがCygwinで動いた
長く苦しい孤独な戦いだった。。
まぁCygwinのpackageのパッチは有るんだけどね。。(ただし超古い)
- https://cygwin.com/git-cygwin-packages/?p=git/cygwin-packages/clang.git;a=tree
- https://cygwin.com/git-cygwin-packages/?p=git/cygwin-packages/llvm.git;a=tree
- https://cygwin.com/git-cygwin-packages/?p=git/cygwin-packages/webkitgtk.git;a=tree
例えば -g1
を指定するといったのは既に入っている。最終的にWebKitのCMakeは
cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -DPORT=WPE -DWPE_INCLUDE_DIR=/cygdrive/f/webkit/proj/libwpe/include -DWPE_LIBRARY=/usr/lib/libelf.a -DUSE_SOUP2=ON -DENABLE_JOURNALD_LOG=OFF -DENABLE_JIT=OFF -DENABLE_C_LOOP=ON -DENABLE_SAMPLING_PROFILER=OFF -DENABLE_UNIFIED_BUILDS=OFF .
に加えて、
DEBUG_FISSION=OFF
USE_THIN_ARCHIVES=OFF
USE_SYSTEM_MALLOC=ON
CMAKE_C_COMPILER
CMAKE_CXX_COMPILER
あたりは調整が必要になった。あとARとRANLIBもLLVMのを使ったしCFLAGS/CXXFLAGSも調整してるな。。
bmallocがクラッシュする
まぁbmallocはとりあえずナシで。。あんまり良い実装とも思わないし。。
(gdb) run
Starting program: /cygdrive/f/webkit/build/webkit/bin/jsc.exe
[New Thread 148484.0x3b4cc]
[New Thread 148484.0x2a65c]
[New Thread 148484.0x7798]
[New Thread 148484.0x1e4a4]
[New Thread 148484.0xb004]
Thread 1 "jsc" received signal SIGSEGV, Segmentation fault.
0x00000001014cd547 in bmalloc::SmallPage::ref(std::unique_lock<bmalloc::Mutex>&) () at /cygdrive/f/webkit/proj/WebKit/Source/bmalloc/bmalloc/SmallPage.h:83
83 BASSERT(m_refCount);
(gdb) bt
#0 0x00000001014cd547 in bmalloc::SmallPage::ref(std::unique_lock<bmalloc::Mutex>&) () at /cygdrive/f/webkit/proj/WebKit/Source/bmalloc/bmalloc/SmallPage.h:83
#1 0x0000000100aa305f in bmalloc::Heap::allocateSmallBumpRangesByMetadata(std::unique_lock<bmalloc::Mutex>&, unsigned long, bmalloc::BumpAllocator&, bmalloc::FixedVector<bmalloc::BumpRange, 3ul>&, std::array<bmalloc::List<bmalloc::SmallPage>, 112ul>&, bmalloc::FailureAction)::$_4::operator()(unsigned long&) const ()
at /cygdrive/f/webkit/proj/WebKit/Source/bmalloc/bmalloc/Heap.cpp:409
#2 0x0000000100aa2dcd in bmalloc::Heap::allocateSmallBumpRangesByMetadata(std::unique_lock<bmalloc::Mutex>&, unsigned long, bmalloc::BumpAllocator&, bmalloc::FixedVector<bmalloc::BumpRange, 3ul>&, std::array<bmalloc::List<bmalloc::SmallPage>, 112ul>&, bmalloc::FailureAction) ()
at /cygdrive/f/webkit/proj/WebKit/Source/bmalloc/bmalloc/Heap.cpp:429
#3 0x00000001014ca53c in bmalloc::Heap::allocateSmallBumpRanges(std::unique_lock<bmalloc::Mutex>&, unsigned long, bmalloc::BumpAllocator&, bmalloc::FixedVector<bmalloc::BumpRange, 3ul>&, std::array<bmalloc::List<bmalloc::SmallPage>, 112ul>&, bmalloc::FailureAction) ()
at /cygdrive/f/webkit/proj/WebKit/Source/bmalloc/bmalloc/Heap.h:157
#4 0x0000000100a9ee8b in bmalloc::Allocator::refillAllocatorSlowCase(bmalloc::BumpAllocator&, unsigned long, bmalloc::FailureAction) ()
bmallocは USE_SYSTEM_MALLOC=ON
でoffにできる。
Cygwinのページサイズは64KiB
要出典。。
$ ./jsc.exe
ASSERTION FAILED: CeilingOnPageSize is too low, raise it in PageBlock.h!
%j
▒i(-15584) :
%s
Aborted (core dumped)
とりあえず 64KiBで。
diff --git a/Source/WTF/wtf/PageBlock.h b/Source/WTF/wtf/PageBlock.h
index 8ff8443d0e25..5b75078973a6 100644
--- a/Source/WTF/wtf/PageBlock.h
+++ b/Source/WTF/wtf/PageBlock.h
@@ -46,7 +46,7 @@ namespace WTF {
// Use 64 KiB for any unknown CPUs to be conservative.
#if OS(DARWIN) || PLATFORM(PLAYSTATION) || CPU(MIPS) || CPU(MIPS64)
constexpr size_t CeilingOnPageSize = 16 * KB;
-#elif CPU(PPC) || CPU(PPC64) || CPU(PPC64LE) || CPU(UNKNOWN)
+#elif CPU(PPC) || CPU(PPC64) || CPU(PPC64LE) || CPU(UNKNOWN) || defined(__CYGWIN__)
constexpr size_t CeilingOnPageSize = 64 * KB;
#elif OS(WINDOWS) || CPU(X86) || CPU(X86_64) || CPU(ARM) || CPU(ARM64) || CPU(RISCV64)
constexpr size_t CeilingOnPageSize = 4 * KB;
alignas
に64KiBとか渡せない
このままだとビルド時にエラーになる。
https://github.com/WebKit/WebKit/blob/8afe31a018b11741abdf9b4d5bb973d7c1d9ff05/Source/WTF/wtf/PageBlock.cpp#L47
/cygdrive/f/webkit/proj/WebKit/Source/WTF/wtf/WTFConfig.cpp:46:1: error: requested alignment must be 8192 bytes or smaller
alignas(WTF::ConfigAlignment) Slot g_config[WTF::ConfigSizeToProtect / sizeof(Slot)];
^ ~~~~~~~~~~~~~~~~~~~~
1 error generated.
まぁWindowsではこのコードを使っていないようなので、Cygwinでも同様に。
diff --git a/Source/WTF/wtf/PlatformEnable.h b/Source/WTF/wtf/PlatformEnable.h
index 664b0e29f6ba..38cb8ae26901 100644
--- a/Source/WTF/wtf/PlatformEnable.h
+++ b/Source/WTF/wtf/PlatformEnable.h
@@ -804,7 +804,7 @@
disable both the use of unified Config record and config freezing for the
Windows port.
*/
-#if OS(WINDOWS)
+#if OS(WINDOWS) || defined(__CYGWIN__)
#define ENABLE_UNIFIED_AND_FREEZABLE_CONFIG_RECORD 0
#else
#define ENABLE_UNIFIED_AND_FREEZABLE_CONFIG_RECORD 1