diff --git a/.github/workflows/WasmExtensions.yml b/.github/workflows/WasmExtensions.yml index bbbd4c3..9114f62 100644 --- a/.github/workflows/WasmExtensions.yml +++ b/.github/workflows/WasmExtensions.yml @@ -52,7 +52,8 @@ jobs: - name: PatchDuckDB run: | cd duckdb - git apply ../cmake.patch + git tag v0.10.3 + #git apply ../cmake.patch cp ../extension_config_local.cmake extension/extension_config.cmake - name: Build Wasm module MVP diff --git a/cmake.patch b/cmake.patch deleted file mode 100644 index 20f32f8..0000000 --- a/cmake.patch +++ /dev/null @@ -1,185 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 5f199d3518..76e0b0affe 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -83,6 +83,13 @@ if (EXTENSION_STATIC_BUILD AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - endif() - - option(DISABLE_UNITY "Disable unity builds." FALSE) -+option(USE_WASM_THREADS "Should threads be used" FALSE) -+if (${USE_WASM_THREADS}) -+ set(WASM_THREAD_FLAGS -+ -pthread -+ -sSHARED_MEMORY=1 -+ ) -+endif() - - option(FORCE_COLORED_OUTPUT - "Always produce ANSI-colored output (GNU/Clang only)." FALSE) -@@ -810,10 +817,12 @@ function(build_loadable_extension_directory NAME OUTPUT_DIRECTORY EXTENSION_VERS - COMMAND ${CMAKE_COMMAND} -E copy $ $.lib - ) - # Compile the library into the actual wasm file -+ string(TOUPPER ${NAME} EXTENSION_NAME_UPPERCASE) -+ string (REPLACE ";" " " LINKED_LIBS_STR "${DUCKDB_EXTENSION_${EXTENSION_NAME_UPPERCASE}_LINKED_LIBS}") - add_custom_command( - TARGET ${TARGET_NAME} - POST_BUILD -- COMMAND emcc $.lib -o $ -sSIDE_MODULE=1 -O3 -+ COMMAND emcc $.lib -o $ -O3 -sSIDE_MODULE=2 -sEXPORTED_FUNCTIONS="_${NAME}_init" ${WASM_THREAD_FLAGS} "${LINKED_LIBS_STR}" - ) - endif() - add_custom_command( -@@ -846,7 +855,7 @@ function(build_static_extension NAME PARAMETERS) - endfunction() - - # Internal extension register function --function(register_extension NAME DONT_LINK DONT_BUILD LOAD_TESTS PATH INCLUDE_PATH TEST_PATH) -+function(register_extension NAME DONT_LINK DONT_BUILD LOAD_TESTS PATH INCLUDE_PATH TEST_PATH LINKED_LIBS) - string(TOLOWER ${NAME} EXTENSION_NAME_LOWERCASE) - string(TOUPPER ${NAME} EXTENSION_NAME_UPPERCASE) - -@@ -868,6 +877,8 @@ function(register_extension NAME DONT_LINK DONT_BUILD LOAD_TESTS PATH INCLUDE_PA - endif() - endif() - -+ set(DUCKDB_EXTENSION_${EXTENSION_NAME_UPPERCASE}_LINKED_LIBS "${LINKED_LIBS}" PARENT_SCOPE) -+ - # Allows explicitly disabling extensions that may be specified in other configurations - if (NOT ${DONT_BUILD} AND NOT ${EXTENSION_TESTS_ONLY}) - set(DUCKDB_EXTENSION_${EXTENSION_NAME_UPPERCASE}_SHOULD_BUILD TRUE PARENT_SCOPE) -@@ -893,7 +904,7 @@ function(register_extension NAME DONT_LINK DONT_BUILD LOAD_TESTS PATH INCLUDE_PA - endfunction() - - # Downloads the external extension repo at the specified commit and calls register_extension --macro(register_external_extension NAME URL COMMIT DONT_LINK DONT_BUILD LOAD_TESTS PATH INCLUDE_PATH TEST_PATH APPLY_PATCHES SUBMODULES) -+macro(register_external_extension NAME URL COMMIT DONT_LINK DONT_BUILD LOAD_TESTS PATH INCLUDE_PATH TEST_PATH APPLY_PATCHES LINKED_LIBS SUBMODULES) - include(FetchContent) - if (${APPLY_PATCHES}) - set(PATCH_COMMAND python3 ${CMAKE_SOURCE_DIR}/scripts/apply_extension_patches.py ${CMAKE_SOURCE_DIR}/.github/patches/extensions/${NAME}/) -@@ -921,6 +932,7 @@ macro(register_external_extension NAME URL COMMIT DONT_LINK DONT_BUILD LOAD_TEST - endif() - - message(STATUS "Load extension '${NAME}' from ${URL} @ ${GIT_SHORT_COMMIT}") -+ string(TOUPPER ${NAME} EXTENSION_NAME_UPPERCASE) - set(DUCKDB_EXTENSION_${EXTENSION_NAME_UPPERCASE}_EXT_VERSION "${GIT_SHORT_COMMIT}" PARENT_SCOPE) - - if ("${INCLUDE_PATH}" STREQUAL "") -@@ -935,13 +947,13 @@ macro(register_external_extension NAME URL COMMIT DONT_LINK DONT_BUILD LOAD_TEST - set(TEST_FULL_PATH "${${NAME}_extension_fc_SOURCE_DIR}/${TEST_PATH}") - endif() - -- register_extension(${NAME} ${DONT_LINK} ${DONT_BUILD} ${LOAD_TESTS} ${${NAME}_extension_fc_SOURCE_DIR}/${PATH} "${INCLUDE_FULL_PATH}" "${TEST_FULL_PATH}") -+ register_extension(${NAME} ${DONT_LINK} ${DONT_BUILD} ${LOAD_TESTS} ${${NAME}_extension_fc_SOURCE_DIR}/${PATH} "${INCLUDE_FULL_PATH}" "${TEST_FULL_PATH}" "${LINKED_LIBS}") - endmacro() - - function(duckdb_extension_load NAME) - # Parameter parsing - set(options DONT_LINK DONT_BUILD LOAD_TESTS APPLY_PATCHES) -- set(oneValueArgs SOURCE_DIR INCLUDE_DIR TEST_DIR GIT_URL GIT_TAG SUBMODULES EXTENSION_VERSION) -+ set(oneValueArgs SOURCE_DIR INCLUDE_DIR TEST_DIR GIT_URL GIT_TAG SUBMODULES EXTENSION_VERSION LINKED_LIBS) - cmake_parse_arguments(duckdb_extension_load "${options}" "${oneValueArgs}" "" ${ARGN}) - - string(TOLOWER ${NAME} EXTENSION_NAME_LOWERCASE) -@@ -960,12 +972,12 @@ function(duckdb_extension_load NAME) - - # Remote Git extension - if (${duckdb_extension_load_DONT_BUILD}) -- register_extension(${NAME} "${duckdb_extension_load_DONT_LINK}" "${duckdb_extension_load_DONT_BUILD}" "" "" "" "") -+ register_extension(${NAME} "${duckdb_extension_load_DONT_LINK}" "${duckdb_extension_load_DONT_BUILD}" "" "" "" "" "") - elseif (NOT "${duckdb_extension_load_GIT_URL}" STREQUAL "") - if ("${duckdb_extension_load_GIT_TAG}" STREQUAL "") - error("Git URL specified but no valid GIT_TAG was found for ${NAME} extension") - endif() -- register_external_extension(${NAME} "${duckdb_extension_load_GIT_URL}" "${duckdb_extension_load_GIT_TAG}" "${duckdb_extension_load_DONT_LINK}" "${duckdb_extension_load_DONT_BUILD}" "${duckdb_extension_load_LOAD_TESTS}" "${duckdb_extension_load_SOURCE_DIR}" "${duckdb_extension_load_INCLUDE_DIR}" "${duckdb_extension_load_TEST_DIR}" "${duckdb_extension_load_APPLY_PATCHES}" "${duckdb_extension_load_SUBMODULES}") -+ register_external_extension(${NAME} "${duckdb_extension_load_GIT_URL}" "${duckdb_extension_load_GIT_TAG}" "${duckdb_extension_load_DONT_LINK}" "${duckdb_extension_load_DONT_BUILD}" "${duckdb_extension_load_LOAD_TESTS}" "${duckdb_extension_load_SOURCE_DIR}" "${duckdb_extension_load_INCLUDE_DIR}" "${duckdb_extension_load_TEST_DIR}" "${duckdb_extension_load_APPLY_PATCHES}" "${duckdb_extension_load_LINKED_LIBS}" "${duckdb_extension_load_SUBMODULES}") - if (NOT "${duckdb_extension_load_EXTENSION_VERSION}" STREQUAL "") - set(DUCKDB_EXTENSION_${EXTENSION_NAME_UPPERCASE}_EXT_VERSION "${duckdb_extension_load_EXTENSION_VERSION}" PARENT_SCOPE) - endif() -@@ -1003,7 +1015,7 @@ function(duckdb_extension_load NAME) - set(DUCKDB_EXTENSION_${EXTENSION_NAME_UPPERCASE}_EXT_VERSION "" PARENT_SCOPE) - endif() - endif() -- register_extension(${NAME} "${duckdb_extension_load_DONT_LINK}" "${duckdb_extension_load_DONT_BUILD}" "${duckdb_extension_load_LOAD_TESTS}" "${duckdb_extension_load_SOURCE_DIR}" "${INCLUDE_PATH_DEFAULT}" "${TEST_PATH_DEFAULT}") -+ register_extension(${NAME} "${duckdb_extension_load_DONT_LINK}" "${duckdb_extension_load_DONT_BUILD}" "${duckdb_extension_load_LOAD_TESTS}" "${duckdb_extension_load_SOURCE_DIR}" "${INCLUDE_PATH_DEFAULT}" "${TEST_PATH_DEFAULT}" "${duckdb_extension_load_LINKED_LIBS}") - elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/extension_external/${NAME}) - # Local extension, default path - message(STATUS "Load extension '${NAME}' from '${CMAKE_CURRENT_SOURCE_DIR}/extension_external'") -@@ -1012,7 +1024,7 @@ function(duckdb_extension_load NAME) - else() - # Local extension, default path - message(STATUS "Load extension '${NAME}' from '${CMAKE_CURRENT_SOURCE_DIR}/extensions'") -- register_extension(${NAME} ${duckdb_extension_load_DONT_LINK} "${duckdb_extension_load_DONT_BUILD}" "${duckdb_extension_load_LOAD_TESTS}" "${CMAKE_CURRENT_SOURCE_DIR}/extension/${NAME}" "${CMAKE_CURRENT_SOURCE_DIR}/extension/${NAME}/include" "${CMAKE_CURRENT_SOURCE_DIR}/extension/${NAME}/test/sql") -+ register_extension(${NAME} ${duckdb_extension_load_DONT_LINK} "${duckdb_extension_load_DONT_BUILD}" "${duckdb_extension_load_LOAD_TESTS}" "${CMAKE_CURRENT_SOURCE_DIR}/extension/${NAME}" "${CMAKE_CURRENT_SOURCE_DIR}/extension/${NAME}/include" "${CMAKE_CURRENT_SOURCE_DIR}/extension/${NAME}/test/sql" "${duckdb_extension_load_LINKED_LIBS}") - set(DUCKDB_EXTENSION_${EXTENSION_NAME_UPPERCASE}_EXT_VERSION "${DUCKDB_EXTENSION_${EXTENSION_NAME_UPPERCASE}_EXT_VERSION}" PARENT_SCOPE) - endif() - -@@ -1024,6 +1036,7 @@ function(duckdb_extension_load NAME) - set(DUCKDB_EXTENSION_${EXTENSION_NAME_UPPERCASE}_PATH ${DUCKDB_EXTENSION_${EXTENSION_NAME_UPPERCASE}_PATH} PARENT_SCOPE) - set(DUCKDB_EXTENSION_${EXTENSION_NAME_UPPERCASE}_INCLUDE_PATH ${DUCKDB_EXTENSION_${EXTENSION_NAME_UPPERCASE}_INCLUDE_PATH} PARENT_SCOPE) - set(DUCKDB_EXTENSION_${EXTENSION_NAME_UPPERCASE}_TEST_PATH ${DUCKDB_EXTENSION_${EXTENSION_NAME_UPPERCASE}_TEST_PATH} PARENT_SCOPE) -+ set(DUCKDB_EXTENSION_${EXTENSION_NAME_UPPERCASE}_LINKED_LIBS ${DUCKDB_EXTENSION_${EXTENSION_NAME_UPPERCASE}_LINKED_LIBS} PARENT_SCOPE) - endfunction() - - if(${EXPORT_DLL_SYMBOLS}) -diff --git a/Makefile b/Makefile -index a6fd0dcd3e..ef4c740acd 100644 ---- a/Makefile -+++ b/Makefile -@@ -265,14 +265,14 @@ ifneq ("${CMAKE_LLVM_PATH}", "") - CMAKE_VARS:=${CMAKE_VARS} -DCMAKE_RANLIB='${CMAKE_LLVM_PATH}/bin/llvm-ranlib' -DCMAKE_AR='${CMAKE_LLVM_PATH}/bin/llvm-ar' -DCMAKE_CXX_COMPILER='${CMAKE_LLVM_PATH}/bin/clang++' -DCMAKE_C_COMPILER='${CMAKE_LLVM_PATH}/bin/clang' - endif - --CMAKE_VARS:=${CMAKE_VARS} ${COMMON_CMAKE_VARS} -- - ifdef DUCKDB_PLATFORM - ifneq ("${DUCKDB_PLATFORM}", "") -- CMAKE_VARS:=${CMAKE_VARS} -DDUCKDB_EXPLICIT_PLATFORM='${DUCKDB_PLATFORM}' -+ COMMON_CMAKE_VARS:=${COMMON_CMAKE_VARS} -DDUCKDB_EXPLICIT_PLATFORM='${DUCKDB_PLATFORM}' - endif - endif - -+CMAKE_VARS:=${CMAKE_VARS} ${COMMON_CMAKE_VARS} -+ - clean: - rm -rf build - -@@ -292,19 +292,35 @@ release: ${EXTENSION_CONFIG_STEP} - cmake $(GENERATOR) $(FORCE_COLOR) ${WARNINGS_AS_ERRORS} ${FORCE_WARN_UNUSED_FLAG} ${FORCE_32_BIT_FLAG} ${DISABLE_UNITY_FLAG} ${DISABLE_SANITIZER_FLAG} ${STATIC_LIBCPP} ${CMAKE_VARS} ${CMAKE_VARS_BUILD} -DCMAKE_BUILD_TYPE=Release ../.. && \ - cmake --build . --config Release - -+#### VCPKG config -+VCPKG_TOOLCHAIN_PATH?= -+ifneq ("${VCPKG_TOOLCHAIN_PATH}", "") -+ TOOLCHAIN_FLAGS:=${TOOLCHAIN_FLAGS} -DVCPKG_MANIFEST_DIR='${PROJ_DIR}/build/extension_configuration' -DVCPKG_BUILD=1 -DCMAKE_TOOLCHAIN_FILE='${VCPKG_TOOLCHAIN_PATH}' -+endif -+ifneq ("${VCPKG_TARGET_TRIPLET}", "") -+ TOOLCHAIN_FLAGS:=${TOOLCHAIN_FLAGS} -DVCPKG_TARGET_TRIPLET='${VCPKG_TARGET_TRIPLET}' -+endif -+ -+VCPKG_EMSDK_FLAGS=-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=$(EMSDK)/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -+WASM_COMPILE_TIME_COMMON_FLAGS=-DWASM_LOADABLE_EXTENSIONS=1 -DBUILD_EXTENSIONS_ONLY=1 -DSKIP_EXTENSIONS="parquet;json" $(TOOLCHAIN_FLAGS) $(VCPKG_EMSDK_FLAGS) -DDUCKDB_CUSTOM_PLATFORM='${DUCKDB_PLATFORM}' -DDUCKDB_EXPLICIT_PLATFORM='${DUCKDB_PLATFORM}' -+WASM_CXX_MVP_FLAGS= -+WASM_CXX_EH_FLAGS=$(WASM_CXX_MVP_FLAGS) -fwasm-exceptions -DWEBDB_FAST_EXCEPTIONS=1 -+WASM_CXX_THREADS_FLAGS=$(WASM_COMPILE_TIME_EH_FLAGS) -DWITH_WASM_THREADS=1 -DWITH_WASM_SIMD=1 -DWITH_WASM_BULK_MEMORY=1 -pthread -+WASM_LINK_TIME_FLAGS=-O3 -sSIDE_MODULE=2 -sEXPORTED_FUNCTIONS="_${EXT_NAME}_version,_${EXT_NAME}_init" -+ - wasm_mvp: ${EXTENSION_CONFIG_STEP} - mkdir -p ./build/wasm_mvp && \ -- emcmake cmake $(GENERATOR) ${COMMON_CMAKE_VARS} -DWASM_LOADABLE_EXTENSIONS=1 -DBUILD_EXTENSIONS_ONLY=1 -Bbuild/wasm_mvp -DCMAKE_CXX_FLAGS="-DDUCKDB_CUSTOM_PLATFORM=wasm_mvp" && \ -+ emcmake cmake $(GENERATOR) $(EXTENSION_FLAGS) $(WASM_COMPILE_TIME_COMMON_FLAGS) -Bbuild/wasm_mvp -DCMAKE_CXX_FLAGS="$(WASM_CXX_MVP_FLAGS)" -DDUCKDB_EXPLICIT_PLATFORM="wasm_mvp" -DBUILD_EXTENSIONS_ONLY=1 && \ - emmake make -j8 -Cbuild/wasm_mvp - - wasm_eh: ${EXTENSION_CONFIG_STEP} - mkdir -p ./build/wasm_eh && \ -- emcmake cmake $(GENERATOR) ${COMMON_CMAKE_VARS} -DWASM_LOADABLE_EXTENSIONS=1 -DBUILD_EXTENSIONS_ONLY=1 -Bbuild/wasm_eh -DCMAKE_CXX_FLAGS="-fwasm-exceptions -DWEBDB_FAST_EXCEPTIONS=1 -DDUCKDB_CUSTOM_PLATFORM=wasm_eh" && \ -+ emcmake cmake $(GENERATOR) $(EXTENSION_FLAGS) $(WASM_COMPILE_TIME_COMMON_FLAGS) -Bbuild/wasm_eh -DCMAKE_CXX_FLAGS="$(WASM_CXX_EH_FLAGS)" -DDUCKDB_EXPLICIT_PLATFORM="wasm_eh" -DBUILD_EXTENSIONS_ONLY=1 && \ - emmake make -j8 -Cbuild/wasm_eh - - wasm_threads: ${EXTENSION_CONFIG_STEP} - mkdir -p ./build/wasm_threads && \ -- emcmake cmake $(GENERATOR) ${COMMON_CMAKE_VARS} -DWASM_LOADABLE_EXTENSIONS=1 -DBUILD_EXTENSIONS_ONLY=1 -Bbuild/wasm_threads -DCMAKE_CXX_FLAGS="-fwasm-exceptions -DWEBDB_FAST_EXCEPTIONS=1 -DWITH_WASM_THREADS=1 -DWITH_WASM_SIMD=1 -DWITH_WASM_BULK_MEMORY=1 -DDUCKDB_CUSTOM_PLATFORM=wasm_threads" && \ -+ emcmake cmake $(GENERATOR) $(EXTENSION_FLAGS) $(WASM_COMPILE_TIME_COMMON_FLAGS) -Bbuild/wasm_threads -DCMAKE_CXX_FLAGS="$(WASM_CXX_THREADS_FLAGS)" -DDUCKDB_EXPLICIT_PLATFORM="wasm_threads" && \ - emmake make -j8 -Cbuild/wasm_threads - - cldebug: ${EXTENSION_CONFIG_STEP}