Skip to content

Commit d83f2d2

Browse files
committed
fix linker path
Signed-off-by: Alexander Droste <[email protected]>
1 parent 17a5603 commit d83f2d2

File tree

2 files changed

+29
-8
lines changed

2 files changed

+29
-8
lines changed

.cargo/config.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
[target.'(target_familiy="unix")']
2-
rustflags = ["-C", "force-frame-pointers=yes"]
1+
[target.'cfg(target_family="unix")']
2+
rustflags = [
3+
"-C", "force-frame-pointers=yes",
4+
"-C", "link-arg=-Wl,-rpath,@executable_path/../lib",
5+
]
6+
37
[target.wasm32-unknown-unknown]
48
rustflags = ['--cfg', 'getrandom_backend="wasm_js"', '-C', 'target-feature=+atomics']
59

vortex-duckdb-ext/build.rs

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,16 @@ const DUCKDB_VERSION: &str = "v1.3.0";
77
const DUCKDB_BASE_URL: &str = "https://github.com/duckdb/duckdb/releases/download";
88

99
fn download_duckdb_archive() -> Result<PathBuf, Box<dyn std::error::Error>> {
10-
let out_dir = PathBuf::from(env::var("OUT_DIR")?);
11-
let duckdb_dir = out_dir.join(format!("duckdb-{DUCKDB_VERSION}"));
10+
let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR")?);
11+
let workspace_root = manifest_dir
12+
.parent()
13+
.ok_or("Failed to get workspace root")?;
14+
15+
let target_dir = env::var("CARGO_TARGET_DIR")
16+
.map(PathBuf::from)
17+
.unwrap_or_else(|_| workspace_root.join("target"));
18+
19+
let duckdb_dir = target_dir.join("lib");
1220

1321
let target = env::var("TARGET")?;
1422
let (platform, arch) = match target.as_str() {
@@ -27,7 +35,7 @@ fn download_duckdb_archive() -> Result<PathBuf, Box<dyn std::error::Error>> {
2735
fs::create_dir_all(&duckdb_dir)?;
2836

2937
if !archive_path.exists() {
30-
println!("Downloading DuckDB static libraries from {url}");
38+
println!("Downloading DuckDB libraries from {url}");
3139
let response = reqwest::blocking::get(&url)?;
3240
fs::write(&archive_path, &response.bytes()?)?;
3341
println!("Downloaded to {}", archive_path.display());
@@ -44,18 +52,27 @@ fn extract_duckdb_libraries(archive_path: PathBuf) -> Result<PathBuf, Box<dyn st
4452
.ok_or("Invalid archive path")?
4553
.to_path_buf();
4654

55+
let lib_file = if env::var("TARGET").unwrap().contains("apple") {
56+
"libduckdb.dylib"
57+
} else {
58+
"libduckdb.so"
59+
};
60+
4761
// Check if already extracted.
48-
if duckdb_dir.join("libduckdb.so").exists() {
62+
if duckdb_dir.join(lib_file).exists() {
4963
println!("DuckDB libraries already extracted, skipping extraction");
5064
return Ok(duckdb_dir);
5165
}
5266

53-
println!("Extracting DuckDB static libraries");
67+
println!("Extracting DuckDB libraries to target/lib");
5468
let file = fs::File::open(&archive_path)?;
5569
let mut archive = zip::ZipArchive::new(file)?;
5670
archive.extract(&duckdb_dir)?;
5771

58-
println!("Extracted DuckDB libraries to {}", duckdb_dir.display());
72+
println!(
73+
"cargo:warning=Extracted DuckDB libraries to: {}",
74+
duckdb_dir.display()
75+
);
5976
Ok(duckdb_dir)
6077
}
6178

0 commit comments

Comments
 (0)