Skip to content

unable to find native static library in 0.55.6 due to change in crate.annotation rustc inputs. #3095

@aran

Description

@aran

In our project we use diesel, which depends on pq-sys. We customize pq-sys to use a libpq built by bazel:

crate.annotation(
    build_script_env = {
        "PQ_LIB_STATIC": "1",
    },
    crate = "pq-sys",
    data = ["@@libpq~~_repo_rules~postgres//:libpq"],
    rustc_flags = [
        "-L",
        "$(BINDIR)/external/libpq~~_repo_rules~postgres",
    ],
)

This works in 0.54.1.

In 0.55.6, I am seeing new build failures:

% bazel build @@rules_rust~~crate~plans_crates__pq-sys-0.6.1//:pq_sys
INFO: Invocation ID: 46e78509-9ff9-4936-a802-5e9e60d1d605
INFO: Analyzed target @@rules_rust~~crate~plans_crates__pq-sys-0.6.1//:pq_sys (32 packages loaded, 313 targets configured).
ERROR: /private/var/tmp/_bazel_aran/3653d9df741c74285dab1d13f08e5df3/external/rules_rust~~crate~plans_crates__pq-sys-0.6.1/BUILD.bazel:18:13: Compiling Rust rlib pq_sys v0.6.1 (5 files) failed: (Exit 1): process_wrapper failed: error executing Rustc command (from target @@rules_rust~~crate~plans_crates__pq-sys-0.6.1//:pq_sys) bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/external/rules_rust~/util/process_wrapper/process_wrapper --env-file ... (remaining 33 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
error: could not find native static library `pq`, perhaps an -L flag is missing?

error: aborting due to 1 previous error

Target @@rules_rust~~crate~plans_crates__pq-sys-0.6.1//:pq_sys failed to build

aquery shows that a -L flag is still being provided (-L \ bazel-out/darwin_arm64-fastbuild/bin/external/libpq~~_repo_rules~postgres), and the directory it is pointing to does contain a libpq.a.

However, in the aquery output, for 0.54.1, I see bazel-out/darwin_arm64-fastbuild/bin/external/libpq~~_repo_rules~postgres/libpq.a, as one of the Rustc Inputs. It is no longer present in the Inputs list in 0.55.6.

I tried adding the libpq target to the crate.annotation deps field, but it doesn't work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions