emk / rust-musl-builder

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.
Apache License 2.0
1.54k stars 193 forks source link

Rust 1.21.0 & diesel_codegen: "undefined symbol: SSL_set_ex_data" #27

Closed emk closed 6 years ago

emk commented 6 years ago

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 https://github.com/rust-lang/rust/issues/43486 and https://github.com/sgrif/pq-sys/pull/18.

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

iddm commented 6 years ago

Still have this issue. Did not try the 1.20 though.

emk commented 6 years ago

See the README for rust-musl-builder for instructions on making diesel work. We have example container that get built as part of the test suite, and they support diesel.

iddm commented 6 years ago

@emk I have read the readme thousands times in hope of finding anything what could help.

emk commented 6 years ago

@vityafx Did you look at the ./test-image script and the examples/ directory? There's an actual, working diesel example that might give you some hints.

iddm commented 6 years ago

This is useless example for me and for the problem which is described in the first post here. The problem is not with the diesel crate but with the diesel-cli, diesel_codegen, diesel_migrations, diesel_infer_schema and so on. diesel works, yes, but not the other crates of it.

emk commented 6 years ago

If you're building inside a Docker container, you might want to avoid diesel_infer_schema and use the CLI tool outside the container to generate the code you need (then commit it). In general, trying to connect to the database at build time under Docker is pretty painful and it's very hard to do without leaking database credentials into the Docker images you create.

In general, if there's a way to handle a use-case by running diesel-cli outside the container and checking in the generated code, I would strongly encourage people to do that.

But if there are diesel_codegen which aren't supported by diesel-cli, well, how hard would it be to modify the examples/using-diesel code to use diesel_codegen, and to submit the updated example as a (broken) PR? That would at least give us something concrete to look at.

In general, there are no easy for fixes for statically-linking C libraries like this. Somebody has to be prepared to put in real debugging time and actually figure out how to make it work. :-(

chrisabruce commented 5 years ago

Does this work with rust 1.3x? Noticed SSL errors while following all direction in README.