Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plrustc will not compile on alpine/postgres. #372

Open
therealjasonkenney opened this issue Aug 10, 2023 · 3 comments
Open

Plrustc will not compile on alpine/postgres. #372

therealjasonkenney opened this issue Aug 10, 2023 · 3 comments

Comments

@therealjasonkenney
Copy link

therealjasonkenney commented Aug 10, 2023

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.

@eeeebbbbrrrr
Copy link
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.

@therealjasonkenney
Copy link
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?

@workingjubilee
Copy link
Contributor

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants