Giter Site home page Giter Site logo

emk / rust-musl-builder Goto Github PK

View Code? Open in Web Editor NEW
1.5K 1.5K 194.0 147 KB

Docker images for compiling static Rust binaries using musl-libc and musl-gcc, with static versions of useful C libraries. Supports openssl and diesel crates.

License: Apache License 2.0

Shell 27.69% Dockerfile 72.31%

rust-musl-builder's Introduction

rust-musl-builder: Docker container for easily building static Rust binaries

Docker Image

UPDATED: This repository is effectively dead at this point, given the increasing rarity of crates which require OpenSSL.

However, rustls now works well with most of the Rust ecosystem, including reqwest, tokio, tokio-postgres, sqlx and many others. The only major project which still requires libpq and OpenSSL is Diesel. If you don't need diesel or libpq:

  • See if you can switch away from OpenSSL, typically by using features in Cargo.toml to ask your dependencies to use rustls instead.
  • If you don't need OpenSSL, try cross build --target=x86_64-unknown-linux-musl --release to cross-compile your binaries for libmusl. This supports many more platforms, with less hassle!

What is this?

This image allows you to build static Rust binaries using diesel, sqlx or openssl. These images can be distributed as single executable files with no dependencies, and they should work on any modern Linux system.

To try it, run:

alias rust-musl-builder='docker run --rm -it -v "$(pwd)":/home/rust/src ekidd/rust-musl-builder'
rust-musl-builder cargo build --release

This command assumes that $(pwd) is readable and writable by uid 1000, gid 1000. At the moment, it doesn't attempt to cache libraries between builds, so this is best reserved for making final release builds.

For a more realistic example, see the Dockerfiles for examples/using-diesel and examples/using-sqlx.

Deploying your Rust application

With a bit of luck, you should be able to just copy your application binary from target/x86_64-unknown-linux-musl/release, and install it directly on any reasonably modern x86_64 Linux machine. In particular, you should be able make static release binaries using TravisCI and GitHub, or you can copy your Rust application into an Alpine Linux container. See below for details!

Available tags

In general, we provide the following tagged Docker images:

  • latest, stable: Current stable Rust, now with OpenSSL 1.1. We try to update this fairly rapidly after every new stable release, and after most point releases.
  • X.Y.Z: Specific versions of stable Rust.
  • beta: This usually gets updated every six weeks alongside the stable release. It will usually not be updated for beta bugfix releases.
  • nightly-YYYY-MM-DD: Specific nightly releases. These should almost always support clippy, rls and rustfmt, as verified using rustup components history. If you need a specific date for compatibility with tokio or another popular library using unstable Rust, please file an issue.

At a minimum, each of these images should be able to compile examples/using-diesel and examples/using-sqlx.

Caching builds

You may be able to speed up build performance by adding the following -v commands to the rust-musl-builder alias:

-v cargo-git:/home/rust/.cargo/git
-v cargo-registry:/home/rust/.cargo/registry
-v target:/home/rust/src/target

You will also need to fix the permissions on the mounted volumes:

rust-musl-builder sudo chown -R rust:rust \
  /home/rust/.cargo/git /home/rust/.cargo/registry /home/rust/src/target

How it works

rust-musl-builder uses musl-libc, musl-gcc, and the new rustup target support. It includes static versions of several libraries:

  • The standard musl-libc libraries.
  • OpenSSL, which is needed by many Rust applications.
  • libpq, which is needed for applications that use diesel with PostgreSQL.
  • libz, which is needed by libpq.
  • SQLite3. See examples/using-diesel.

This library also sets up the environment variables needed to compile popular Rust crates using these libraries.

Extras

This image also supports the following extra goodies:

  • Basic compilation for armv7 using musl-libc. Not all libraries are supported at the moment, however.
  • mdbook and mdbook-graphviz for building searchable HTML documentation from Markdown files. Build manuals to use alongside your cargo doc output!
  • cargo about to collect licenses for your dependencies.
  • cargo deb to build Debian packages
  • cargo deny to check your Rust project for known security issues.

Making OpenSSL work

If your application uses OpenSSL, you will also need to take a few extra steps to make sure that it can find OpenSSL's list of trusted certificates, which is stored in different locations on different Linux distributions. You can do this using openssl-probe as follows:

fn main() {
    openssl_probe::init_ssl_cert_env_vars();
    //... your code
}

Making Diesel work

In addition to setting up OpenSSL, you'll need to add the following lines to your Cargo.toml:

[dependencies]
diesel = { version = "1", features = ["postgres", "sqlite"] }

# Needed for sqlite.
libsqlite3-sys = { version = "*", features = ["bundled"] }

# Needed for Postgres.
openssl = "*"

For PostgreSQL, you'll also need to include diesel and openssl in your main.rs in the following order (in order to avoid linker errors):

extern crate openssl;
#[macro_use]
extern crate diesel;

If this doesn't work, you might be able to fix it by reversing the order. See this PR for a discussion of the latest issues involved in linking to diesel, pq-sys and openssl-sys.

Making static releases with Travis CI and GitHub

These instructions are inspired by rust-cross.

First, read the Travis CI: GitHub Releases Uploading page, and run travis setup releases as instructed. Then add the following lines to your existing .travis.yml file, replacing myapp with the name of your package:

language: rust
sudo: required
os:
- linux
- osx
rust:
- stable
services:
- docker
before_deploy: "./build-release myapp ${TRAVIS_TAG}-${TRAVIS_OS_NAME}"
deploy:
  provider: releases
  api_key:
    secure: "..."
  file_glob: true
  file: "myapp-${TRAVIS_TAG}-${TRAVIS_OS_NAME}.*"
  skip_cleanup: true
  on:
    rust: stable
    tags: true

Next, copy build-release into your project and run chmod +x build-release.

Finally, add a Dockerfile to perform the actual build:

FROM ekidd/rust-musl-builder

# We need to add the source code to the image because `rust-musl-builder`
# assumes a UID of 1000, but TravisCI has switched to 2000.
ADD --chown=rust:rust . ./

CMD cargo build --release

When you push a new tag to your project, build-release will automatically build new Linux binaries using rust-musl-builder, and new Mac binaries with Cargo, and it will upload both to the GitHub releases page for your repository.

For a working example, see faradayio/cage.

Making tiny Docker images with Alpine Linux and Rust binaries

Docker now supports multistage builds, which make it easy to build your Rust application with rust-musl-builder and deploy it using Alpine Linux. For a working example, see examples/using-diesel/Dockerfile.

Adding more C libraries

If you're using Docker crates which require specific C libraries to be installed, you can create a Dockerfile based on this one, and use musl-gcc to compile the libraries you need. For an example, see examples/adding-a-library/Dockerfile. This usually involves a bit of experimentation for each new library, but it seems to work well for most simple, standalone libraries.

If you need an especially common library, please feel free to submit a pull request adding it to the main Dockerfile! We'd like to support popular Rust crates out of the box.

Development notes

After modifying the image, run ./test-image to make sure that everything works.

Other ways to build portable Rust binaries

If for some reason this image doesn't meet your needs, there's a variety of other people working on similar projects:

License

Either the Apache 2.0 license, or the MIT license.

rust-musl-builder's People

Contributors

bitzl avatar bomgar avatar cssivision avatar dvic avatar emk avatar frol avatar icorderi avatar insanitybit avatar miraclx avatar mriehl avatar silvio avatar snobu avatar stevenleadbeater avatar svend avatar tofay avatar tzrlk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rust-musl-builder's Issues

openssl runtime error

  • use cargo run everything is ok.
  • successfully built a static binary, but get a openssl issue when run the executable binary:
The OpenSSL library reported an error: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed:s3_clnt.c:1264:

Cannot use local libraries

Hi

I tried to use rust-musl-builder but it failed when updating the dependencies In
Cargo.toml:

error: Unable to update file:///home/rust/<project_name>

Caused by:
  failed to read `/home/rust/<project_name>/Cargo.toml`

I am using local libraries in the project I am trying to build, so I have something like this in Cargo.toml:

[dependencies.<project_name>]
path = "../<project_name>"

The path cannot be found because the local directory where the main project is stored is mounted inside the docker container, but the local libs are outside.

Not sure how/if this kind of setup can be supported in a nice way but I am reporting it anyhow :).

Consider avoiding sudo (especially, passwordless sudo)

Passwordless sudo inside a container is almost the same as running the commands by root directly. What is the point of going through all the hassle of managing rust user if simple sudo -i will bring you to the root shell?

Building crate with dependency on libclang?

Is this something that is possible using this Docker image?

Currently trying to build something that depends on findshlibs (0.4.0), which fails to build using the latest rust-musl-builder image.

Minimal example:

Cargo.toml

[package]
name = "ftest"
version = "0.1.0"

[dependencies]
findshlibs = "0.4.0"

main.rs

fn main() {
    println!("Hello, world!");
}

Then building with:

docker run --rm -it -v "$(pwd)":/home/rust/src ekidd/rust-musl-builder cargo build

eventually fails with:

   ... packages omitted ...
   Compiling clap v2.31.2
   Compiling thread_local v0.3.5
   Compiling cexpr v0.2.3
   Compiling findshlibs v0.4.0
error: failed to run custom build command for `findshlibs v0.4.0`
process didn't exit successfully: `/home/rust/src/target/debug/build/findshlibs-82fc297a20c1d8dd/build-script-build` (exit code: 101)
--- stderr
thread 'main' panicked at 'Unable to find libclang: "couldn\'t find any of [\'libclang.so\', \'libclang.so.*\', \'libclang-*.so\'], set the LIBCLANG_PATH environment variable to a path where one of these files can be found (skipped: [])"', libcore/result.rs:945:5
note: Run with `RUST_BACKTRACE=1` for a backtrace.

So wondering if I can use a custom Dockerfile to make those libraries available when building? Or whether the above is just masking some other issue.

build script not found

What did you try to do?

I found the build-script-not-found error while using rust-musl-builder, here is the link for reproducing this error, I'm not sure it's a cargo bug or rust-musl-builder's bug or just because that I use a bad method.

What happened?

cannot compile

What did you hope to happen?

be able to compile

Additional information

Is there anything else that we should know? no

Binary doesn't seem to be fully static

First of all, thanks for this image.

When trying to compile this project using docker run --rm -it -v "$(pwd)":/home/rust/src ekidd/rust-musl-builder cargo build --release the resulted binary doesn't seem to be static:

$ ldd transporter
    linux-vdso.so.1 (0x00007ffe895f1000)
    libc.so => not found
$ ./transporter
-bash: ./transporter: /lib/ld64.so.1: bad ELF interpreter: No such file or directory

I'm probably doing something wrong here, but I couldn't figure out what is it

Please update nightly to 1.33.0

pin has been stabilized since 1.33.0 and tokio-async-await (0.1.5) no longer compiles in the current nightly because they've removed the feature gate.

@emk Could you please update the nightly build?

Possible to upgrade nightly to 1.25.0?

docker run --rm -it -v "$(pwd)":/home/rust/src ekidd/rust-musl-builder:nightly cargo build --release

Trying to build a rust rocket webserver container, but getting this error:

warning: build failed, waiting for other jobs to finish...
error: failed to run custom build command for `rocket v0.3.6`
process didn't exit successfully: `/home/rust/src/target/release/build/rocket-739bb9e3dbfc16ec/build-script-build` (exit code: 101)
--- stderr
Error: Rocket requires a more recent version of rustc.
Use `rustup update` or your preferred method to update Rust.
Installed version is: 1.24.0-nightly (2018-01-03). Minimum required: 1.25.0-nightly (2018-01-12).
thread 'main' panicked at 'Aborting compilation due to incompatible compiler.', /home/rust/.cargo/registry/src/github.com-1ecc6299db9ec823/rocket-0.3.6/build.rs:50:13
note: Run with `RUST_BACKTRACE=1` for a backtrace.

