You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
rust_decimal is a regular library crate for decimal numbers. With the 'db-diesel2-postgres' feature,
it pulls in the pq-sys dependency, that in its build.rs potentially finds libpq using pkg-config:
(To make pkg-config work with the homebrew setup, we are modifying some envvars, see .bazelrc)
In the demo repository, the target //:good depends on rust_decimal, and bazel can compile and link it.
The rust_decimal_macros is a proc-macro crate, that provides (surprise!) macros for the above crate.
It depends on rust_decimal, therefore it also pulls in pq-sys transitively.
In the demo repository, the target //:bad depends on rust_decimal_macros, and bazel cannot compile it:
$ bazel build bad
[...]
ld: library 'pq' not found
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Suspicion
aquery shows that //:good inherits a linker search path from pq-sys:
$ bazel aquery good | grep pq
[...]
bazel-out/darwin_arm64-fastbuild/bin/external/rules_rust~~crate~crates__pq-sys-0.6.3/_bs.linksearchpaths \
but //bad: does not. Therefore the suspicion, that proc macro crates do not pass forward their link search path files?
Interestingly, even if bad also depends on rust_decimal or even pq-sys, it doesn't link.
The text was updated successfully, but these errors were encountered:
Refined suspicion: The link search path given by the build.rs file is not propagated to the linking of proc-macro itself, that is linked in host configuration. Ugly workaround:
Reproduction Requirements
I could trigger this on macOS only. Install:
Then clone:
What happens there
rust_decimal
is a regular library crate for decimal numbers. With the'db-diesel2-postgres'
feature,it pulls in the
pq-sys
dependency, that in itsbuild.rs
potentially finds libpq usingpkg-config
:(To make
pkg-config
work with the homebrew setup, we are modifying some envvars, see.bazelrc
)In the demo repository, the target
//:good
depends onrust_decimal
, and bazel can compile and link it.The
rust_decimal_macros
is a proc-macro crate, that provides (surprise!) macros for the above crate.It depends on
rust_decimal
, therefore it also pulls inpq-sys
transitively.In the demo repository, the target
//:bad
depends onrust_decimal_macros
, and bazel cannot compile it:Suspicion
aquery
shows that//:good
inherits a linker search path frompq-sys
:but
//bad:
does not. Therefore the suspicion, that proc macro crates do not pass forward their link search path files?Interestingly, even if
bad
also depends onrust_decimal
or evenpq-sys
, it doesn't link.The text was updated successfully, but these errors were encountered: