以下是 Diesel 的diesel_migrations
板条箱无法使用clux/muslrust
映像通过 Docker 在 musl 上编译的最小工作示例。它给出了一个undefined symbol: strlcpy
错误。该代码在本机系统 (macOS) 上运行良好。
码头工人命令
docker run \
-v cargo-cache:/root/.cargo \
-v "$PWD:/volume" \
--rm -it clux/muslrust cargo build --release
满载货物输出
Fresh bitflags v1.0.1
Fresh unicode-xid v0.0.4
Fresh byteorder v1.2.1
Fresh antidote v1.0.0
Fresh uuid v0.5.1
Fresh num-traits v0.2.0
Fresh itoa v0.3.4
Fresh quote v0.3.15
Fresh serde v1.0.27
Fresh cfg-if v0.1.2
Fresh dtoa v0.4.2
Fresh synom v0.11.3
Fresh scheduled-thread-pool v0.2.0
Fresh num-traits v0.1.43
Fresh log v0.4.1
Fresh syn v0.11.11
Fresh serde_json v1.0.9
Fresh pq-sys v0.4.4
Fresh r2d2 v0.8.2
Fresh diesel_derives v1.1.0
Fresh diesel v1.1.1
Fresh migrations_internals v1.1.0
Fresh migrations_macros v1.1.0
Compiling diesel_migrations v1.1.0
Running `rustc --crate-name diesel_migrations /root/.cargo/registry/src/github.com-1ecc6299db9ec823/diesel_migrations-1.1.0/src/lib.rs --crate-type lib --emit=dep-info,link -C opt-level=3 --cfg 'feature="default"' -C metadata=4358fb7d50fa83b4 -C extra-filename=-4358fb7d50fa83b4 --out-dir /volume/target/x86_64-unknown-linux-musl/release/deps --target x86_64-unknown-linux-musl -L dependency=/volume/target/x86_64-unknown-linux-musl/release/deps -L dependency=/volume/target/release/deps --extern migrations_internals=/volume/target/x86_64-unknown-linux-musl/release/deps/libmigrations_internals-0fb7c87a53458af1.rlib --extern migrations_macros=/volume/target/release/deps/libmigrations_macros-410fd6f73c776a1c.so --cap-lints allow -L native=/musl/lib`
error: /volume/target/release/deps/libmigrations_macros-410fd6f73c776a1c.so: undefined symbol: strlcpy
--> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/diesel_migrations-1.1.0/src/lib.rs:77:1
|
77 | extern crate migrations_macros;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: Could not compile `diesel_migrations`.
Caused by:
process didn't exit successfully: `rustc --crate-name diesel_migrations /root/.cargo/registry/src/github.com-1ecc6299db9ec823/diesel_migrations-1.1.0/src/lib.rs --crate-type lib --emit=dep-info,link -C opt-level=3 --cfg feature="default" -C metadata=4358fb7d50fa83b4 -C extra-filename=-4358fb7d50fa83b4 --out-dir /volume/target/x86_64-unknown-linux-musl/release/deps --target x86_64-unknown-linux-musl -L dependency=/volume/target/x86_64-unknown-linux-musl/release/deps -L dependency=/volume/target/release/deps --extern migrations_internals=/volume/target/x86_64-unknown-linux-musl/release/deps/libmigrations_internals-0fb7c87a53458af1.rlib --extern migrations_macros=/volume/target/release/deps/libmigrations_macros-410fd6f73c776a1c.so --cap-lints allow -L native=/musl/lib` (exit code: 101)
货运.toml
[package]
name = "diesel_test"
version = "0.1.0"
authors = ["John Doe <example@email.com>"]
[dependencies]
diesel_migrations = "1"
[dependencies.diesel]
version = "1"
features = ["postgres", "uuid", "serde_json", "r2d2", "large-tables"]
src/main.rs
#[macro_use] extern crate diesel_migrations;
extern crate diesel;
embed_migrations!();
fn main() {
println!("Hello, world!");
}
迁移/2018-02-07-164146_create_post/up.sql
-- Your SQL goes here
create table posts (
id serial primary key,
)
迁移/2018-02-07-164146_create_post/down.sql
-- Your SQL goes here
drop table posts