Skip to content

Commit f3bef2b

Browse files
committed
don't redownload duckdb for every branch
1 parent deb7de0 commit f3bef2b

3 files changed

Lines changed: 22 additions & 18 deletions

File tree

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,8 @@ use_debug = "deny"
367367

368368
[profile.release]
369369
codegen-units = 1
370-
# Turn LTO off, as it breaks when vortex-duckdb-ext is linked.
370+
# Our general performance should not be dependent on LTO since crates that use
371+
# Vortex may choose not to have LTO.
371372
lto = "off"
372373

373374
[profile.release_debug]

vortex-duckdb/build.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,14 @@ fn c2rust(crate_dir: &Path, duckdb_include_dir: &Path) {
328328
}
329329
}
330330

331-
fn cpp(duckdb_include_dir: &Path) {
331+
fn cpp(duckdb_include_dir: &Path, build_type: &str) {
332+
let mut flags = vec!["-Wall", "-Wextra", "-Wpedantic", "-Werror"];
333+
if build_type == "release" {
334+
flags.extend_from_slice(&["-flto=auto"]);
335+
}
332336
cc::Build::new()
333337
.std("c++20")
334-
.flags(["-Wall", "-Wextra", "-Wpedantic"])
338+
.flags(flags)
335339
.cpp(true)
336340
.include(duckdb_include_dir)
337341
.include("cpp/include")
@@ -392,8 +396,12 @@ fn main() {
392396

393397
let crate_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
394398
let duckdb_dir = crate_dir.join("duckdb");
395-
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
396-
let library_dir = out_dir.join(format!("duckdb-lib-{version}"));
399+
// Cargo has changed OUT_DIR behaviour so for every branch and build we have
400+
// a different directory e.g.
401+
// ~/vortex/target/release/build/vortex-duckdb-b6bc1fb73230910e/out/duckdb-lib-v1.5.2
402+
// We don't want this since artifacts are the same.
403+
// We can't use CARGO_TARGET_DIR since it's out of tree.
404+
let library_dir = duckdb_dir.join(format!("duckdb-lib-{version}"));
397405

398406
let library_dir_str = library_dir.display();
399407
println!("cargo:rustc-link-search=native={library_dir_str}");
@@ -414,7 +422,7 @@ fn main() {
414422
// Alternatively, set LD_LIBRARY_PATH (Linux) or DYLD_LIBRARY_PATH (macOS) at runtime.
415423
println!("cargo:lib_dir={library_dir_str}");
416424

417-
let source_dir = out_dir.join(format!("duckdb-source-{version}"));
425+
let source_dir = duckdb_dir.join(format!("duckdb-source-{version}"));
418426
let source_archive_url = match &version {
419427
DuckDBVersion::Release(v) => format!("{DUCKDB_SOURCE_RELEASE_URL}/v{v}.zip"),
420428
DuckDBVersion::Commit(c) => format!("{DUCKDB_SOURCE_COMMIT_URL}/{c}.zip"),
@@ -429,10 +437,6 @@ fn main() {
429437
extract(&source_archive_path, &source_dir);
430438
}
431439

432-
drop(fs::remove_file(&duckdb_dir));
433-
drop(fs::remove_dir_all(&duckdb_dir));
434-
std::os::unix::fs::symlink(&source_dir, &duckdb_dir).unwrap();
435-
436440
let has_debug_env =
437441
env::var("VX_DUCKDB_DEBUG").is_ok_and(|v| matches!(v.as_str(), "1" | "true"));
438442
let build_type = match has_debug_env {
@@ -449,6 +453,6 @@ fn main() {
449453

450454
let duckdb_include_dir = inner_dir.join("src").join("include");
451455
c2rust(&crate_dir, &duckdb_include_dir);
452-
cpp(&duckdb_include_dir);
456+
cpp(&duckdb_include_dir, build_type);
453457
rust2c(&crate_dir);
454458
}

vortex-duckdb/cpp/CMakeLists.txt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33

44
# This CMake project is only used for IDE support (CLion, etc.).
55
# See build.rs for the actual build definition.
6-
#
76
# Prerequisites: Run `cargo build -p vortex-duckdb` first to download DuckDB
8-
# source and create the symlink at ../duckdb.
7+
# source
98
#
109
# If your editor relies on a compilation database to enable LSP functionality,
1110
# you can generate it by running `cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON` or
@@ -23,19 +22,19 @@ if (NOT CMAKE_BUILD_TYPE)
2322
endif()
2423

2524
# Enable compiler warnings (matching build.rs flags).
26-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic")
25+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -Werror")
26+
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall -Wextra -Wpedantic -Werror -O3")
2727

28-
# Find DuckDB include directory via the symlink created by build.rs.
29-
# The symlink points to target/duckdb-source-vX.Y.Z which contains duckdb-X.Y.Z/
30-
file(GLOB DUCKDB_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../duckdb/duckdb-*")
28+
# Find DuckDB include directory containing duckdb-source-vX.Y.Z which contains duckdb-X.Y.Z/
29+
file(GLOB DUCKDB_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../duckdb/duckdb-source-*/duckdb-*/")
3130
if(DUCKDB_DIRS)
3231
list(GET DUCKDB_DIRS 0 DUCKDB_DIR)
3332
set(DUCKDB_INCLUDE "${DUCKDB_DIR}/src/include")
3433
message(STATUS "Found DuckDB include: ${DUCKDB_INCLUDE}")
3534
else()
3635
message(FATAL_ERROR
3736
"DuckDB source not found at ../duckdb/duckdb-*\n"
38-
"Run 'cargo build -p vortex-duckdb' first to download DuckDB and create the symlink."
37+
"Run 'cargo build -p vortex-duckdb' first to download DuckDB"
3938
)
4039
endif()
4140

0 commit comments

Comments
 (0)