Skip to content

Plrustc will not compile on alpine/postgres. #372

Open

Description

@therealjasonkenney

I get this output when running the build script for plrustc:

3.516 + env 'RUSTFLAGS=-Clink-args=-Wl,-rpath,/usr/local/rustup/toolchains/1.70.0-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib -Zunstable-options -Zbinary-dep-depinfo' cargo build --release -p plrustc --bin plrustc --target x86_64-unknown-linux-musl
3.800     Updating crates.io index
4.751  Downloading crates ...
5.213   Downloaded once_cell v1.18.0
5.725   Downloaded libc v0.2.147
5.872    Compiling libc v0.2.147
5.872    Compiling once_cell v1.18.0
7.969    Compiling plrustc v1.2.3 (/tmp/plrust-1.2.3/plrustc/plrustc)
8.681 error: crate `rustc_ast` required to be available in rlib format, but was not found in this form
8.681

I looked in the library path, and indeed many rlibs are missing.

 FROM rust:alpine3.17 AS rust-builder

 RUN rustup update 1.70.0 \
    && rustup default 1.70.0 \
    && rustup component add --toolchain 1.70.0 llvm-tools-preview rustc-dev rust-src
  
  RUN wget -qO /tmp/plrust.tar.gz https://github.com/tcdi/plrust/archive/refs/tags/v1.2.3.tar.gz  \
    && tar -xvzf /tmp/plrust.tar.gz -C /tmp
  
  WORKDIR /tmp/plrust-1.2.3/plrustc
          
   RUN /bin/ash -x ./build.sh

pgrx, plrust both compile without errors. Just plrustc breaks.

Activity

  1. eeeebbbbrrrr commented on Aug 10, 2023

    @eeeebbbbrrrr
    Contributor

    I don't know if this will help, but for alpine you almost always need:

    ENV RUSTFLAGS="-C target-feature=-crt-static"
    

    before you start compiling anything. Give that a shot. Offhand I don't know if plrustc/build.sh might need to be updated or if you can handle it directly in your Dockerfile.

  2. therealjasonkenney commented on Aug 11, 2023

    @therealjasonkenney
    Author

    Thanks, I managed to get it all compiled, mostly by not using plrustc/build.sh and manually adding a json file to postgrestd. However a new problem arrises, how do I get those rust flags to be used when Postgres compiles a rust function?

  3. workingjubilee commented on Aug 21, 2023

    @workingjubilee
    Member

    Proper support would involve threading full support for a musl libc distro in all locations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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