Skip to content
Merged
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
3 changes: 0 additions & 3 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,3 @@ r = "run --features"
[target.'cfg(target_os="macos")']
# Postgres symbols won't be available until runtime
rustflags = ["-Clink-arg=-Wl,-undefined,dynamic_lookup"]

[target.'cfg(target_env="msvc")']
linker = "lld-link"
3 changes: 0 additions & 3 deletions cargo-pgrx/src/templates/cargo_config_toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[target.'cfg(target_os="macos")']
# Postgres symbols won't be available until runtime
rustflags = ["-Clink-arg=-Wl,-undefined,dynamic_lookup"]

[target.'cfg(target_env="msvc")']
linker = "lld-link"
13 changes: 8 additions & 5 deletions pgrx-bindgen/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1009,11 +1009,14 @@ fn build_shim(
std::fs::copy(shim_src, shim_dst).unwrap();

let mut build = cc::Build::new();
if let Some("msvc") = env_tracked("CARGO_CFG_TARGET_ENV").as_deref() {
// without this, pgrx_embed would be linked to postgres.lib
build.compiler("clang");
build.archiver("llvm-lib");
build.flag("-flto=thin");
let compiler = build.get_compiler();
if compiler.is_like_gnu() || compiler.is_like_clang() {
build.flag("-ffunction-sections");
build.flag("-fdata-sections");
}
if compiler.is_like_msvc() {
build.flag("/Gy");
build.flag("/Gw");
}
for pg_target_include in pg_target_includes(major_version, pg_config)?.iter() {
build.flag(&format!("-I{pg_target_include}"));
Expand Down