#!/bin/bash # https://docs.sheetjs.com/docs/demos/engines/chakra cd /tmp rm -rf sheetjs-chakra mkdir sheetjs-chakra cd sheetjs-chakra git clone https://github.com/chakra-core/ChakraCore.git cd ChakraCore git checkout e26c81f cd .. cd ChakraCore ## in commit e26c81f in macOS 15.2, the build fails with the following error: ## ##/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk/usr/include/c++/v1/new:279:66: error: redefinition of 'operator new' ## 279 | _LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_HIDE_FROM_ABI void* operator new(std::size_t, void* __p) _NOEXCEPT { ## | ^ ##/tmp/sheetjs-chakra/ChakraCore/lib/Common/Memory/Allocator.h:457:1: note: previous definition is here ## 457 | operator new( ## | ^ ## ## This patch avoids the issues cat <sheetjs.patch diff --git a/lib/Common/Memory/Allocator.h b/lib/Common/Memory/Allocator.h index 5a3a099bc..e05a7390f 100644 --- a/lib/Common/Memory/Allocator.h +++ b/lib/Common/Memory/Allocator.h @@ -452,24 +452,7 @@ void AssertValue(void * mem, T value, uint byteCount) #ifndef __PLACEMENT_NEW_INLINE #define __PLACEMENT_NEW_INLINE -_Ret_notnull_ -NO_EXPORT(inline void *) __cdecl -operator new( -DECLSPEC_GUARD_OVERFLOW size_t byteSize, -_In_ void * previousAllocation) throw() -{ - return previousAllocation; -} - - -NO_EXPORT(inline void) __cdecl -operator delete( -void * allocationToFree, // Allocation to free -void * previousAllocation // Previously allocated memory -) throw() -{ - -} +#include #endif EOF git apply sheetjs.patch ./build.sh --static --icu=/usr/local/opt/icu4c/include --test-build -j=8 --no-jit cd .. curl -L -O https://docs.sheetjs.com/chakra/sheetjs.ch.cpp curl -L -O https://docs.sheetjs.com/chakra/Makefile make curl -L -O https://cdn.sheetjs.com/xlsx-latest/package/dist/xlsx.full.min.js curl -L -O https://cdn.sheetjs.com/xlsx-latest/package/dist/shim.min.js curl -L -O https://docs.sheetjs.com/pres.numbers ./sheetjs.ch pres.numbers cp ChakraCore/out/Test/ch . node -e "fs.writeFileSync('payload.js', 'var payload = \"' + fs.readFileSync('pres.numbers').toString('base64') + '\";')" cat <global.js var global = (function(){ return this; }).call(null); EOF cat <chakra.js var wb = XLSX.read(payload, {type:'base64'}); console.log(XLSX.utils.sheet_to_csv(wb.Sheets[wb.SheetNames[0]])); EOF cat global.js xlsx.full.min.js payload.js chakra.js > xlsx.chakra.js ./ch xlsx.chakra.js