Or is there a better way to do this?

Please update stable to 1.36.0

How could this project be improved?
1.36.0 was just released. Would be great to have an image for this release.

Also, it looks like sqlite in the 1.35.0 is not up to date. I get this error when trying to build diesel with the sqlite feature:

  = note: /usr/bin/ld: cannot find -lsqlite3
          collect2: error: ld returned 1 exit status

I can get around this by run apt update && apt install sqlite3 libsqlite3-dev libzip-dev. I added the dev package for libzip because after adding sqlite, I ran into a similar error but with -lz.

If you're interested in implementing this feature yourself, how could I help you?
Happy to attempt a PR, if that helps.

Mount local crates into container

Would you be interested in adding a note to the README about mounting the local cache to speed up build times? It stores the crates on the host machine in-between builds, and speeds up the overall build process.

# CACHE_DIR is probably $HOME/.cargo/registry

docker run --rm -it -v $CACHE_DIR:/home/rust/.cargo/registry -v $(pwd):/home/rust/src ekidd/rust-musl-builder:nightly cargo build

Permission denied on build

Consider this Dockerfile:

# Our first FROM statement declares the build environment.
FROM ekidd/rust-musl-builder AS builder

# You would normally add your source code to /home/rust/src like this.
COPY . /home/rust/src/

# Build our application.
RUN cargo build --release

FROM alpine:latest
RUN apk --no-cache add ca-certificates
COPY --from=builder \
  /home/rust/src/target/x86_64-unknown-linux-musl/release/app \
  /usr/local/bin/
CMD /usr/local/bin/app

I'm getting following error on building image:

Sending build context to Docker daemon  27.14kB
Step 1/7 : FROM ekidd/rust-musl-builder AS builder
 ---> 92fa09f60317
Step 2/7 : COPY . /home/rust/src/
 ---> 2f52fde9c6f4
Step 3/7 : RUN cargo build --release
 ---> Running in 59cc9a3fd6f9
error: failed to open: /home/rust/src/target/release/.cargo-lock

Caused by:
  Permission denied (os error 13)
The command '/bin/sh -c cargo build --release' returned a non-zero code: 101

My app is simply generated with cargo new --bin app

rust-musl-builder and DinD CI

Hello, I'm trying to use rust-musl-builder in my CI flow I use droneCI for that, that means I'm running a DinD so when I run rust-musl-builder cargo build --target=aarch64-unknown-linux-gnu --release I have the following error could not find Cargo.toml in /home/rust/src cause for some reason the volume doesn't mount in the last container

Update to stable rust v1.29

Please update the image so that it contains rust 1.29.

Also, how do I simply update one in my own image?
When I try I have this:

root@0549b9ea95aa:/home/rust# su rust
rust@0549b9ea95aa:~$ .cargo/bin/rustup update
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
info: latest update on 2018-09-13, rust version 1.29.0 (aa3ca1994 2018-09-11)
info: downloading component 'rustc'
info: downloading component 'rust-std'
info: downloading component 'cargo'
info: downloading component 'rust-docs'
info: downloading component 'rust-std' for 'armv7-unknown-linux-musleabihf'
info: downloading component 'rust-std' for 'x86_64-unknown-linux-musl'
info: removing component 'rustc'
info: rolling back changes
error: could not rename component file from '/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends' to '/home/rust/.rustup/tmp/rio5q73mj8clfll6_dir/bk'
info: checking for self-updates

  stable-x86_64-unknown-linux-gnu update failed - rustc 1.28.0 (9634041f0 2018-07-30)

warning: tool `rustfmt` is already installed, remove it from `/home/rust/.cargo/bin`, then run `rustup update` to have rustup manage this tool.
warning: tool `cargo-fmt` is already installed, remove it from `/home/rust/.cargo/bin`, then run `rustup update` to have rustup manage this tool

Can't build a docker image. #HelpNeeded

Hi.
First I should say I'm very new to docker.
I'm trying to build a docker image using nightly Rust (planning to use Rocket).
But build fails with error (two last lines):

....
making all in tools...
make[1]: Entering directory '/tmp/openssl-1.0.2o/tools'
make[1]: Nothing to be done for 'all'.

make[1]: Leaving directory '/tmp/openssl-1.0.2o/tools'
sudo: /etc/sudoers.d/nopasswd is world writable
sudo: no tty present and no askpass program specifie
....

The only change I did in Dockerfile is in line 6 changed to ARG TOOLCHAIN=nightly

To be honest I can't even build the original file... so I guess it's related to my lack of docker knowledge. I spend lots of time searching for a solution but never got any progress.

My system:

uname -a
Linux myMint 4.15.0-47-generic #50-Ubuntu SMP Wed Mar 13 10:44:52 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

docker -v
Docker version 18.09.2, build 6247962

Current nightly image currently failing

First up, fantastic script and Docker image, it has been revolutionary in getting static builds deployed through CI for me ๐Ÿ‘

Looks like the current nightly image is broken though due to a cargo issue from last month, would it be at all possible to have a new image built from the Dockerfile? It's currently stopping me from being able to use this to deploy a Rocket app.

The error looks like the following:

mick@mick-pc ~/D/b/api (master)> ./build-release 
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /checkout/src/libcore/option.rs:323
note: Run with `RUST_BACKTRACE=1` for a backtrace.

Thanks!
Michael

docker --ssh feature fails

I am trying to use the --ssh option of the docker build command. I can successfully use it with ubuntu as a base image

# syntax=docker/dockerfile:1.0.0-experimental
# syntax=docker/dockerfile:experimental
FROM ubuntu:18.04

RUN apt-get -yq update && apt-get -yqq install ssh git

RUN mkdir -m 700 ~/.ssh && touch -m ~/.ssh/known_hosts && ssh-keyscan github.com > ~/.ssh/known_hosts
RUN --mount=type=ssh,id=github git clone [email protected]:my-company/my-private-repo.git ~/my-private-repo

but it fails when I use ekidd/rust-musl-builder

# syntax=docker/dockerfile:1.0.0-experimental
# syntax=docker/dockerfile:experimental
FROM ekidd/rust-musl-builder

RUN sudo apt-get -yq update && sudo apt-get -yqq install ssh git

RUN mkdir -m 700 ~/.ssh && touch -m ~/.ssh/known_hosts && ssh-keyscan github.com > ~/.ssh/known_hosts
RUN --mount=type=ssh,id=github git clone [email protected]:my-company/my-private-repo.git ~/my-private-repo

Running the command DOCKER_BUILDKIT=1 docker build --ssh github=~/.ssh/id_rsa . gives me the following error message:

#9 1.043 [email protected]: Permission denied (publickey).
#9 1.045 fatal: Could not read from remote repository.
#9 1.045
#9 1.045 Please make sure you have the correct access rights
#9 1.045 and the repository exists.

It's unclear to me what in the rust-musl-builder image may break the --ssh.

Here is my docker version:

Client: Docker Engine - Community
 Version:           18.09.2
 API version:       1.39
 Go version:        go1.10.8
 Git commit:        6247962
 Built:             Sun Feb 10 04:12:39 2019
 OS/Arch:           darwin/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.2
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.6
  Git commit:       6247962
  Built:            Sun Feb 10 04:13:06 2019
  OS/Arch:          linux/amd64
  Experimental:     false

Build error: https://github.com/mariocao/actix-p2p

First of all great work! The project is very much appreciated.

Anyway, building https://github.com/mariocao/actix-p2p outside of rust-musl-builder works without error on my Debian GNU/Linux 9 (stretch) 64 Bit machine with cargo 1.30.0 (36d96825d 2018-10-24) . However if I try to build inside the rust-musl-builder, I get the following errors:


error: cannot find derive macro Message in this scope
--> src/codec.rs:8:17
|
8 | #[derive(Debug, Message)]
| ^^^^^^^

error: cannot find derive macro Message in this scope
--> src/codec.rs:14:17
|
14 | #[derive(Debug, Message)]
| ^^^^^^^

