indygreg / indygreg/PyOxidizer
musl static compilation of PyOxidizer
- Dominant language
- Rust
- Stars
- 6.2k
- Forks
- 256
- PR merge metrics
- No merged PRs in 30d
Description
I would like to compile a statically linked version of PyOxidizer with musl instead of glibc. I read in your documentation the following.
> "On Linux, a binary built with musl libc should just work on pretty much any Linux machine."
And that you can build said binary with the following.
> "pyoxidizer build --target x86_64-unknown-linux-musl"
I want to be able to do this, but my compilation machine has no access to the internet and will not be able to to download the dependencies. So the following, will not work.
> Or by cloning the Git repository and building the project locally:
"$ git clone https://github.com/indygreg/PyOxidizer.git
$ cd PyOxidizer
$ cargo install --path pyoxidizer"
This means that I cannot install PyOxidizer. I would like to pre-compile a version of PyOxidizer on a machine at home with internet with musl so that I can import it into the offline machine.
I have tried the following:
```
sudo apt-get install musl-tools pkg-config libssl-dev
rustup target add x86_64-unknown-linux-musl
export PKG_CONFIG_ALLOW_CROSS=1
cargo install pyoxidizer --target x86_64-unknown-linux-musl --force
```
Giving me the following error.
```
`Error: failed to run custom build command for `openssl-sys v0.9.48`
Caused by:
process didn't exit successfully: `/tmp/cargo-installeHZ2b4/release/build/openssl-sys-c6ab3905e6834642/build-script-main` (exit code: 101)
--- stdout
cargo:rustc-cfg=const_fn
cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_LIB_DIR
X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_LIB_DIR unset
cargo:rerun-if-env-changed=OPENSSL_LIB_DIR
OPENSSL_LIB_DIR unset
cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_INCLUDE_DIR
X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_INCLUDE_DIR unset
cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR
OPENSSL_INCLUDE_DIR unset
cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_DIR
X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_DIR unset
cargo:rerun-if-env-changed=OPENSSL_DIR
OPENSSL_DIR unset
cargo:rustc-link-lib=ssl
cargo:rustc-link-lib=crypto
OPT_LEVEL = Some("3")
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
CROSS_COMPILE = None
CFLAGS_x86_64-unknown-linux-musl = None
CFLAGS_x86_64_unknown_linux_musl = None
TARGET_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("false")
CARGO_CFG_TARGET_FEATURE = Some("crt-static,fxsr,sse,sse2")
running: "musl-gcc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-static" "-Wall" "-Wextra" "-E" "build/expando.c"
cargo:warning=build/expando.c:1:10: fatal error: openssl/opensslv.h: No such file or directory
cargo:warning= #include
cargo:warning= ^~~~~~~~~~~~~~~~~~~~
cargo:warning=compilation terminated.
exit code: 1
--- stderr
thread 'main' panicked at '
Header expansion error:
Error { kind: ToolExecError, message: "Command \"musl-gcc\" \"-O3\" \"-ffunction-sections\" \"-fdata-sections\" \"-fPIC\" \"-m64\" \"-static\" \"-Wall\" \"-Wextra\" \"-E\" \"build/expando.c\" with args \"musl-gcc\" did not execute successfully (status code exit code: 1)." }
Failed to find OpenSSL development headers.
```
I know that this is probably not an issue with PyOxidizer, **but there is a small audience out there that could really use relocatable PyOxidizer binary.** I really do think this project is great.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the documented `cargo install pyoxidizer --target x86_64-unknown-linux-musl` command and inspect the `openssl-sys` build output, especially the missing OpenSSL headers. Determine the project entry points and build configuration involved in producing a relocatable offline binary; done means a documented, reproducible musl build path that works without internet access.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- build-system, cli
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100