Skip to content

Commit

Permalink
Fix release builds for musl targets
Browse files Browse the repository at this point in the history
The `libpg_query.a` static archive fails to link during a release build
for musl targets with errors like: "undefined reference to
`_longjmp_chk'".

This appears to be caused by the fact that the static archive is
compiled with the default toolchain, and so has references to symbols
provided by glibc (but not musl libc).

This change switches to use the `musl-gcc` wrapper as `CC` when the
target triple ends with `-musl`.
  • Loading branch information
JamesGuthrie committed Dec 18, 2023
1 parent 9faad34 commit 8a49ae8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {

make.env_remove("PROFILE").arg("-C").arg(&out_dir).arg("build");

if env::var("TARGET").unwrap().ends_with("-musl") {
make.env("CC", "musl-gcc");
}

if env::var("PROFILE").unwrap() == "debug" {
make.arg("DEBUG=1");
}
Expand Down

0 comments on commit 8a49ae8

Please sign in to comment.