error[E0658]: crate in paths is experimental (see issue #45477)
--> src/client.rs:11:5
|
11 | use crate::codec::P2PCodec;
| ^^^^^

error[E0658]: crate in paths is experimental (see issue #45477)
--> src/client.rs:12:5
|
12 | use crate::session::Session;
| ^^^^^

error[E0658]: crate in paths is experimental (see issue #45477)
--> src/server.rs:17:5
|
17 | use crate::codec::P2PCodec;
| ^^^^^

error[E0658]: crate in paths is experimental (see issue #45477)
--> src/server.rs:18:5
|
18 | use crate::session::Session;
| ^^^^^

error[E0658]: crate in paths is experimental (see issue #45477)
--> src/session.rs:13:5
|
13 | use crate::codec::{P2PCodec, Request};
| ^^^^^

error[E0658]: crate in paths is experimental (see issue #45477)
--> src/main.rs:14:5
|
14 | use crate::client::Client;
| ^^^^^

error[E0658]: crate in paths is experimental (see issue #45477)
--> src/main.rs:15:5
|
15 | use crate::server::Server;
| ^^^^^

error: aborting due to 9 previous errors

For more information about this error, try rustc --explain E0658.
error: Could not compile actix-p2p.


E0658:

An unstable feature was used.

Erroneous code example:

#[repr(u128)] // error: use of unstable library feature 'repr128'
enum Foo {
    Bar(u64),
}

If you're using a stable or a beta version of rustc, you won't be able to use
any unstable features. In order to do so, please switch to a nightly version of
rustc (by using rustup).

If you're using a nightly version of rustc, just add the corresponding feature
to be able to use it:

Updating the embedded rust version fails

I use the following docker command to compile my app with the latest nightly version:
docker run --rm -it -v "$HOME/.cargo/registry":/home/rust/.cargo/registry -v "$(pwd)":/home/rust/src ekidd/rust-musl-builder:nightly /bin/bash -c "rustup update; cargo build --verbose --release"

previously this worked, but now the update fails and it uses the older nightly version, which is incompatible with my code:

Unable to find image 'ekidd/rust-musl-builder:nightly' locally
nightly: Pulling from ekidd/rust-musl-builder
Status: Downloaded newer image for ekidd/rust-musl-builder:nightly
info: syncing channel updates for 'nightly-x86_64-unknown-linux-gnu'
info: downloading component 'rustc'
 43.8 MiB /  43.8 MiB (100 %)   5.6 MiB/s ETA:   0 s                
info: downloading component 'rust-std'
 71.0 MiB /  71.0 MiB (100 %)   5.6 MiB/s ETA:   0 s                
info: downloading component 'cargo'
  9.4 MiB /   9.4 MiB (100 %)   9.1 MiB/s ETA:   0 s                
info: downloading component 'rust-docs'
 11.3 MiB /  11.3 MiB (100 %)   7.4 MiB/s ETA:   0 s                
info: downloading component 'rust-std' for 'x86_64-unknown-linux-musl'
 14.8 MiB /  14.8 MiB (100 %)   6.1 MiB/s ETA:   0 s                
info: rolling back changes
error: could not rename component directory from '/home/rust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/share/doc/rust/html' to '/home/rust/.rustup/tmp/n9q7qtc1ziteopal_dir/bk'
info: checking for self-updates
  nightly-x86_64-unknown-linux-gnu update failed - rustc 1.17.0-nightly (a559452b0 2017-03-17)

Use a non-ephemeral cargo cache

It would be nice if the cargo cache for this image wasn't ephemeral so that every rebuild didn't wind up re-downloading all the crates it needs. I can think of two ways do to this:

  1. Use VOLUME ~rust/.cargo to make the .cargo directory a persistent data volume: https://docs.docker.com/engine/reference/builder/#/volume (This must be done after all the steps in the Dockerfile that will write data to that directory.)
  2. Change the alias to mount the host ~/.cargo as ~rust/.cargo, to share the cargo cache from the host system.

Can not find crate for std, when building with rust-toolchain file

My project has got a file named: rust-toolchain. It's content is required compiler version: 1.24.1
The project builds fine on my desktop. rust-toolchain is also taken into account automatically and correctly.

However, the builder container failed to build one:

> docker run --rm -it --mount type=bind,source=$(pwd),target=/home/rust/src ekidd/rust-musl-builder cargo build --release

The output is:

info: syncing channel updates for '1.24.1-x86_64-unknown-linux-gnu'
269.6 KiB / 269.6 KiB (100 %) 247.4 KiB/s ETA:   0 s
info: latest update on 2018-03-01, rust version 1.24.1 (d3ae9a9e0 2018-02-27)
info: downloading component 'rustc'
 47.8 MiB /  47.8 MiB (100 %)  17.2 MiB/s ETA:   0 s
info: downloading component 'rust-std'
 66.9 MiB /  66.9 MiB (100 %)  18.1 MiB/s ETA:   0 s
info: downloading component 'cargo'
info: downloading component 'rust-docs'
info: installing component 'rustc'
info: installing component 'rust-std'
info: installing component 'cargo'
info: installing component 'rust-docs'
    Updating registry `https://github.com/rust-lang/crates.io-index`
 Downloading serde_json v1.0.6
 Downloading serde v1.0.20
 Downloading env_logger v0.5.4
 Downloading tokio-timer v0.1.2
 Downloading log v0.4.1
 Downloading chrono v0.4.0
 Downloading clap v2.27.1
 Downloading error-chain v0.11.0
 Downloading serde_derive v1.0.20
 Downloading reqwest v0.8.4
 Downloading uuid v0.6.0
 Downloading tokio-core v0.1.10
 Downloading openssl-probe v0.1.2
 Downloading hyper v0.11.15
 Downloading futures v0.1.17
 Downloading dtoa v0.4.2
 Downloading itoa v0.3.4
 Downloading num-traits v0.1.40
 Downloading regex v0.2.6
 Downloading humantime v1.1.0
 Downloading atty v0.2.3
 Downloading termcolor v0.3.5
 Downloading cfg-if v0.1.2
 Downloading aho-corasick v0.6.4
 Downloading memchr v2.0.1
 Downloading utf8-ranges v1.0.0
 Downloading regex-syntax v0.4.2
 Downloading thread_local v0.3.5
 Downloading libc v0.2.33
 Downloading unreachable v1.0.0
 Downloading lazy_static v1.0.0
 Downloading void v1.0.2
 Downloading quick-error v1.2.1
 Downloading slab v0.3.0
 Downloading time v0.1.38
 Downloading num v0.1.40
 Downloading num-integer v0.1.35
 Downloading num-iter v0.1.34
 Downloading vec_map v0.8.0
 Downloading strsim v0.6.0
 Downloading bitflags v0.9.1
 Downloading ansi_term v0.9.0
 Downloading unicode-width v0.1.4
 Downloading textwrap v0.9.0
 Downloading backtrace v0.3.5
 Downloading rustc-demangle v0.1.5
 Downloading serde_derive_internals v0.17.0
 Downloading quote v0.3.15
 Downloading syn v0.11.11
 Downloading synom v0.11.3
 Downloading unicode-xid v0.0.4
 Downloading serde_urlencoded v0.5.1
 Downloading native-tls v0.1.5
 Downloading uuid v0.5.1
 Downloading mime_guess v2.0.0-alpha.3
 Downloading hyper-tls v0.1.2
 Downloading url v1.6.0
 Downloading tokio-tls v0.1.4
 Downloading tokio-io v0.1.4
 Downloading bytes v0.4.5
 Downloading libflate v0.1.14
 Downloading matches v0.1.6
 Downloading idna v0.1.4
 Downloading percent-encoding v1.0.1
 Downloading unicode-bidi v0.3.4
 Downloading unicode-normalization v0.1.5
 Downloading slab v0.4.0
 Downloading iovec v0.1.1
 Downloading scoped-tls v0.1.0
 Downloading mio v0.6.11
 Downloading log v0.3.8
 Downloading byteorder v1.1.0
 Downloading net2 v0.2.31
 Downloading lazycell v0.5.1
 Downloading lazy_static v0.2.11
 Downloading rand v0.3.18
 Downloading unicase v1.4.2
 Downloading phf v0.7.21
 Downloading mime v0.3.5
 Downloading version_check v0.1.3
 Downloading phf_shared v0.7.21
 Downloading siphasher v0.2.2
 Downloading unicase v2.0.0
 Downloading rustc_version v0.1.7
 Downloading semver v0.1.20
 Downloading phf_codegen v0.7.21
 Downloading phf_generator v0.7.21
 Downloading tokio-service v0.1.0
 Downloading relay v0.1.0
 Downloading tokio-proto v0.1.1
 Downloading httparse v1.2.3
 Downloading base64 v0.9.0
 Downloading language-tags v0.2.2
 Downloading futures-cpupool v0.1.7
 Downloading smallvec v0.2.1
 Downloading take v0.1.0
 Downloading safemem v0.2.0
 Downloading num_cpus v1.7.0
 Downloading crc v1.7.0
 Downloading adler32 v1.0.2
 Downloading build_const v0.2.0
 Downloading rand v0.4.2
 Downloading backtrace-sys v0.1.16
 Downloading cc v1.0.4
 Downloading openssl v0.9.23
 Downloading foreign-types v0.3.2
 Downloading openssl-sys v0.9.24
 Downloading foreign-types-shared v0.1.1
 Downloading pkg-config v0.3.9
   Compiling quick-error v1.2.1
   Compiling take v0.1.0
error[E0463]: can't find crate for `std`
  |
  = note: the `x86_64-unknown-linux-musl` target may not be installed

error: aborting due to previous error

error[E0463]: can't find crate for `std`
  |
  = note: the `x86_64-unknown-linux-musl` target may not be installed

error: aborting due to previous error

error: Could not compile `take`.
warning: build failed, waiting for other jobs to finish...
error: Could not compile `quick-error`.

To learn more, run the command again with --verbose.

What is the way to fix it?

standard_init_linux.go:178: exec user process caused "permission denied"

Hi!
I am getting this error:

docker run --rm -it -v "$(pwd)":/home/rust/src ekidd/rust-musl-builder cargo build --release
standard_init_linux.go:178: exec user process caused "permission denied"

Any ideas how to make it work?

My env:

uname -a
Linux susanne 4.9.0-3-amd64 #1 SMP Debian 4.9.30-2+deb9u2 (2017-06-26) x86_64 GNU/Linux
docker --version
Docker version 17.03.1-ce, build c6d412e

Using diesel and sqlite3

I get the following compile error:

 = note: /usr/bin/ld: cannot find -lsqlite3
          collect2: error: ld returned 1 exit status

The PR was closed but was the issue solved or rejected? #29

libinfer_schema_macros.so: undefined symbol: ASN1_STRING_length

First of all, thanks for creating this!

I have tried to build my cargo binary with your docker image, it is sadly slightly out of date. (I need at least 2017-12-20 due to codegen deps) However I was able to fix that in my Dockerfile. However, then I get this error:

error: /home/rust/src/target/release/deps/libinfer_schema_macros-da12480521239fc5.so: undefined symbol: ASN1_STRING_length
  --> /home/rust/.cargo/registry/src/github.com-1ecc6299db9ec823/diesel_infer_schema-1.0.0-beta1/src/lib.rs:15:1
   |
15 | extern crate infer_schema_macros;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Do you know what would fix this?

My Dockerfile:

FROM ekidd/rust-musl-builder:1.20.0 AS builder

ADD . ./

RUN sudo chown -R rust:rust /home/rust

RUN rustup default nightly-2017-12-20 &&  rustup target add x86_64-unknown-linux-musl

RUN cargo build --release

FROM alpine:latest
RUN apk --no-cache add ca-certificates
COPY --from=builder \
    /home/rust/src/target/x86_64-unknown-linux-musl/release/fc \
    /usr/local/bin/
CMD /usr/local/bin/fc

This seems different from the pg-sys problem you mention in the Readme.

Unable to find musl-g++

I have a dependency on grpcio-sys, which is failing to build in the container with the following:

error: failed to run custom build command for `grpcio-sys v0.2.3`
process didn't exit successfully: `/home/rust/src/target/release/build/grpcio-sys-53b66955a325ba1b/build-script-build` (exit code: 101)
--- stdout
cargo:rerun-if-changed=grpc_wrap.c
cargo:rerun-if-changed=grpc
cargo:rerun-if-env-changed=GRPCIO_SYS_USE_PKG_CONFIG
running: "cmake" "/home/rust/.cargo/registry/src/github.com-1ecc6299db9ec823/grpcio-sys-0.2.3/grpc" "-DCMAKE_INSTALL_PREFIX=/home/rust/src/target/x86_64-unknown-linux-musl/release/build/grpcio-sys-0c674ae629d3b252/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64 -static" "-DCMAKE_C_COMPILER=/usr/bin/musl-gcc" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64 -static" "-DCMAKE_CXX_COMPILER=musl-g++" "-DCMAKE_BUILD_TYPE=Release"
-- The CXX compiler identification is unknown
-- Configuring incomplete, errors occurred!
See also "/home/rust/src/target/x86_64-unknown-linux-musl/release/build/grpcio-sys-0c674ae629d3b252/out/build/CMakeFiles/CMakeOutput.log".
See also "/home/rust/src/target/x86_64-unknown-linux-musl/release/build/grpcio-sys-0c674ae629d3b252/out/build/CMakeFiles/CMakeError.log".

--- stderr
CMake Error at CMakeLists.txt:31 (project):
The CMAKE_CXX_COMPILER:

musl-g++

is not a full path and was not found in the PATH.

Tell CMake where to find the compiler by setting either the environment
variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
to the compiler, or to the compiler name if it is in the PATH.


thread 'main' panicked at '
command did not execute successfully, got: exit code: 1

build script failed, must exit now', /home/rust/.cargo/registry/src/github.com-1ecc6299db9ec823/cmake-0.1.31/src/lib.rs:643:5
note: Run with `RUST_BACKTRACE=1` for a backtrace.

OpenSSL linker error

One of my builds started failing yesterday when the image got updated.

When building with ekidd/rust-musl-builder@sha256:ee647bcd629149e1fb5be3b6aab27ecf5626e58e101b9b6f801eb70aa25fd7cc I get the following linker error:

  = note: /home/rust/project/target/x86_64-unknown-linux-musl/release/deps/libpq_sys-6529182a19f7c36c.rlib(fe-secure-openssl.o): In function `pgtls_init':
          fe-secure-openssl.c:(.text+0x1493): undefined reference to `OPENSSL_config'
          collect2: error: ld returned 1 exit status

This error did not happen with the previous nightly image (ekidd/rust-musl-builder@sha256:74cf07e9c178a78954d07c2a98103ed4bfcd8da011c4deb1b91fcbf7a59c58c1)

Use of bindgen

Hi,

thanks for this amazing docker file, it was really helpful.

In my project I use bindgen which requires:

llvm-3.9-dev libclang-3.9-dev clang-3.9

Can we install them in the docker file?

They increase sensibly the overall size of the image.

I can go ahead and provide a PR if needed.

Has anybody succeeded with static build with dependent C++ library?

Hi,

I'm trying to build static binary, which depends on taglib, which is C++ library with C bindings. I use this rust crate, which binds this library - https://github.com/ebassi/taglib-rust.

After bit of playing around I ended up with link failure, where only two symbols are missing __dso_handle and __sprintf_chk - first one seems to be generic problem of static linking of C++ library - as refered here rust-lang/rust#36710 (comment) (with some possible workaround), for second symbol I'm not sure - it looks like some incompatibility between glibc and musl libc? Musl faq says "The existing libstdc++ is actually compatible with musl in most cases and could be used by copying it into the musl library path".

Here are steps I've done to compile (using this image):

cd ..
curl -sL https://taglib.org/releases/taglib-1.11.1.tar.gz | tar xzv
cd taglib-1.11.1/
CC=musl-gcc CPPFLAGS=-I/usr/local/musl/include cmake  -DCMAKE_INSTALL_PREFIX:PATH=/usr/local/musl .
make && sudo make install
cd ../src

# in ~/.cargo/config add
# [target.x86_64-unknown-linux-musl]
# rustflags=["-C", "link-arg=-lstdc++", "-C", "link-arg=-lz"]
sudo cp /usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a /usr/local/musl/lib

cargo build --release

And got this error:

= note: /usr/local/musl/lib//libstdc++.a(system_error.o): In function `_GLOBAL__sub_I_system_error.cc':                                                                                                    
          (.text.startup._GLOBAL__sub_I_system_error.cc+0x3): undefined reference to `__dso_handle'                                                                                                          
          /usr/local/musl/lib//libstdc++.a(system_error.o): In function `_GLOBAL__sub_I_system_error.cc':                                                                                                    
          (.text.startup._GLOBAL__sub_I_system_error.cc+0x21): undefined reference to `__dso_handle'                                                                                                         
          /home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libstd-cd33df8f773a8d34.rlib(std-cd33df8f773a8d34.std.qsu1i6tj-cgu.2.rcgu.o):(.data._rust_extern_with_linkage___dso_handle.llvm.11799784290520478383+0x0): undefined reference to `__dso_handle'
          /usr/local/musl/lib//libtag_c.a(tag_c.cpp.o): In function `__static_initialization_and_destruction_0(int, int)':                                                                                   
          tag_c.cpp:(.text+0xe66): undefined reference to `__dso_handle'                                                                                                                                     
          tag_c.cpp:(.text+0xe84): undefined reference to `__dso_handle'                                                                                                                                     
          /usr/local/musl/lib//libtag.a(mpegfile.cpp.o):mpegfile.cpp:(.text+0x19fe): more undefined references to `__dso_handle' follow                                                                      
          /usr/local/musl/lib//libstdc++.a(cp-demangle.o): In function `d_print_comp_inner':                                                                                                                 
          (.text+0x4007): undefined reference to `__sprintf_chk'                                                                                                                                             
          /usr/local/musl/lib//libstdc++.a(cp-demangle.o): In function `d_print_comp_inner':                                                                                                                 
          (.text+0x5869): undefined reference to `__sprintf_chk'                                                                                                                                             
          /usr/local/musl/lib//libstdc++.a(cp-demangle.o): In function `d_print_comp_inner':                                                                                                                 
          (.text+0x5cef): undefined reference to `__sprintf_chk'                                                                                                                                             
          /usr/local/musl/lib//libstdc++.a(cp-demangle.o): In function `d_print_comp_inner':                                                                                                                 
          (.text+0x5e56): undefined reference to `__sprintf_chk'                                                                                                                                             
          /usr/local/musl/lib//libstdc++.a(cp-demangle.o): In function `d_print_comp_inner':                                                                                                                 
          (.text+0x69c6): undefined reference to `__sprintf_chk'                                                                                                                                             
          /usr/local/musl/lib//libstdc++.a(cp-demangle.o):(.text+0x87b8): more undefined references to `__sprintf_chk' follow                                                                                
          /usr/local/musl/lib//libstdc++.a(messages_members.o): In function `(anonymous namespace)::get_catalogs()':                                                                                         
          (.text._ZN12_GLOBAL__N_112get_catalogsEv+0xa1): undefined reference to `__dso_handle'                                                                                                              
          /usr/local/musl/lib//libstdc++.a(messages_members_cow.o): In function `(anonymous namespace)::get_catalogs()':                                                                                     
          (.text._ZN12_GLOBAL__N_112get_catalogsEv+0xa1): undefined reference to `__dso_handle'                                                                                                              
          /usr/bin/ld: /home/rust/src/target/x86_64-unknown-linux-musl/release/deps/audioserve-ab76b24750bd4658: hidden symbol `__dso_handle' isn't defined                                                  
          /usr/bin/ld: final link failed: Bad value                                                                                                                                                          
          collect2: error: ld returned 1 exit status  

My question is if somebody has experiences with using C++ library in static build, if I'm doing something wrong or if there are any recommendation how to process, I'm not much expert on c/c++, I saw that possibily of custom build script, but I guess it'll still not solve the problem with second symbol __sprintf_chk.

Thanks

How do you statically link libraries?

I'm using a multi build docker file to try to create a docker image with nothing but the binary in it. Unfortunately I'm left with a large number of dynamic links.

Dockerfile:

#########
# Build #
#########
FROM ekidd/rust-musl-builder AS builder

RUN sudo apt-get update \
 && sudo apt-get install -y \
    libmysqlclient-dev

WORKDIR /build

RUN sudo chown rust:rust .

COPY src src
COPY Cargo.toml .
COPY Cargo.lock .
COPY diesel.toml .

RUN cargo build --release

##############
# Executable #
##############
FROM scratch

WORKDIR /app

COPY --from=builder /build/target/x86_64-unknown-linux-musl/release/webserver webserver

EXPOSE 8080

CMD ["/app/webserver"]

However, if I test the binary after building:

$ ldd target/x86_64-unknown-linux-musl/release/webserver
        linux-vdso.so.1 =>  (0x00007fff33df6000)
        libmysqlclient.so.20 => /usr/lib/x86_64-linux-gnu/libmysqlclient.so.20 (0x00007f41a7252000)
        libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f41a7038000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f41a6e34000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f41a6c17000)
        libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f41a6895000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f41a658c000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f41a6376000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f41a5fac000)
        /lib/ld64.so.1 => /lib64/ld-linux-x86-64.so.2 (0x00007f41a7861000)

I feel like others must have gone through this but I can't find any sort of guide written down anywhere (my google foo is bad though so ๐Ÿคท๐Ÿปโ€โ™‚๏ธ).

I feel esspecially silly as I think I was able to do this about nine months ago (with very basic apps at least). ๐Ÿ˜Š

Is there a process I can go through to manage static linking? Perhaps a step by step guide?

`diesel` link order issues sometimes break build

Trying to build with the using-diesel example fails. Here is snippet of error:

error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-Wl,--eh-frame-hdr" "-m64" "-nostdlib" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/crt1.o" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/crti.o" "-L" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/using_diesel-94aa5cadffcea30e.using_diesel.dqcexic7-cgu.0.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/using_diesel-94aa5cadffcea30e.using_diesel.dqcexic7-cgu.1.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/using_diesel-94aa5cadffcea30e.using_diesel.dqcexic7-cgu.10.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/using_diesel-94aa5cadffcea30e.using_diesel.dqcexic7-cgu.11.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/using_diesel-94aa5cadffcea30e.using_diesel.dqcexic7-cgu.12.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/using_diesel-94aa5cadffcea30e.using_diesel.dqcexic7-cgu.13.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/using_diesel-94aa5cadffcea30e.using_diesel.dqcexic7-cgu.14.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/using_diesel-94aa5cadffcea30e.using_diesel.dqcexic7-cgu.15.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/using_diesel-94aa5cadffcea30e.using_diesel.dqcexic7-cgu.2.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/using_diesel-94aa5cadffcea30e.using_diesel.dqcexic7-cgu.3.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/using_diesel-94aa5cadffcea30e.using_diesel.dqcexic7-cgu.4.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/using_diesel-94aa5cadffcea30e.using_diesel.dqcexic7-cgu.5.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/using_diesel-94aa5cadffcea30e.using_diesel.dqcexic7-cgu.6.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/using_diesel-94aa5cadffcea30e.using_diesel.dqcexic7-cgu.7.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/using_diesel-94aa5cadffcea30e.using_diesel.dqcexic7-cgu.8.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/using_diesel-94aa5cadffcea30e.using_diesel.dqcexic7-cgu.9.rcgu.o" "-o" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/using_diesel-94aa5cadffcea30e" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/using_diesel-94aa5cadffcea30e.3n7t9phqceru8m8i.rcgu.o" "-Wl,--gc-sections" "-no-pie" "-Wl,-zrelro" "-Wl,-znow" "-Wl,-O1" "-nodefaultlibs" "-L" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps" "-L" "/home/rust/src/target/release/deps" "-L" "/home/rust/src/target/x86_64-unknown-linux-musl/release/build/libsqlite3-sys-ac3cf7454f406832/out" "-L" "/usr/local/musl/lib" "-L" "/usr/local/musl/lib/" "-L" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib" "-Wl,-Bstatic" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/libopenssl-0de50740ee181784.rlib" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/libopenssl_sys-89c6410693b927d6.rlib" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/liblibc-6265db6daf6f0d94.rlib" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/liblazy_static-5cac84b776fcd98b.rlib" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/libforeign_types-23f459ebafab2c61.rlib" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/libforeign_types_shared-1eba4aeaa81c6d19.rlib" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/libdiesel-c89a5a6bebad19a9.rlib" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/liblibsqlite3_sys-818909750b3afa36.rlib" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/libpq_sys-dc85b10baeb00fc3.rlib" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/libbyteorder-9272cb6794a9382c.rlib" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/libbitflags-b8224b03590c6c21.rlib" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libstd-af9362ed5d81a840.rlib" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libpanic_unwind-4d55a38564aae54a.rlib" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libbacktrace_sys-f8521075e248b627.rlib" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libunwind-7c91ffdc8da860d3.rlib" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/librustc_demangle-0ad27b9879d551d3.rlib" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/liblibc-588f18eae3ea58be.rlib" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/liballoc-4ebf5caee903d98f.rlib" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/librustc_std_workspace_core-8895b32baedb08c6.rlib" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libcore-6a9d233d01acc350.rlib" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libcompiler_builtins-851bb3b5f6c4db49.rlib" "-Wl,-Bdynamic" "-lpq" "-static" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/crtn.o"
  = note: /usr/local/musl/lib/libpq.a(fe-connect.o): In function `connectFailureMessage':
          fe-connect.c:(.text+0xa12): undefined reference to `strlcpy'
          /usr/local/musl/lib/libpq.a(fe-connect.o): In function `internal_cancel':
          fe-connect.c:(.text+0xca9): undefined reference to `htonl'
          fe-connect.c:(.text+0xcb7): undefined reference to `htonl'
          fe-connect.c:(.text+0xcc4): undefined reference to `htonl'
          fe-connect.c:(.text+0xcd1): undefined reference to `htonl'
          fe-connect.c:(.text+0xd6e): undefined reference to `strlcpy'
          fe-connect.c:(.text+0xd9e): undefined reference to `strncat'
          fe-connect.c:(.text+0xdde): undefined reference to `strlcpy'
          fe-connect.c:(.text+0xdfa): undefined reference to `strlcpy'
          fe-connect.c:(.text+0xe26): undefined reference to `strncat'
          /usr/local/musl/lib/libpq.a(fe-connect.o): In function `PQcancel':
          fe-connect.c:(.text+0x1462): undefined reference to `strlcpy'
          /usr/local/musl/lib/libpq.a(fe-connect.o): In function `PQrequestCancel':
          fe-connect.c:(.text+0x14f0): undefined reference to `strlcpy'
          /usr/local/musl/lib/libpq.a(fe-connect.o): In function `PQsetClientEncoding':
          fe-connect.c:(.text+0x1a71): undefined reference to `sprintf'
          /usr/local/musl/lib/libpq.a(fe-connect.o): In function `pqGetHomeDirectory':
          fe-connect.c:(.text+0x1c81): undefined reference to `strlcpy'
          /usr/local/musl/lib/libpq.a(fe-connect.o): In function `parseServiceInfo':
          fe-connect.c:(.text+0x1d1e): undefined reference to `strlcpy'
          /usr/local/musl/lib/libpq.a(fe-connect.o): In function `getPgPassFilename':
          fe-connect.c:(.text+0x2c11): undefined reference to `strlcpy'
          /usr/local/musl/lib/libpq.a(fe-connect.o): In function `PasswordFromFile':
          fe-connect.c:(.text+0x2d1c): undefined reference to `feof'
          /usr/local/musl/lib/libpq.a(fe-connect.o): In function `PQconnectPoll':
          fe-connect.c:(.text+0x3969): undefined reference to `htonl'
          /usr/local/musl/lib/libpq.a(fe-connect.o): In function `defaultNoticeProcessor':
          fe-connect.c:(.text+0xee): undefined reference to `fputs'
          /usr/local/musl/lib/libpq.a(fe-exec.o): In function `pqInternalNotice':
          fe-exec.c:(.text+0x1256): undefined reference to `sprintf'
          /usr/local/musl/lib/libpq.a(fe-exec.o): In function `pqSaveParameterStatus':
          fe-exec.c:(.text+0x1964): undefined reference to `sscanf'
          /usr/local/musl/lib/libpq.a(fe-exec.o): In function `PQoidStatus':
          fe-exec.c:(.text+0x3a11): undefined reference to `strspn'
          /usr/local/musl/lib/libpq.a(fe-misc.o): In function `pqGetnchar':
          fe-misc.c:(.text+0x3ac): undefined reference to `fputc'
          fe-misc.c:(.text+0x3c6): undefined reference to `fputc'
          /usr/local/musl/lib/libpq.a(fe-misc.o): In function `pqSkipnchar':
          fe-misc.c:(.text+0x454): undefined reference to `fputc'
          fe-misc.c:(.text+0x46f): undefined reference to `fputc'
          /usr/local/musl/lib/libpq.a(fe-misc.o): In function `pqGetInt':
          fe-misc.c:(.text+0x4ec): undefined reference to `ntohl'
          fe-misc.c:(.text+0x58a): undefined reference to `ntohs'
          /usr/local/musl/lib/libpq.a(fe-misc.o): In function `pqPutnchar':
          fe-misc.c:(.text+0x7dc): undefined reference to `fputc'
          fe-misc.c:(.text+0x7f6): undefined reference to `fputc'
          /usr/local/musl/lib/libpq.a(fe-misc.o): In function `pqPutInt':
          fe-misc.c:(.text+0x881): undefined reference to `htonl'
          /usr/local/musl/lib/libpq.a(fe-misc.o): In function `pqPutMsgEnd':
          fe-misc.c:(.text+0xf9d): undefined reference to `htonl'
          /usr/local/musl/lib/libpq.a(fe-protocol2.o): In function `pqSetenvPoll':
          fe-protocol2.c:(.text+0xa59): undefined reference to `sprintf'
          fe-protocol2.c:(.text+0xb90): undefined reference to `sprintf'
          fe-protocol2.c:(.text+0xbb0): undefined reference to `sprintf'
          /usr/local/musl/lib/libpq.a(fe-protocol2.o): In function `pqParseInput2':
          fe-protocol2.c:(.text+0xde8): undefined reference to `strlcpy'
          /usr/local/musl/lib/libpq.a(fe-protocol2.o): In function `pqBuildStartupPacket2':
          fe-protocol2.c:(.text+0x1bad): undefined reference to `htonl'
          /usr/local/musl/lib/libpq.a(fe-protocol3.o): In function `build_startup_packet':
          fe-protocol3.c:(.text+0x4b3): undefined reference to `htonl'
          /usr/local/musl/lib/libpq.a(fe-protocol3.o): In function `pqGetErrorNotice3':
          fe-protocol3.c:(.text+0x11f7): undefined reference to `strlcpy'
          /usr/local/musl/lib/libpq.a(fe-protocol3.o): In function `pqParseInput3':
          fe-protocol3.c:(.text+0x19a8): undefined reference to `strlcpy'
          /usr/local/musl/lib/libpq.a(fe-secure.o): In function `pq_block_sigpipe':
          fe-secure.c:(.text+0x19c): undefined reference to `sigaddset'
          fe-secure.c:(.text+0x1c6): undefined reference to `sigismember'
          fe-secure.c:(.text+0x20c): undefined reference to `sigpending'
          fe-secure.c:(.text+0x21f): undefined reference to `sigismember'
          /usr/local/musl/lib/libpq.a(fe-secure.o): In function `pq_reset_sigpipe':
          fe-secure.c:(.text+0x288): undefined reference to `sigpending'
          fe-secure.c:(.text+0x2d1): undefined reference to `sigismember'
          fe-secure.c:(.text+0x2f2): undefined reference to `sigaddset'
          fe-secure.c:(.text+0x2ff): undefined reference to `sigwait'
          /usr/local/musl/lib/libpq.a(chklocale.o): In function `pg_get_encoding_from_locale':
          chklocale.c:(.text+0x50): undefined reference to `setlocale'
          chklocale.c:(.text+0x77): undefined reference to `setlocale'
          chklocale.c:(.text+0x8a): undefined reference to `nl_langinfo'
          chklocale.c:(.text+0xa7): undefined reference to `setlocale'
          chklocale.c:(.text+0x115): undefined reference to `setlocale'
          chklocale.c:(.text+0x159): undefined reference to `nl_langinfo'
          chklocale.c:(.text+0x1ba): undefined reference to `fputc'
          /usr/local/musl/lib/libpq.a(inet_net_ntop.o): In function `inet_net_ntop':
          inet_net_ntop.c:(.text+0xd3): undefined reference to `sprintf'
          inet_net_ntop.c:(.text+0x10b): undefined reference to `sprintf'
          inet_net_ntop.c:(.text+0x324): undefined reference to `sprintf'
          inet_net_ntop.c:(.text+0x3c4): undefined reference to `sprintf'
          inet_net_ntop.c:(.text+0x41b): undefined reference to `sprintf'
          /usr/local/musl/lib/libpq.a(ip.o): In function `pg_getnameinfo_all':
          ip.c:(.text+0x281): undefined reference to `getnameinfo'
          ip.c:(.text+0x2a7): undefined reference to `strlcpy'
          ip.c:(.text+0x2be): undefined reference to `strlcpy'
          /usr/local/musl/lib/libpq.a(ip.o): In function `pg_sockaddr_cidr_mask':
          ip.c:(.text+0x46f): undefined reference to `htonl'
          /usr/local/musl/lib/libpq.a(ip.o): In function `pg_foreach_ifaddr':
          ip.c:(.text+0x5ce): undefined reference to `getifaddrs'
          ip.c:(.text+0x65e): undefined reference to `freeifaddrs'
          /usr/local/musl/lib/libpq.a(fe-secure-openssl.o): In function `SSLerrmessage':
          fe-secure-openssl.c:(.text+0x38): undefined reference to `ERR_reason_error_string'
          fe-secure-openssl.c:(.text+0x4d): undefined reference to `strlcpy'
          /usr/local/musl/lib/libpq.a(fe-secure-openssl.o): In function `initialize_SSL':
          fe-secure-openssl.c:(.text+0x122): undefined reference to `SSLv23_method'
          fe-secure-openssl.c:(.text+0x12a): undefined reference to `SSL_CTX_new'
          fe-secure-openssl.c:(.text+0x14a): undefined reference to `SSL_CTX_ctrl'
          fe-secure-openssl.c:(.text+0x15e): undefined reference to `SSL_CTX_ctrl'
          fe-secure-openssl.c:(.text+0x1c8): undefined reference to `SSL_new'
          fe-secure-openssl.c:(.text+0x1e5): undefined reference to `SSL_set_ex_data'
          fe-secure-openssl.c:(.text+0x209): undefined reference to `BIO_new'
          fe-secure-openssl.c:(.text+0x22d): undefined reference to `SSL_set_bio'
          fe-secure-openssl.c:(.text+0x244): undefined reference to `BIO_int_ctrl'
          fe-secure-openssl.c:(.text+0x253): undefined reference to `SSL_CTX_free'
          fe-secure-openssl.c:(.text+0x2bc): undefined reference to `ENGINE_by_id'
          fe-secure-openssl.c:(.text+0x2d4): undefined reference to `ENGINE_init'
          fe-secure-openssl.c:(.text+0x2ef): undefined reference to `ENGINE_load_private_key'
          fe-secure-openssl.c:(.text+0x307): undefined reference to `SSL_use_PrivateKey'
          fe-secure-openssl.c:(.text+0x405): undefined reference to `ERR_put_error'
          fe-secure-openssl.c:(.text+0x40a): undefined reference to `ERR_get_error'
          fe-secure-openssl.c:(.text+0x44e): undefined reference to `SSL_CTX_free'
          fe-secure-openssl.c:(.text+0x471): undefined reference to `strlcpy'
          fe-secure-openssl.c:(.text+0x4e9): undefined reference to `strlcpy'
          fe-secure-openssl.c:(.text+0x5b1): undefined reference to `SSL_check_private_key'
          fe-secure-openssl.c:(.text+0x5bf): undefined reference to `ERR_get_error'
          fe-secure-openssl.c:(.text+0x619): undefined reference to `SSL_CTX_load_verify_locations'
          fe-secure-openssl.c:(.text+0x62a): undefined reference to `SSL_CTX_get_cert_store'
          fe-secure-openssl.c:(.text+0x661): undefined reference to `ERR_clear_error'
          fe-secure-openssl.c:(.text+0x6a9): undefined reference to `ERR_get_error'
          fe-secure-openssl.c:(.text+0x6fc): undefined reference to `SSL_set_verify'
          fe-secure-openssl.c:(.text+0x715): undefined reference to `SSL_CTX_use_certificate_chain_file'
          fe-secure-openssl.c:(.text+0x723): undefined reference to `ERR_get_error'
          fe-secure-openssl.c:(.text+0x7b4): undefined reference to `SSL_ctrl'
          fe-secure-openssl.c:(.text+0x834): undefined reference to `SSL_use_PrivateKey_file'
          fe-secure-openssl.c:(.text+0x842): undefined reference to `ERR_get_error'
          fe-secure-openssl.c:(.text+0x8a1): undefined reference to `BIO_s_socket'
          fe-secure-openssl.c:(.text+0x954): undefined reference to `strlcpy'
          fe-secure-openssl.c:(.text+0x969): undefined reference to `strlcpy'
          fe-secure-openssl.c:(.text+0x984): undefined reference to `X509_STORE_load_locations'
          fe-secure-openssl.c:(.text+0x99a): undefined reference to `X509_STORE_set_flags'
          fe-secure-openssl.c:(.text+0x9d1): undefined reference to `ERR_get_error'
          fe-secure-openssl.c:(.text+0xa1a): undefined reference to `ENGINE_finish'
          fe-secure-openssl.c:(.text+0xa26): undefined reference to `ENGINE_free'
          fe-secure-openssl.c:(.text+0xa75): undefined reference to `ERR_get_error'
          fe-secure-openssl.c:(.text+0xa9e): undefined reference to `ERR_get_error'
          fe-secure-openssl.c:(.text+0xb08): undefined reference to `ERR_get_error'
          fe-secure-openssl.c:(.text+0xb6d): undefined reference to `ERR_get_error'
          /usr/local/musl/lib/libpq.a(fe-secure-openssl.o): In function `verify_peer_name_matches_certificate_name':
          fe-secure-openssl.c:(.text+0xbc5): undefined reference to `ASN1_STRING_data'
          fe-secure-openssl.c:(.text+0xbd0): undefined reference to `ASN1_STRING_length'
          /usr/local/musl/lib/libpq.a(fe-secure-openssl.o): In function `my_sock_write':
          fe-secure-openssl.c:(.text+0xdb1): undefined reference to `BIO_clear_flags'
          fe-secure-openssl.c:(.text+0xde2): undefined reference to `BIO_set_flags'
          /usr/local/musl/lib/libpq.a(fe-secure-openssl.o): In function `my_sock_read':
          fe-secure-openssl.c:(.text+0xe11): undefined reference to `BIO_clear_flags'
          fe-secure-openssl.c:(.text+0xe42): undefined reference to `BIO_set_flags'
          /usr/local/musl/lib/libpq.a(fe-secure-openssl.o): In function `pgtls_read_pending':
          fe-secure-openssl.c:(.text+0xeec): undefined reference to `SSL_pending'
          /usr/local/musl/lib/libpq.a(fe-secure-openssl.o): In function `pgtls_read':
          fe-secure-openssl.c:(.text+0xf4a): undefined reference to `ERR_clear_error'
          fe-secure-openssl.c:(.text+0xf5d): undefined reference to `SSL_read'
          fe-secure-openssl.c:(.text+0xf6e): undefined reference to `SSL_get_error'
          fe-secure-openssl.c:(.text+0xfa1): undefined reference to `ERR_get_error'
          /usr/local/musl/lib/libpq.a(fe-secure-openssl.o): In function `pgtls_write':
          fe-secure-openssl.c:(.text+0x11b8): undefined reference to `ERR_clear_error'
          fe-secure-openssl.c:(.text+0x11ca): undefined reference to `SSL_write'
          fe-secure-openssl.c:(.text+0x11db): undefined reference to `SSL_get_error'
          fe-secure-openssl.c:(.text+0x1211): undefined reference to `ERR_get_error'
          /usr/local/musl/lib/libpq.a(fe-secure-openssl.o): In function `pgtls_init':
          fe-secure-openssl.c:(.text+0x1461): undefined reference to `CRYPTO_get_id_callback'
          fe-secure-openssl.c:(.text+0x146f): undefined reference to `CRYPTO_get_locking_callback'
          fe-secure-openssl.c:(.text+0x1480): undefined reference to `CRYPTO_set_locking_callback'
          fe-secure-openssl.c:(.text+0x1493): undefined reference to `OPENSSL_config'
          fe-secure-openssl.c:(.text+0x1498): undefined reference to `SSL_library_init'
          fe-secure-openssl.c:(.text+0x149d): undefined reference to `SSL_load_error_strings'
          fe-secure-openssl.c:(.text+0x14b1): undefined reference to `CRYPTO_num_locks'
          fe-secure-openssl.c:(.text+0x14dc): undefined reference to `CRYPTO_num_locks'
          fe-secure-openssl.c:(.text+0x153a): undefined reference to `CRYPTO_set_id_callback'
          /usr/local/musl/lib/libpq.a(fe-secure-openssl.o): In function `pgtls_close':
          fe-secure-openssl.c:(.text+0x1568): undefined reference to `SSL_shutdown'
          fe-secure-openssl.c:(.text+0x1579): undefined reference to `SSL_free'
          fe-secure-openssl.c:(.text+0x159c): undefined reference to `X509_free'
          fe-secure-openssl.c:(.text+0x15b8): undefined reference to `ENGINE_finish'
          fe-secure-openssl.c:(.text+0x15c4): undefined reference to `ENGINE_free'
          fe-secure-openssl.c:(.text+0x1631): undefined reference to `CRYPTO_get_locking_callback'
          fe-secure-openssl.c:(.text+0x1642): undefined reference to `CRYPTO_get_id_callback'
          fe-secure-openssl.c:(.text+0x1655): undefined reference to `CRYPTO_set_id_callback'
          fe-secure-openssl.c:(.text+0x165e): undefined reference to `CRYPTO_set_locking_callback'
          /usr/local/musl/lib/libpq.a(fe-secure-openssl.o): In function `pgtls_open_client':
          fe-secure-openssl.c:(.text+0x16a6): undefined reference to `ERR_clear_error'
          fe-secure-openssl.c:(.text+0x16b2): undefined reference to `SSL_connect'
          fe-secure-openssl.c:(.text+0x16c8): undefined reference to `SSL_get_peer_certificate'
          fe-secure-openssl.c:(.text+0x1773): undefined reference to `SSL_get_error'
          fe-secure-openssl.c:(.text+0x177b): undefined reference to `ERR_get_error'
          fe-secure-openssl.c:(.text+0x183d): undefined reference to `X509_get_ext_d2i'
          fe-secure-openssl.c:(.text+0x1851): undefined reference to `sk_num'
          fe-secure-openssl.c:(.text+0x188c): undefined reference to `sk_value'
          fe-secure-openssl.c:(.text+0x18ed): undefined reference to `sk_free'
          fe-secure-openssl.c:(.text+0x1931): undefined reference to `ERR_get_error'
          fe-secure-openssl.c:(.text+0x19cc): undefined reference to `sk_free'
          fe-secure-openssl.c:(.text+0x1a2d): undefined reference to `sk_free'
          fe-secure-openssl.c:(.text+0x1a40): undefined reference to `X509_get_subject_name'
          fe-secure-openssl.c:(.text+0x1a5e): undefined reference to `X509_NAME_get_index_by_NID'
          fe-secure-openssl.c:(.text+0x1a7a): undefined reference to `X509_NAME_get_entry'
          fe-secure-openssl.c:(.text+0x1a82): undefined reference to `X509_NAME_ENTRY_get_data'
          fe-secure-openssl.c:(.text+0x1b6d): undefined reference to `X509_get_subject_name'
          fe-secure-openssl.c:(.text+0x1b85): undefined reference to `X509_NAME_get_index_by_NID'
          /usr/local/musl/lib/libpq.a(fe-secure-openssl.o): In function `PQsslAttribute':
          fe-secure-openssl.c:(.text+0x1ce3): undefined reference to `SSL_get_version'
          fe-secure-openssl.c:(.text+0x1d04): undefined reference to `SSL_get_current_cipher'
          fe-secure-openssl.c:(.text+0x1d11): undefined reference to `SSL_CIPHER_get_bits'
          fe-secure-openssl.c:(.text+0x1d44): undefined reference to `SSL_get_current_compression'
          fe-secure-openssl.c:(.text+0x1d64): undefined reference to `SSL_get_current_cipher'
          fe-secure-openssl.c:(.text+0x1d6c): undefined reference to `SSL_CIPHER_get_name'
          /usr/local/musl/lib/libpq.a(fe-secure-openssl.o): In function `pq_threadidcallback':
          fe-secure-openssl.c:(.text+0xd81): undefined reference to `pthread_self'
          collect2: error: ld returned 1 exit status
          

error: aborting due to previous error

error: Could not compile `using-diesel`.

Binary not static

Hi,

for a while i was using rust-musl-builder as a git submodule. So I did not update.
I tried to update to master and now my binary is no longer static. (same with the dockerhub version)

ยป file target/x86_64-unknown-linux-musl/release/fw                                                                                                                                                                                                     
target/x86_64-unknown-linux-musl/release/fw: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib/ld64.so.1, BuildID[sha1]=bc7437143885536c8640f165e4fccbc4fdaf2ff9, with debug_info, not stripped

Here is my repo https://github.com/brocode/fw

With commit 8ea04b5f166b18dfa4bd5c49c771e2598284f87f everything works fine.

404 not found when using with rust-embeded

Hello, I have a project with these dependencies

[package]
name = "acs_server"
version = "0.1.0"
authors = ["Cheng JIANG <[email protected]>"]
license-file = "LICENSE"
description = "Access Control Server"
edition = "2018"
build = "build.rs"

[dependencies]
actix = "0.7.9"
actix-web = { version = "0.7.18", features = ["ssl"] }
diesel = { version = "1.4.2", features = ["r2d2", "postgres", "chrono", "uuid"] }
futures = "0.1.25"
env_logger = "0.6.0"
log = "0.4.6"
openssl = "0.10"
toml = "0.4.10"
failure = "0.1.5"
serde_derive = "1.0.85"
serde = "1.0.85"
serde_json = "1.0.37"
rust-embed = "4.3.0"
mime_guess = "2.0.0-alpha.6"
clap = { version = "2.32.0", features = ["yaml"] }
uuid = { version = "0.7", features = ["serde", "v4"] }
r2d2 = "0.8.3"
num_cpus = "1.0"
chrono = { version = "0.4", features = ["serde"] }
bcrypt = "0.2.0"
validator = "0.8.0"
validator_derive = "0.8.0"
exit = "0.1.0"
lazy_static = "1.2.0"
regex = "1"
jsonwebtoken = "^5.0.1"
md5 = "0.6.0"
ring = "0.13.5"
derive_builder = "0.5.1"
actix-web-httpauth = "0.1.0"
base64 = "^0.8.0"
askama = { version = "^0.8.0", features = ["with-actix-web"] }
percent-encoding = "1.0.1"
globset = "0.3"

[build-dependencies]
failure = "0.1.5"

I did this in Makefile to compile it into static, It works fine and I get a static binary, this binary can also work on my PC (ubuntu18.10), but when I upload it to a public server (ubuntu18.04).

        if [ ! "$(shell docker image ls | grep muslrust)" ]; then \
		docker pull clux/muslrust ;\
	fi ;\
	echo "$(GREEN)=> building...$(END)" && \
	docker run -v "$(shell pwd)":/volume -v cargo-cache:/root/.cargo/registry --rm -t clux/muslrust cargo build --manifest-path=server/Cargo.toml

It can start without error but it cannot load my VueJs client anymore, the client is compiled into this binary.

Then I switch to use cargo build --release and upload the new dynamic binary to my public server, it works and succeed to load static files (which has been embeded into the binary).

Unable to use native netlink library from libc crate?

Attempting to a compile a crate that has a dependency on the netstat library which uses the native netlink API causes a bunch of errors like:

error[E0412]: cannot find type `nlmsghdr` in this scope
error[E0425]: cannot find value `NETLINK_INET_DIAG` in this scope                                                                             
error[E0063]: missing fields `__pad1`, `__pad2` in initializer of `libc::msghdr`                                                              

Which leads me to believe that parts of the libc crate are not being linked in correctly? Trying to understand this issue.

Rust 1.18

Could you republish your image to DockerHub now that Rust 1.18 has been released?

Rust 1.21.0 & diesel_codegen: "undefined symbol: SSL_set_ex_data"

When cross-compiling using diesel_codegen and Rust 1.21.0, I get the following error:

   Compiling using-diesel v0.1.0 (file:///home/rust/src)
error: /home/rust/src/target/release/deps/libdiesel_codegen-61cdddf775bc61b4.so: undefined symbol: SSL_set_ex_data
 --> src/main.rs:4:1
  |
4 | extern crate diesel_codegen;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: Could not compile `using-diesel`.

This appears to be caused by rust-lang/rust#43486 and sgrif/pq-sys#18.

Workaround: Use FROM ekidd/rust-musl-builder:1.20.0 if you need to use diesel before sgrif/pq-sys#18 gets fixed.

No toolchain installed when running from within the container

Whenever I try to build my project from the drone ci inside this docker image - it says:

error: no default toolchain configured

The project compiles fine on my desktop machine with the alias proposed in the README but if I try to create my own image based on this one I have this error. Then I add the toolchains and the project build can be started but it does not compile because of libpq and so on, however, again, on my desktop machine it compiles successfully. What is the problem?

Unable to find crate libc

My project builds normally on my system but fails within the docker container with the following error:

error[E0463]: can't find crate for `libc`
  --> /home/rust/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.4.2/src/os.rs:75:5
   |
75 |     extern crate libc;
   |     ^^^^^^^^^^^^^^^^^^ can't find crate

error: aborting due to previous error

Here's a full log of the compilation. I've seen this happen with other crates too, not just rand. I've tried this on various tags of the docker image (in some older versions it isn't always libc that cannot be found) to no success.

Unable to build diesel_cli with postgres feature flag

I am trying to build diesel_cli but got an error from the builder as the following:

   Compiling diesel_cli v1.1.0 (file:///home/rust/diesel/diesel_cli)
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-nostdlib" "-Wl,--eh-frame-hdr" "-Wl,-(" "-m64" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/crt1.o" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/crti.o" "-L" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/diesel-7a4a0e167a1797f2.diesel0-26d4766fabdab83b8419777d549f1645.rs.rcgu.o" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/diesel-7a4a0e167a1797f2.diesel1-26d4766fabdab83b8419777d549f1645.rs.rcgu.o" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/diesel-7a4a0e167a1797f2.diesel10-26d4766fabdab83b8419777d549f1645.rs.rcgu.o" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/diesel-7a4a0e167a1797f2.diesel11-26d4766fabdab83b8419777d549f1645.rs.rcgu.o" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/diesel-7a4a0e167a1797f2.diesel12-26d4766fabdab83b8419777d549f1645.rs.rcgu.o" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/diesel-7a4a0e167a1797f2.diesel13-26d4766fabdab83b8419777d549f1645.rs.rcgu.o" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/diesel-7a4a0e167a1797f2.diesel14-26d4766fabdab83b8419777d549f1645.rs.rcgu.o" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/diesel-7a4a0e167a1797f2.diesel15-26d4766fabdab83b8419777d549f1645.rs.rcgu.o" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/diesel-7a4a0e167a1797f2.diesel2-26d4766fabdab83b8419777d549f1645.rs.rcgu.o" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/diesel-7a4a0e167a1797f2.diesel3-26d4766fabdab83b8419777d549f1645.rs.rcgu.o" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/diesel-7a4a0e167a1797f2.diesel4-26d4766fabdab83b8419777d549f1645.rs.rcgu.o" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/diesel-7a4a0e167a1797f2.diesel5-26d4766fabdab83b8419777d549f1645.rs.rcgu.o" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/diesel-7a4a0e167a1797f2.diesel6-26d4766fabdab83b8419777d549f1645.rs.rcgu.o" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/diesel-7a4a0e167a1797f2.diesel7-26d4766fabdab83b8419777d549f1645.rs.rcgu.o" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/diesel-7a4a0e167a1797f2.diesel8-26d4766fabdab83b8419777d549f1645.rs.rcgu.o" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/diesel-7a4a0e167a1797f2.diesel9-26d4766fabdab83b8419777d549f1645.rs.rcgu.o" "-o" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/diesel-7a4a0e167a1797f2" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/diesel-7a4a0e167a1797f2.crate.allocator.rcgu.o" "-Wl,--gc-sections" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-nodefaultlibs" "-L" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps" "-L" "/home/rust/diesel/target/release/deps" "-L" "/usr/local/musl/lib" "-L" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/build/backtrace-sys-235db71ab7b9d38f/out/.libs" "-L" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib" "-Wl,-Bstatic" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/libchrono-6f107524b3609d73.rlib" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/libnum-5d443b635c3204fc.rlib" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/libnum_iter-04494746af2d9a99.rlib" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/libmigrations_internals-2abdb121d2c25d09.rlib" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/libnum_integer-f38f3bc5cea5ccfd.rlib" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/libinfer_schema_internals-01a02896b7fb2c48.rlib" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/libdiesel-8872bace061b6510.rlib" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/libpq_sys-e7bfd413cb1fe413.rlib" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/libtime-d949784cd9141faa.rlib" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/libnum_traits-1fcc7c193263026c.rlib" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/libclap-0abcfd1cb1a2830a.rlib" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/libvec_map-d94c8bd06610ebfc.rlib" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/libtextwrap-6ac523702c4d5e28.rlib" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/libstrsim-ecaf9974da60c7b7.rlib" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/libatty-1e80113c789e048b.rlib" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/libansi_term-9cc451663117f964.rlib" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/libbitflags-89752eb3a69646d1.rlib" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/libunicode_width-0a3c6c3b404e265c.rlib" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/libbyteorder-4edb820ad62e5d17.rlib" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/libdotenv-f10f395943e7a050.rlib" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/libregex-67af8c4317e580d7.rlib" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/libregex_syntax-ab898a4a92f87f4a.rlib" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/libthread_local-2514ac82137de196.rlib" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/liblazy_static-f19884f0179dfcc3.rlib" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/libunreachable-96ccfcf2ec3a0294.rlib" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/libaho_corasick-9de61f9422c2df04.rlib" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/liberror_chain-b9bdb6d863ec6a81.rlib" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/libbacktrace-cb57c62f474f9259.rlib" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/libbacktrace_sys-16fb65e0bd7dd06e.rlib" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/librustc_demangle-5c6a466f6c283a05.rlib" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/libcfg_if-c9d5e1d6a61c169b.rlib" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/libmemchr-634ae2b7dfc91771.rlib" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/liblibc-2c1ec03e054bb4f8.rlib" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/libvoid-2070cd511b734eab.rlib" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/libutf8_ranges-85040a39209847a7.rlib" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/liburl-6da23519f6669722.rlib" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/libpercent_encoding-c24a794a1a2126c9.rlib" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/libidna-c8fdb9d55962e8be.rlib" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/libunicode_normalization-6b203d3395d3f5dd.rlib" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/libunicode_bidi-ce3e14d8ea28b64c.rlib" "/home/rust/diesel/target/x86_64-unknown-linux-musl/release/deps/libmatches-bc33109da41c0e78.rlib" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libstd-b0da19f2d692501d.rlib" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libpanic_unwind-242eaced57051917.rlib" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libunwind-6331842fea676519.rlib" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/liballoc_jemalloc-26f7e4cbe93f7672.rlib" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/liballoc_system-133ce0bbc9bd63ed.rlib" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/liblibc-8e0555f144f880a6.rlib" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/liballoc-86980ccd7d424d3c.rlib" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libstd_unicode-c637fe1b1e39daa3.rlib" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libcore-5c39c43032358f5e.rlib" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libcompiler_builtins-3b0ffcc5dfdf46ec.rlib" "-Wl,-Bdynamic" "-l" "pq" "-static" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/crtn.o" "-Wl,-)"
  = note: /usr/local/musl/lib/libpq.a(fe-secure-openssl.o): In function `SSLerrmessage':
          fe-secure-openssl.c:(.text+0x38): undefined reference to `ERR_reason_error_string'
          /usr/local/musl/lib/libpq.a(fe-secure-openssl.o): In function `initialize_SSL':
          fe-secure-openssl.c:(.text+0x122): undefined reference to `SSLv23_method'
          fe-secure-openssl.c:(.text+0x12a): undefined reference to `SSL_CTX_new'
          fe-secure-openssl.c:(.text+0x14a): undefined reference to `SSL_CTX_ctrl'
          fe-secure-openssl.c:(.text+0x15e): undefined reference to `SSL_CTX_ctrl'
          fe-secure-openssl.c:(.text+0x1c8): undefined reference to `SSL_new'
          fe-secure-openssl.c:(.text+0x1e5): undefined reference to `SSL_set_ex_data'
          fe-secure-openssl.c:(.text+0x209): undefined reference to `BIO_new'
          fe-secure-openssl.c:(.text+0x22d): undefined reference to `SSL_set_bio'
          fe-secure-openssl.c:(.text+0x244): undefined reference to `BIO_int_ctrl'
          fe-secure-openssl.c:(.text+0x253): undefined reference to `SSL_CTX_free'
          fe-secure-openssl.c:(.text+0x2bc): undefined reference to `ENGINE_by_id'
          fe-secure-openssl.c:(.text+0x2d4): undefined reference to `ENGINE_init'
          fe-secure-openssl.c:(.text+0x2ef): undefined reference to `ENGINE_load_private_key'
          fe-secure-openssl.c:(.text+0x307): undefined reference to `SSL_use_PrivateKey'
          fe-secure-openssl.c:(.text+0x405): undefined reference to `ERR_put_error'
          fe-secure-openssl.c:(.text+0x40a): undefined reference to `ERR_get_error'
          fe-secure-openssl.c:(.text+0x44e): undefined reference to `SSL_CTX_free'
          fe-secure-openssl.c:(.text+0x5b1): undefined reference to `SSL_check_private_key'
          fe-secure-openssl.c:(.text+0x5bf): undefined reference to `ERR_get_error'
          fe-secure-openssl.c:(.text+0x619): undefined reference to `SSL_CTX_load_verify_locations'
          fe-secure-openssl.c:(.text+0x62a): undefined reference to `SSL_CTX_get_cert_store'
          fe-secure-openssl.c:(.text+0x661): undefined reference to `ERR_clear_error'
          fe-secure-openssl.c:(.text+0x6a9): undefined reference to `ERR_get_error'
          fe-secure-openssl.c:(.text+0x6fc): undefined reference to `SSL_set_verify'
          fe-secure-openssl.c:(.text+0x715): undefined reference to `SSL_CTX_use_certificate_chain_file'
          fe-secure-openssl.c:(.text+0x723): undefined reference to `ERR_get_error'
          fe-secure-openssl.c:(.text+0x7b4): undefined reference to `SSL_ctrl'
          fe-secure-openssl.c:(.text+0x834): undefined reference to `SSL_use_PrivateKey_file'
          fe-secure-openssl.c:(.text+0x842): undefined reference to `ERR_get_error'
          fe-secure-openssl.c:(.text+0x8a1): undefined reference to `BIO_s_socket'
          fe-secure-openssl.c:(.text+0x984): undefined reference to `X509_STORE_load_locations'
          fe-secure-openssl.c:(.text+0x99a): undefined reference to `X509_STORE_set_flags'
          fe-secure-openssl.c:(.text+0x9d1): undefined reference to `ERR_get_error'
          fe-secure-openssl.c:(.text+0xa1a): undefined reference to `ENGINE_finish'
          fe-secure-openssl.c:(.text+0xa26): undefined reference to `ENGINE_free'
          fe-secure-openssl.c:(.text+0xa75): undefined reference to `ERR_get_error'
          fe-secure-openssl.c:(.text+0xa9e): undefined reference to `ERR_get_error'
          fe-secure-openssl.c:(.text+0xb08): undefined reference to `ERR_get_error'
          fe-secure-openssl.c:(.text+0xb6d): undefined reference to `ERR_get_error'
          /usr/local/musl/lib/libpq.a(fe-secure-openssl.o): In function `verify_peer_name_matches_certificate_name':
          fe-secure-openssl.c:(.text+0xbc5): undefined reference to `ASN1_STRING_data'
          fe-secure-openssl.c:(.text+0xbd0): undefined reference to `ASN1_STRING_length'
          /usr/local/musl/lib/libpq.a(fe-secure-openssl.o): In function `my_sock_write':
          fe-secure-openssl.c:(.text+0xdb1): undefined reference to `BIO_clear_flags'
          fe-secure-openssl.c:(.text+0xde2): undefined reference to `BIO_set_flags'
          /usr/local/musl/lib/libpq.a(fe-secure-openssl.o): In function `my_sock_read':
          fe-secure-openssl.c:(.text+0xe11): undefined reference to `BIO_clear_flags'
          fe-secure-openssl.c:(.text+0xe42): undefined reference to `BIO_set_flags'
          /usr/local/musl/lib/libpq.a(fe-secure-openssl.o): In function `pgtls_read_pending':
          fe-secure-openssl.c:(.text+0xeec): undefined reference to `SSL_pending'
          /usr/local/musl/lib/libpq.a(fe-secure-openssl.o): In function `pgtls_read':
          fe-secure-openssl.c:(.text+0xf4a): undefined reference to `ERR_clear_error'
          fe-secure-openssl.c:(.text+0xf5d): undefined reference to `SSL_read'
          fe-secure-openssl.c:(.text+0xf6e): undefined reference to `SSL_get_error'
          fe-secure-openssl.c:(.text+0xfa1): undefined reference to `ERR_get_error'
          /usr/local/musl/lib/libpq.a(fe-secure-openssl.o): In function `pgtls_write':
          fe-secure-openssl.c:(.text+0x11b8): undefined reference to `ERR_clear_error'
          fe-secure-openssl.c:(.text+0x11ca): undefined reference to `SSL_write'
          fe-secure-openssl.c:(.text+0x11db): undefined reference to `SSL_get_error'
          fe-secure-openssl.c:(.text+0x1211): undefined reference to `ERR_get_error'
          /usr/local/musl/lib/libpq.a(fe-secure-openssl.o): In function `pgtls_init':
          fe-secure-openssl.c:(.text+0x1461): undefined reference to `CRYPTO_get_id_callback'
          fe-secure-openssl.c:(.text+0x146f): undefined reference to `CRYPTO_get_locking_callback'
          fe-secure-openssl.c:(.text+0x1480): undefined reference to `CRYPTO_set_locking_callback'
          fe-secure-openssl.c:(.text+0x1493): undefined reference to `OPENSSL_config'
          fe-secure-openssl.c:(.text+0x1498): undefined reference to `SSL_library_init'
          fe-secure-openssl.c:(.text+0x149d): undefined reference to `SSL_load_error_strings'
          fe-secure-openssl.c:(.text+0x14b1): undefined reference to `CRYPTO_num_locks'
          fe-secure-openssl.c:(.text+0x14dc): undefined reference to `CRYPTO_num_locks'
          fe-secure-openssl.c:(.text+0x153a): undefined reference to `CRYPTO_set_id_callback'
          /usr/local/musl/lib/libpq.a(fe-secure-openssl.o): In function `pgtls_close':
          fe-secure-openssl.c:(.text+0x1568): undefined reference to `SSL_shutdown'
          fe-secure-openssl.c:(.text+0x1579): undefined reference to `SSL_free'
          fe-secure-openssl.c:(.text+0x159c): undefined reference to `X509_free'
          fe-secure-openssl.c:(.text+0x15b8): undefined reference to `ENGINE_finish'
          fe-secure-openssl.c:(.text+0x15c4): undefined reference to `ENGINE_free'
          fe-secure-openssl.c:(.text+0x1631): undefined reference to `CRYPTO_get_locking_callback'
          fe-secure-openssl.c:(.text+0x1642): undefined reference to `CRYPTO_get_id_callback'
          fe-secure-openssl.c:(.text+0x1655): undefined reference to `CRYPTO_set_id_callback'
          fe-secure-openssl.c:(.text+0x165e): undefined reference to `CRYPTO_set_locking_callback'
          /usr/local/musl/lib/libpq.a(fe-secure-openssl.o): In function `pgtls_open_client':
          fe-secure-openssl.c:(.text+0x16a6): undefined reference to `ERR_clear_error'
          fe-secure-openssl.c:(.text+0x16b2): undefined reference to `SSL_connect'
          fe-secure-openssl.c:(.text+0x16c8): undefined reference to `SSL_get_peer_certificate'
          fe-secure-openssl.c:(.text+0x1773): undefined reference to `SSL_get_error'
          fe-secure-openssl.c:(.text+0x177b): undefined reference to `ERR_get_error'
          fe-secure-openssl.c:(.text+0x183d): undefined reference to `X509_get_ext_d2i'
          fe-secure-openssl.c:(.text+0x1851): undefined reference to `sk_num'
          fe-secure-openssl.c:(.text+0x188c): undefined reference to `sk_value'
          fe-secure-openssl.c:(.text+0x18ed): undefined reference to `sk_free'
          fe-secure-openssl.c:(.text+0x1931): undefined reference to `ERR_get_error'
          fe-secure-openssl.c:(.text+0x19cc): undefined reference to `sk_free'
          fe-secure-openssl.c:(.text+0x1a2d): undefined reference to `sk_free'
          fe-secure-openssl.c:(.text+0x1a40): undefined reference to `X509_get_subject_name'
          fe-secure-openssl.c:(.text+0x1a5e): undefined reference to `X509_NAME_get_index_by_NID'
          fe-secure-openssl.c:(.text+0x1a7a): undefined reference to `X509_NAME_get_entry'
          fe-secure-openssl.c:(.text+0x1a82): undefined reference to `X509_NAME_ENTRY_get_data'
          fe-secure-openssl.c:(.text+0x1b6d): undefined reference to `X509_get_subject_name'
          fe-secure-openssl.c:(.text+0x1b85): undefined reference to `X509_NAME_get_index_by_NID'
          /usr/local/musl/lib/libpq.a(fe-secure-openssl.o): In function `PQsslAttribute':
          fe-secure-openssl.c:(.text+0x1ce3): undefined reference to `SSL_get_version'
          fe-secure-openssl.c:(.text+0x1d04): undefined reference to `SSL_get_current_cipher'
          fe-secure-openssl.c:(.text+0x1d11): undefined reference to `SSL_CIPHER_get_bits'
          fe-secure-openssl.c:(.text+0x1d44): undefined reference to `SSL_get_current_compression'
          fe-secure-openssl.c:(.text+0x1d64): undefined reference to `SSL_get_current_cipher'
          fe-secure-openssl.c:(.text+0x1d6c): undefined reference to `SSL_CIPHER_get_name'
          collect2: error: ld returned 1 exit status


error: aborting due to previous error

error: Could not compile `diesel_cli`.

It seems htat it's related to the openssl and libpq library. Did I miss something?

failed to build on ubuntu 16.04

I can build one internal project successfully with cargo directly, but encounter error message with rust-musl-builder.

below are more details:

environment

('Ubuntu', '16.04', 'xenial')

Run:

alias rust-musl-builder='docker run --rm -it -v "$(pwd)":/home/rust/src ekidd/rust-musl-builder'
rust-musl-builder cargo build --release

Error message

Compiling pkg-config v0.3.6
Compiling winapi-build v0.1.1
Compiling bitflags v0.1.1
Compiling clap v1.5.5
Compiling fnv v1.0.3
Compiling memchr v0.1.11
Compiling unicode-normalization v0.1.2
Compiling gcc v0.3.21
Compiling advapi32-sys v0.1.2
error: linking with cc failed: exit code: 1
|
= note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/home/rust/.multirust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/home/rust/src/target/release/build/advapi32-sys-7ea5190fd4bcfa0c/build_script_build.0.o" "-o" "/home/rust/src/target/release/build/advapi32-sys-7ea5190fd4bcfa0c/build_script_build" "-Wl,--gc-sections" "-pie" "-Wl,-O1" "-nodefaultlibs" "-L" "/home/rust/src/target/release/deps" "-L" "/home/rust/.multirust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "-Wl,-Bdynamic" "/home/rust/src/target/release/deps/libbuild-493a7b0628804707.rlib" "/home/rust/.multirust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-5c6cf767.rlib" "/home/rust/.multirust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-5c6cf767.rlib" "/home/rust/.multirust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-5c6cf767.rlib" "/home/rust/.multirust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librand-5c6cf767.rlib" "/home/rust/.multirust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcollections-5c6cf767.rlib" "/home/rust/.multirust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_unicode-5c6cf767.rlib" "/home/rust/.multirust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-5c6cf767.rlib" "/home/rust/.multirust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_jemalloc-5c6cf767.rlib" "/home/rust/.multirust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-5c6cf767.rlib" "/home/rust/.multirust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-5c6cf767.rlib" "-l" "dl" "-l" "pthread" "-l" "gcc_s" "-l" "pthread" "-l" "c" "-l" "m" "-l" "rt" "-l" "util" "-l" "compiler-rt"
= note: cc: error: /home/rust/src/target/release/build/advapi32-sys-7ea5190fd4bcfa0c/build_script_build.0.o: Permission denied
cc: error: /home/rust/src/target/release/deps/libbuild-493a7b0628804707.rlib: Permission denied

error: aborting due to previous error

Compiling ws2_32-sys v0.2.1
Build failed, waiting for other jobs to finish...
error: linking with cc failed: exit code: 1
|
= note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/home/rust/.multirust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/home/rust/src/target/release/build/ws2_32-sys-fe7373db9ed2332c/build_script_build.0.o" "-o" "/home/rust/src/target/release/build/ws2_32-sys-fe7373db9ed2332c/build_script_build" "-Wl,--gc-sections" "-pie" "-Wl,-O1" "-nodefaultlibs" "-L" "/home/rust/src/target/release/deps" "-L" "/home/rust/.multirust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "-Wl,-Bdynamic" "/home/rust/src/target/release/deps/libbuild-493a7b0628804707.rlib" "/home/rust/.multirust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-5c6cf767.rlib" "/home/rust/.multirust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-5c6cf767.rlib" "/home/rust/.multirust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-5c6cf767.rlib" "/home/rust/.multirust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librand-5c6cf767.rlib" "/home/rust/.multirust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcollections-5c6cf767.rlib" "/home/rust/.multirust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_unicode-5c6cf767.rlib" "/home/rust/.multirust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-5c6cf767.rlib" "/home/rust/.multirust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_jemalloc-5c6cf767.rlib" "/home/rust/.multirust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-5c6cf767.rlib" "/home/rust/.multirust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-5c6cf767.rlib" "-l" "dl" "-l" "pthread" "-l" "gcc_s" "-l" "pthread" "-l" "c" "-l" "m" "-l" "rt" "-l" "util" "-l" "compiler-rt"
= note: cc: error: /home/rust/src/target/release/build/ws2_32-sys-fe7373db9ed2332c/build_script_build.0.o: Permission denied
cc: error: /home/rust/src/target/release/deps/libbuild-493a7b0628804707.rlib: Permission denied

error: aborting due to previous error

Build failed, waiting for other jobs to finish...
error: Could not compile advapi32-sys.

Consider using different Docker tags for ARM and x86_64 platforms

I have just noticed that the Dockerfile pulls Rust and GCC toolchains for ARM platform along with x86_64. There are a few points why I find it cumbersome:

  • The image size is noticeably affected.
  • The popular libraries are only built for x86_64, thus the ARM target is not on par with x86_64.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.