Hi, all!
I try build project for x86_64-unknown-linux-musl target.
- build musl and install in /usr/local/musl (I don't want add /usr/local/musl/bin to PATH)
- build openssl with musl and --prefix=/usr/local/musl
- i run
cargo build
and got
error: failed to run custom build command for `openssl-sys v0.9.14`
process didn't exit successfully: `/home/cnonim/projects/foo/target/debug/build/openssl-sys-7ddcfddd026875a5/build-script-build` (exit code: 101)
--- stdout
run pkg_config fail: "Cross compilation detected. Use PKG_CONFIG_ALLOW_CROSS=1 to override"
--- stderr
thread 'main' panicked at '
Could not find directory of OpenSSL installation, and this `-sys` crate cannot
proceed without this knowledge. If OpenSSL is installed and this crate had
trouble finding it, you can set the `OPENSSL_DIR` environment variable for the
compilation process.
If you're in a situation where you think the directory *should* be found
automatically, please open a bug at https://github.com/sfackler/rust-openssl
and include information about your system as well as this message.
$HOST = x86_64-unknown-linux-gnu
$TARGET = x86_64-unknown-linux-musl
openssl-sys = 0.9.14
', /home/cnonim/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.14/build.rs:176
note: Run with `RUST_BACKTRACE=1` for a backtrace.
warning: build failed, waiting for other jobs to finish...
error: build failed
ok, I try OPENSSL_DIR=/usr/local/musl cargo build -p server
and got
error: failed to run custom build command for `openssl-sys v0.9.14`
process didn't exit successfully: `/home/cnonim/projects/foo/target/debug/build/openssl-sys-7ddcfddd026875a5/build-script-build` (exit code: 101)
--- stdout
cargo:rustc-link-search=native=/usr/local/musl/lib
cargo:include=/usr/local/musl/include
OPT_LEVEL = Some("0")
TARGET = Some("x86_64-unknown-linux-musl")
HOST = Some("x86_64-unknown-linux-gnu")
TARGET = Some("x86_64-unknown-linux-musl")
TARGET = Some("x86_64-unknown-linux-musl")
HOST = Some("x86_64-unknown-linux-gnu")
CC_x86_64-unknown-linux-musl = None
CC_x86_64_unknown_linux_musl = None
TARGET_CC = None
CC = None
HOST = Some("x86_64-unknown-linux-gnu")
CROSS_COMPILE = None
TARGET = Some("x86_64-unknown-linux-musl")
HOST = Some("x86_64-unknown-linux-gnu")
CFLAGS_x86_64-unknown-linux-musl = None
CFLAGS_x86_64_unknown_linux_musl = None
TARGET_CFLAGS = None
CFLAGS = None
PROFILE = Some("debug")
running: "musl-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-m64" "-static" "-I" "/usr/local/musl/include" "-E" "/home/cnonim/projects/foo/target/x86_64-unknown-linux-musl/debug/build/openssl-sys-79d18a4aaac85536/out/expando.c"
failed to execute command: No such file or directory (os error 2)
Is `musl-gcc` not installed?
--- stderr
thread 'main' panicked at 'explicit panic', /home/cnonim/.cargo/registry/src/github.com-1ecc6299db9ec823/gcc-0.3.51/src/lib.rs:1239
note: Run with `RUST_BACKTRACE=1` for a backtrace.
thread 'main' panicked at '
Failed to find OpenSSL development headers.
You can try fixing this setting the `OPENSSL_DIR` environment variable
pointing to your OpenSSL installation or installing OpenSSL headers package
specific to your distribution:
# On Ubuntu
sudo apt-get install libssl-dev
# On Arch Linux
sudo pacman -S openssl
# On Fedora
sudo dnf install openssl-devel
See rust-openssl README for more information:
https://github.com/sfackler/rust-openssl#linux
', /home/cnonim/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.14/build.rs:292
warning: build failed, waiting for other jobs to finish...
error: build failed
ok, CC=/usr/local/musl/bin/musl-gcc OPENSSL_DIR=/usr/local/musl cargo build -p server
Now, I want specify all ENVIROMENT variables for target in .cargo/config
but
[target.x86_64-unknown-linux-musl]
env = { CC = "/usr/local/musl/bin/musl-gcc", OPENSSL_DIR = "/usr/local/musl" }
doesn't work. Why?