Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cross compile x86_64-unknown-linux-musl #903

Closed
doitian opened this issue May 26, 2019 · 5 comments

Comments

@doitian
Copy link
Member

commented May 26, 2019

I have tried https://github.com/emk/rust-musl-builder . The build failed on rocksdb.

@doitian doitian added the help wanted label May 26, 2019

@apiraino

This comment has been minimized.

Copy link

commented May 27, 2019

In theory the workflow to xcompile with musl should be easy:

# install the cross compiler
$ cargo install cross

# add the cargo target
$ rustup target add x86_64-unknown-linux-musl

# Finally, cross compile
# Some magic is happening here: a Docker image with musl
# is downloaded and executed to xcompile
$ cross build --release --target=x86_64-unknown-linux-musl

Unfortunately the last step fails, I guess it's related to rust-rocksdb/rust-rocksdb#174

Stacktrace

error: failed to run custom build command for `librocksdb-sys v5.18.3`
process didn't exit successfully: `/target/release/build/librocksdb-sys-ec5db74b9d3e7904/build-script-build` (exit code: 101)
--- stdout
cargo:rerun-if-changed=build.rs
cargo:rerun-if-changed=rocksdb/
cargo:rerun-if-changed=snappy/
cargo:rerun-if-changed=lz4/
cargo:rerun-if-changed=zstd/
cargo:rerun-if-changed=zlib/
cargo:rerun-if-changed=bzip2/

--- stderr
thread 'main' panicked at 'Unable to find libclang: "couldn\'t find any valid shared libraries matching: [\'libclang.so\', \'libclang-*.so\', \'libclang.so.*\'], set the `LIBCLANG_PATH` environment variable to a path where one of these files can be found (invalid: [])"', src/libcore/result.rs:997:5

Thanks to @wolf4ood for the hint ;-)

@doitian

This comment has been minimized.

Copy link
Member Author

commented May 28, 2019

Error using emk/rust-musl-builder

error: failed to run custom build command for `librocksdb-sys v5.18.3`
process didn't exit successfully: `/home/rust/src/target/release/build/librocksdb-sys-dbb872178387f235/build-script-build` (exit code: 101)
--- stdout
cargo:rerun-if-changed=build.rs
cargo:rerun-if-changed=rocksdb/
cargo:rerun-if-changed=snappy/
cargo:rerun-if-changed=lz4/
cargo:rerun-if-changed=zstd/
cargo:rerun-if-changed=zlib/
cargo:rerun-if-changed=bzip2/

--- stderr
thread 'main' panicked at 'Unable to find libclang: "couldn\'t find any valid shared libraries matching: [\'libclang.so\', \'libclang-*.so\', \'libclang.so.*\'], set the `LIBCLANG_PATH` environment variable to a path where one of these files can be found (invalid: [])"', src/libcore/result.rs:997:5
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

warning: build failed, waiting for other jobs to finish...
error: failed to run custom build command for `jemalloc-sys v0.3.0`
process didn't exit successfully: `/home/rust/src/target/release/build/jemalloc-sys-129394ed5d2e2a14/build-script-build` (exit code: 101)
[...]
Makefile:386: recipe for target 'lib/libjemalloc.so.2' failed

--- stderr
configure: WARNING: using cross tools not prefixed with host triplet
ar: `u' modifier ignored since `D' is the default (see `U')
/usr/bin/ld: src/jemalloc.pic.o: relocation R_X86_64_32 against `.rodata.malloc_conf_init.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: src/arena.pic.o: relocation R_X86_64_32S against hidden symbol `_rjem_je_h_steps' can not be used when making a shared object
/usr/bin/ld: src/background_thread.pic.o: relocation R_X86_64_32S against hidden symbol `_rjem_je_h_steps' can not be used when making a shared object
/usr/bin/ld: src/base.pic.o: relocation R_X86_64_32S against hidden symbol `_rjem_je_sz_size2index_tab' can not be used when making a shared object
/usr/bin/ld: src/bin.pic.o: relocation R_X86_64_32 against `.rodata._rjem_je_bin_init.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: src/ckh.pic.o: relocation R_X86_64_32S against hidden symbol `_rjem_je_sz_size2index_tab' can not be used when making a shared object
/usr/bin/ld: src/ctl.pic.o: relocation R_X86_64_32 against `.rodata.super_arenas_bin_i_node' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: src/extent.pic.o: relocation R_X86_64_32 against undefined hidden symbol `_rjem_je_extents_rtree' can not be used when making a shared object
/usr/bin/ld: src/large.pic.o: relocation R_X86_64_32S against undefined hidden symbol `_rjem_je_arenas' can not be used when making a shared object
/usr/bin/ld: src/log.pic.o: relocation R_X86_64_32 against undefined hidden symbol `_rjem_je_log_var_names' can not be used when making a shared object
/usr/bin/ld: src/malloc_io.pic.o: relocation R_X86_64_32S against `.rodata._rjem_je_malloc_strtoumax' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: src/mutex.pic.o: relocation R_X86_64_32 against `.rodata._rjem_je_malloc_mutex_postfork_child.str1.8' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: src/pages.pic.o: relocation R_X86_64_32 against `.rodata._rjem_je_pages_map.str1.8' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: src/prof.pic.o: relocation R_X86_64_32 against `.rodata.prof_dump_open_impl.str1.8' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: src/rtree.pic.o: relocation R_X86_64_32 against `.rodata._rjem_je_rtree_new.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: src/stats.pic.o: relocation R_X86_64_32S against `.rodata.mutex_stats_init_cols.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: src/tcache.pic.o: relocation R_X86_64_32S against undefined hidden symbol `_rjem_je_arenas' can not be used when making a shared object
/usr/bin/ld: src/tsd.pic.o: relocation R_X86_64_32 against `.rodata._rjem_je_tsd_cleanup.str1.8' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: src/witness.pic.o: relocation R_X86_64_32 against `.rodata.witness_lock_error_impl.str1.8' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
make: *** [lib/libjemalloc.so.2] Error 1
make: *** Waiting for unfinished jobs....
thread 'main' panicked at 'command did not execute successfully: "make" "srcroot=../jemalloc/" "-j" "16"
expected success, got: exit code: 2', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/jemalloc-sys-0.3.0/build.rs:370:9
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
@doitian

This comment has been minimized.

Copy link
Member Author

commented May 28, 2019

It's unlikely to build against musl now since rocksdb requires c++.

@doitian doitian closed this May 28, 2019

@apiraino

This comment has been minimized.

Copy link

commented May 28, 2019

I'm chasing down the maintainer of the japaric/x86_64-unknown-linux-musl Docker container to see if we can get it fixed there. I think it would be the best option (since cargo cross is well integrated in the building workflow.

@doitian

This comment has been minimized.

Copy link
Member Author

commented May 28, 2019

I have tried a custom image with cargo cross. I have installed clang, g++, and made link musl-g++ to g++. The problem is rocksdb depends on c++ standard library heavily, we need a real c++ for musl to make it work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.