Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,10 @@ jobs:
shell: bash
run: |
choco install visualstudio2022buildtools --package-parameters "--add Microsoft.VisualStudio.Workload.VCTools --includeRecommended --passive" -y
- name: Install LLVM / Clang (Windows)
if: matrix.os == 'windows-x64'
shell: bash
run: choco install llvm -y
- name: Setup Python (Windows)
if: matrix.os == 'windows-x64'
uses: actions/setup-python@v5
Expand All @@ -533,7 +537,7 @@ jobs:
tool: nextest
- name: Rust Tests (Windows)
if: matrix.os == 'windows-x64'
run: cargo nextest run --locked --workspace --all-features --no-fail-fast --exclude bench-vortex --exclude vortex-python --exclude vortex-duckdb --exclude vortex-fuzz
run: cargo nextest run --locked --workspace --all-features --no-fail-fast --exclude bench-vortex --exclude vortex-python --exclude vortex-fuzz
- name: Rust Tests (Other)
if: matrix.os != 'windows-x64'
run: cargo nextest run --locked --workspace --all-features --no-fail-fast --exclude bench-vortex --exclude vortex-duckdb
Expand Down
55 changes: 39 additions & 16 deletions vortex-duckdb/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ fn download_duckdb_lib_archive() -> Result<PathBuf, Box<dyn std::error::Error>>
"x86_64-apple-darwin" => ("osx", "universal"),
"x86_64-unknown-linux-gnu" => ("linux", "amd64"),
"aarch64-unknown-linux-gnu" => ("linux", "arm64"),
"x86_64-pc-windows-msvc" => ("windows", "amd64"),
"aarch64-pc-windows-msvc" => ("windows", "arm64"),
_ => return Err(format!("Unsupported target: {target}").into()),
};

Expand Down Expand Up @@ -71,9 +73,11 @@ fn extract_duckdb_libraries(archive_path: PathBuf) -> Result<PathBuf, Box<dyn st
.ok_or("Invalid archive path")?
.to_path_buf();

// Check if already extracted. The archive for Linux only contains a .so library, macOS only .dylib.
// Check if already extracted. The archive for Linux contains
// a .so library, macOS .dylib and Windows a .dll file.
if duckdb_lib_dir.join("libduckdb.dylib").exists()
|| duckdb_lib_dir.join("libduckdb.so").exists()
|| duckdb_lib_dir.join("duckdb.dll").exists()
{
println!("DuckDB libraries already extracted, skipping extraction");
return Ok(duckdb_lib_dir);
Expand Down Expand Up @@ -204,7 +208,7 @@ fn build_duckdb(duckdb_source_root: &Path) -> Result<PathBuf, Box<dyn std::error
}
fs::create_dir_all(&duckdb_library_dir)?;

// Copy .dylib and .so files (macOS and Linux).
// Copy .dylib, .so, and .dll files (macOS, Linux, and Windows).
for entry in fs::read_dir(build_dir.join("src"))? {
let entry = entry?;
let path = entry.path();
Expand Down Expand Up @@ -233,8 +237,13 @@ fn main() {
let zip_source_path = download_duckdb_source_archive().unwrap();
let extracted_source_path = extract_duckdb_source(zip_source_path).unwrap();
drop(fs::remove_dir_all(&duckdb_repo));

#[cfg(unix)]
std::os::unix::fs::symlink(&extracted_source_path, &duckdb_repo).unwrap();

#[cfg(windows)]
std::os::windows::fs::symlink_dir(&extracted_source_path, &duckdb_repo).unwrap();

let library_path =
// DuckDB debug build is linked in case of `VX_DUCKDB_DEBUG=1`.
if env::var("VX_DUCKDB_DEBUG").is_ok_and(|v| matches!(v.as_str(), "1" | "true")) {
Expand Down Expand Up @@ -293,23 +302,37 @@ fn main() {
println!("cargo:rerun-if-env-changed=VX_DUCKDB_SAN");
println!("cargo:rustc-link-search=native={}", library_path.display());
println!("cargo:rustc-link-lib=dylib=duckdb");

#[cfg(unix)]
println!("cargo:rustc-link-arg=-Wl,-rpath,{}", library_path.display());

// Compile our C++ code that exposes additional DuckDB functionality.
cc::Build::new()
.std("c++17")
// Enable compiler warnings.
.flag("-Wall")
.flag("-Wextra")
.flag("-Wpedantic")
// Allow C++20 designator syntax even with C++17 std
.flag("-Wno-c++20-designator")
// Enable C++20 extensions
.flag("-Wno-c++20-extensions")
// Unused parameter warnings are disabled as we include DuckDB
// headers with implementations that have unused parameters.
.flag("-Wno-unused-parameter")
.cpp(true)
let mut builder = cc::Build::new();
builder.std("c++17").cpp(true);

#[cfg(target_os = "windows")]
{
builder
// Enable C++ exception handling
.flag("/EHsc");
}

#[cfg(not(target_os = "windows"))]
{
builder
.flag("-Wall")
.flag("-Wextra")
.flag("-Wpedantic")
// Allow C++20 designator syntax even with C++17 std
.flag("-Wno-c++20-designator")
// Enable C++20 extensions
.flag("-Wno-c++20-extensions")
// Unused parameter warnings are disabled as we include DuckDB
// headers with implementations that have unused parameters.
.flag("-Wno-unused-parameter");
}

builder
// We include DuckDB headers from the DuckDB extension submodule.
.include(duckdb_repo.join(format!("duckdb-{}/src/include", DUCKDB_VERSION.as_str())))
.include("cpp/include")
Expand Down
Loading