diff --git a/examples/esbuild-browser/serve.json b/examples/esbuild-browser/serve.json index 825afee008..db8e11d4ad 100644 --- a/examples/esbuild-browser/serve.json +++ b/examples/esbuild-browser/serve.json @@ -3,8 +3,14 @@ { "source": "*", "headers": [ - { "key": "Cross-Origin-Embedder-Policy", "value": "require-corp" }, - { "key": "Cross-Origin-Opener-Policy", "value": "same-origin" } + { + "key": "Cross-Origin-Embedder-Policy", + "value": "require-corp" + }, + { + "key": "Cross-Origin-Opener-Policy", + "value": "same-origin" + } ] } ] diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 60a692282a..03302687b8 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -22,7 +22,7 @@ if(DEFINED ENV{DUCKDB_WASM_LOADABLE_EXTENSIONS}) endif() -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -DDUCKDB_WASM=1") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -DDUCKDB_WASM=1 -DFSST_MUST_ALIGN") if(DUCKDB_WASM_LOADABLE_EXTENSIONS) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWASM_LOADABLE_EXTENSIONS=1 -DDUCKDB_EXTENSION_AUTOLOAD_DEFAULT=1 -fPIC") @@ -110,16 +110,11 @@ if(EMSCRIPTEN) endif() # Debug build elseif(CMAKE_BUILD_TYPE STREQUAL "Debug") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \ - --profiling \ - -gsource-map \ - --source-map-base=file://${CMAKE_BINARY_DIR}/") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") set(WASM_LINK_FLAGS "${WASM_LINK_FLAGS} \ -sASSERTIONS=1 \ -sSAFE_HEAP=1 \ - -gsource-map \ - --source-map-base=file://${CMAKE_BINARY_DIR}/ \ - -sSEPARATE_DWARF_URL=file://${CMAKE_BINARY_DIR}/duckdb.wasm") + -g") # ... with fast linking if(WASM_FAST_LINKING) set(WASM_LINK_FLAGS "${WASM_LINK_FLAGS} -O0") diff --git a/packages/duckdb-wasm/src/targets/duckdb-browser-coi.pthread.worker.ts b/packages/duckdb-wasm/src/targets/duckdb-browser-coi.pthread.worker.ts index e92933615a..2be2de22ac 100644 --- a/packages/duckdb-wasm/src/targets/duckdb-browser-coi.pthread.worker.ts +++ b/packages/duckdb-wasm/src/targets/duckdb-browser-coi.pthread.worker.ts @@ -12,15 +12,17 @@ for (const func of Object.getOwnPropertyNames(BROWSER_RUNTIME)) { // We just override the load handler of the pthread wrapper to bundle DuckDB with esbuild. globalThis.onmessage = (e: any) => { if (e.data.cmd === 'load') { - const m = pthread_api.getModule(); + let m = pthread_api.getModule(); - // Module and memory were sent from main thread + (globalThis as any).startWorker = (instance: any) => { + m = instance; + postMessage({ cmd: 'loaded' }); + }; m['wasmModule'] = e.data.wasmModule; m['wasmMemory'] = e.data.wasmMemory; m['buffer'] = m['wasmMemory'].buffer; m['ENVIRONMENT_IS_PTHREAD'] = true; - - DuckDB(m).then(function (instance) { + DuckDB(m).then((instance: any) => { pthread_api.setModule(instance); }); } else if (e.data.cmd === 'registerFileHandle') {