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 compilation fails. #322

Closed
bddap opened this issue Aug 26, 2019 · 0 comments

Comments

@bddap
Copy link
Contributor

@bddap bddap commented Aug 26, 2019

To reproduce (macos)

brew install FiloSottile/musl-cross/musl-cross
rustup target add x86_64-unknown-linux-musl
CXX_x86_64-unknown-linux-musl=x86_64-linux-musl-gcc CC_x86_64-unknown-linux-musl=x86_64-linux-musl-g++ cargo build --release --target x86_64-unknown-linux-musl
Error log
   Compiling librocksdb-sys v6.1.2 (/Users/a/d/tmp/rust-rocksdb/librocksdb-sys)
error: failed to run custom build command for `librocksdb-sys v6.1.2 (/Users/a/d/tmp/rust-rocksdb/librocksdb-sys)`

Caused by:
  process didn't exit successfully: `/Users/a/d/tmp/rust-rocksdb/target/release/build/librocksdb-sys-dd7419cf82e92f3f/build-script-build` (exit code: 1)
--- 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/
cargo:warning=couldn't execute `llvm-config --prefix` (error: No such file or directory (os error 2))
cargo:warning=set the LLVM_CONFIG_PATH environment variable to a valid `llvm-config` executable
NUM_JOBS = Some("8")
TARGET = Some("x86_64-unknown-linux-musl")
OPT_LEVEL = Some("3")
HOST = Some("x86_64-apple-darwin")
CXX_x86_64-unknown-linux-musl = Some("x86_64-linux-musl-gcc")
CXXFLAGS_x86_64-unknown-linux-musl = None
CXXFLAGS_x86_64_unknown_linux_musl = None
TARGET_CXXFLAGS = None
CXXFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("false")
CARGO_CFG_TARGET_FEATURE = Some("crt-static,fxsr,sse,sse2")
running: "x86_64-linux-musl-gcc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-static" "-I" "rocksdb/include/" "-I" "rocksdb/" "-I" "rocksdb/third-party/gtest-1.7.0/fused-src/" "-I" "snappy/" "-I" "lz4/lib/" "-I" "zstd/lib/" "-I" "zstd/lib/dictBuilder/" "-I" "zlib/" "-I" "bzip2/" "-I" "." "-Wall" "-Wextra" "-msse2" "-msse4.1" "-msse4.2" "-mpclmul" "-std=c++11" "-Wno-unused-parameter" "-DSNAPPY=1" "-DLZ4=1" "-DZSTD=1" "-DZLIB=1" "-DBZIP2=1" "-DNDEBUG=1" "-DHAVE_PCLMUL=1" "-DHAVE_SSE42=1" "-DOS_MACOSX=1" "-DROCKSDB_PLATFORM_POSIX=1" "-DROCKSDB_LIB_IO_POSIX=1" "-o" "/Users/a/d/tmp/rust-rocksdb/target/x86_64-unknown-linux-musl/release/build/librocksdb-sys-a35f3ad4e7061929/out/rocksdb/utilities/document/json_document_builder.o" "-c" "rocksdb/utilities/document/json_document_builder.cc"
running: "x86_64-linux-musl-gcc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-static" "-I" "rocksdb/include/" "-I" "rocksdb/" "-I" "rocksdb/third-party/gtest-1.7.0/fused-src/" "-I" "snappy/" "-I" "lz4/lib/" "-I" "zstd/lib/" "-I" "zstd/lib/dictBuilder/" "-I" "zlib/" "-I" "bzip2/" "-I" "." "-Wall" "-Wextra" "-msse2" "-msse4.1" "-msse4.2" "-mpclmul" "-std=c++11" "-Wno-unused-parameter" "-DSNAPPY=1" "-DLZ4=1" "-DZSTD=1" "-DZLIB=1" "-DBZIP2=1" "-DNDEBUG=1" "-DHAVE_PCLMUL=1" "-DHAVE_SSE42=1" "-DOS_MACOSX=1" "-DROCKSDB_PLATFORM_POSIX=1" "-DROCKSDB_LIB_IO_POSIX=1" "-o" "/Users/a/d/tmp/rust-rocksdb/target/x86_64-unknown-linux-musl/release/build/librocksdb-sys-a35f3ad4e7061929/out/rocksdb/utilities/options/options_util.o" "-c" "rocksdb/utilities/options/options_util.cc"
running: "x86_64-linux-musl-gcc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-static" "-I" "rocksdb/include/" "-I" "rocksdb/" "-I" "rocksdb/third-party/gtest-1.7.0/fused-src/" "-I" "snappy/" "-I" "lz4/lib/" "-I" "zstd/lib/" "-I" "zstd/lib/dictBuilder/" "-I" "zlib/" "-I" "bzip2/" "-I" "." "-Wall" "-Wextra" "-msse2" "-msse4.1" "-msse4.2" "-mpclmul" "-std=c++11" "-Wno-unused-parameter" "-DSNAPPY=1" "-DLZ4=1" "-DZSTD=1" "-DZLIB=1" "-DBZIP2=1" "-DNDEBUG=1" "-DHAVE_PCLMUL=1" "-DHAVE_SSE42=1" "-DOS_MACOSX=1" "-DROCKSDB_PLATFORM_POSIX=1" "-DROCKSDB_LIB_IO_POSIX=1" "-o" "/Users/a/d/tmp/rust-rocksdb/target/x86_64-unknown-linux-musl/release/build/librocksdb-sys-a35f3ad4e7061929/out/rocksdb/util/dynamic_bloom.o" "-c" "rocksdb/util/dynamic_bloom.cc"
running: "x86_64-linux-musl-gcc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-static" "-I" "rocksdb/include/" "-I" "rocksdb/" "-I" "rocksdb/third-party/gtest-1.7.0/fused-src/" "-I" "snappy/" "-I" "lz4/lib/" "-I" "zstd/lib/" "-I" "zstd/lib/dictBuilder/" "-I" "zlib/" "-I" "bzip2/" "-I" "." "-Wall" "-Wextra" "-msse2" "-msse4.1" "-msse4.2" "-mpclmul" "-std=c++11" "-Wno-unused-parameter" "-DSNAPPY=1" "-DLZ4=1" "-DZSTD=1" "-DZLIB=1" "-DBZIP2=1" "-DNDEBUG=1" "-DHAVE_PCLMUL=1" "-DHAVE_SSE42=1" "-DOS_MACOSX=1" "-DROCKSDB_PLATFORM_POSIX=1" "-DROCKSDB_LIB_IO_POSIX=1" "-o" "/Users/a/d/tmp/rust-rocksdb/target/x86_64-unknown-linux-musl/release/build/librocksdb-sys-a35f3ad4e7061929/out/rocksdb/utilities/blob_db/blob_file.o" "-c" "rocksdb/utilities/blob_db/blob_file.cc"
running: "x86_64-linux-musl-gcc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-static" "-I" "rocksdb/include/" "-I" "rocksdb/" "-I" "rocksdb/third-party/gtest-1.7.0/fused-src/" "-I" "snappy/" "-I" "lz4/lib/" "-I" "zstd/lib/" "-I" "zstd/lib/dictBuilder/" "-I" "zlib/" "-I" "bzip2/" "-I" "." "-Wall" "-Wextra" "-msse2" "-msse4.1" "-msse4.2" "-mpclmul" "-std=c++11" "-Wno-unused-parameter" "-DSNAPPY=1" "-DLZ4=1" "-DZSTD=1" "-DZLIB=1" "-DBZIP2=1" "-DNDEBUG=1" "-DHAVE_PCLMUL=1" "-DHAVE_SSE42=1" "-DOS_MACOSX=1" "-DROCKSDB_PLATFORM_POSIX=1" "-DROCKSDB_LIB_IO_POSIX=1" "-o" "/Users/a/d/tmp/rust-rocksdb/target/x86_64-unknown-linux-musl/release/build/librocksdb-sys-a35f3ad4e7061929/out/rocksdb/cache/clock_cache.o" "-c" "rocksdb/cache/clock_cache.cc"
running: "x86_64-linux-musl-gcc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-static" "-I" "rocksdb/include/" "-I" "rocksdb/" "-I" "rocksdb/third-party/gtest-1.7.0/fused-src/" "-I" "snappy/" "-I" "lz4/lib/" "-I" "zstd/lib/" "-I" "zstd/lib/dictBuilder/" "-I" "zlib/" "-I" "bzip2/" "-I" "." "-Wall" "-Wextra" "-msse2" "-msse4.1" "-msse4.2" "-mpclmul" "-std=c++11" "-Wno-unused-parameter" "-DSNAPPY=1" "-DLZ4=1" "-DZSTD=1" "-DZLIB=1" "-DBZIP2=1" "-DNDEBUG=1" "-DHAVE_PCLMUL=1" "-DHAVE_SSE42=1" "-DOS_MACOSX=1" "-DROCKSDB_PLATFORM_POSIX=1" "-DROCKSDB_LIB_IO_POSIX=1" "-o" "/Users/a/d/tmp/rust-rocksdb/target/x86_64-unknown-linux-musl/release/build/librocksdb-sys-a35f3ad4e7061929/out/rocksdb/table/get_context.o" "-c" "rocksdb/table/get_context.cc"
running: "x86_64-linux-musl-gcc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-static" "-I" "rocksdb/include/" "-I" "rocksdb/" "-I" "rocksdb/third-party/gtest-1.7.0/fused-src/" "-I" "snappy/" "-I" "lz4/lib/" "-I" "zstd/lib/" "-I" "zstd/lib/dictBuilder/" "-I" "zlib/" "-I" "bzip2/" "-I" "." "-Wall" "-Wextra" "-msse2" "-msse4.1" "-msse4.2" "-mpclmul" "-std=c++11" "-Wno-unused-parameter" "-DSNAPPY=1" "-DLZ4=1" "-DZSTD=1" "-DZLIB=1" "-DBZIP2=1" "-DNDEBUG=1" "-DHAVE_PCLMUL=1" "-DHAVE_SSE42=1" "-DOS_MACOSX=1" "-DROCKSDB_PLATFORM_POSIX=1" "-DROCKSDB_LIB_IO_POSIX=1" "-o" "/Users/a/d/tmp/rust-rocksdb/target/x86_64-unknown-linux-musl/release/build/librocksdb-sys-a35f3ad4e7061929/out/rocksdb/db/write_batch_base.o" "-c" "rocksdb/db/write_batch_base.cc"
running: "x86_64-linux-musl-gcc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-static" "-I" "rocksdb/include/" "-I" "rocksdb/" "-I" "rocksdb/third-party/gtest-1.7.0/fused-src/" "-I" "snappy/" "-I" "lz4/lib/" "-I" "zstd/lib/" "-I" "zstd/lib/dictBuilder/" "-I" "zlib/" "-I" "bzip2/" "-I" "." "-Wall" "-Wextra" "-msse2" "-msse4.1" "-msse4.2" "-mpclmul" "-std=c++11" "-Wno-unused-parameter" "-DSNAPPY=1" "-DLZ4=1" "-DZSTD=1" "-DZLIB=1" "-DBZIP2=1" "-DNDEBUG=1" "-DHAVE_PCLMUL=1" "-DHAVE_SSE42=1" "-DOS_MACOSX=1" "-DROCKSDB_PLATFORM_POSIX=1" "-DROCKSDB_LIB_IO_POSIX=1" "-o" "/Users/a/d/tmp/rust-rocksdb/target/x86_64-unknown-linux-musl/release/build/librocksdb-sys-a35f3ad4e7061929/out/rocksdb/utilities/transactions/pessimistic_transaction_db.o" "-c" "rocksdb/utilities/transactions/pessimistic_transaction_db.cc"
cargo:warning=In file included from rocksdb/port/port.h:18:0,
cargo:warning=                 from rocksdb/util/dynamic_bloom.h:12,
cargo:warning=                 from rocksdb/util/dynamic_bloom.cc:6:
cargo:warning=rocksdb/port/port_posix.h:26:30: fatal error: machine/endian.h: No such file or directory
cargo:warning=   #include <machine/endian.h>
cargo:warning=                              ^
cargo:warning=compilation terminated.
cargo:warning=In file included from rocksdb/port/port.h:18:0,
cargo:warning=                 from rocksdb/utilities/blob_db/blob_file.h:11,
cargo:warning=                 from rocksdb/utilities/blob_db/blob_file.cc:6:
cargo:warning=rocksdb/port/port_posix.h:26:30: fatal error: machine/endian.h: No such file or directory
cargo:warning=   #include <machine/endian.h>
cargo:warning=                              ^
cargo:warning=compilation terminated.
exit code: 1
exit code: 1
cargo:warning=In file included from rocksdb/port/port.h:18:0,
cargo:warning=                 from rocksdb/monitoring/perf_level_imp.h:8,
cargo:warning=                 from rocksdb/monitoring/perf_step_timer.h:7,
cargo:warning=                 from rocksdb/monitoring/perf_context_imp.h:7,
cargo:warning=                 from rocksdb/db/dbformat.h:14,
cargo:warning=                 from rocksdb/db/merge_context.h:9,
cargo:warning=                 from rocksdb/table/get_context.h:8,
cargo:warning=                 from rocksdb/table/get_context.cc:6:
cargo:warning=rocksdb/port/port_posix.h:26:30: fatal error: machine/endian.h: No such file or directory
cargo:warning=   #include <machine/endian.h>
cargo:warning=                              ^
cargo:warning=compilation terminated.
exit code: 1
cargo:warning=In file included from rocksdb/port/port.h:18:0,
cargo:warning=                 from rocksdb/monitoring/perf_level_imp.h:8,
cargo:warning=                 from rocksdb/monitoring/perf_step_timer.h:7,
cargo:warning=                 from rocksdb/monitoring/perf_context_imp.h:7,
cargo:warning=                 from rocksdb/db/dbformat.h:14,
cargo:warning=                 from rocksdb/table/block_based_table_factory.h:16,
cargo:warning=                 from rocksdb/options/options_parser.h:15,
cargo:warning=                 from rocksdb/utilities/options/options_util.cc:10:
cargo:warning=rocksdb/port/port_posix.h:26:30: fatal error: machine/endian.h: No such file or directory
cargo:warning=   #include <machine/endian.h>
cargo:warning=                              ^
cargo:warning=compilation terminated.
cargo:warning=In file included from rocksdb/port/port.h:18:0,
cargo:warning=                 from rocksdb/monitoring/perf_level_imp.h:8,
cargo:warning=                 from rocksdb/monitoring/perf_step_timer.h:7,
cargo:warning=                 from rocksdb/monitoring/perf_context_imp.h:7,
cargo:warning=                 from rocksdb/db/dbformat.h:14,
cargo:warning=                 from rocksdb/db/memtable_list.h:15,
cargo:warning=                 from rocksdb/db/column_family.h:17,
cargo:warning=                 from rocksdb/db/db_impl.h:22,
cargo:warning=                 from rocksdb/db/db_iter.h:13,
cargo:warning=                 from rocksdb/utilities/transactions/pessimistic_transaction_db.h:16,
cargo:warning=                 from rocksdb/utilities/transactions/pessimistic_transaction_db.cc:12:
cargo:warning=rocksdb/port/port_posix.h:26:30: fatal error: machine/endian.h: No such file or directory
cargo:warning=   #include <machine/endian.h>
cargo:warning=                              ^
cargo:warning=compilation terminated.
exit code: 1
exit code: 1
exit code: 0
exit code: 0
exit code: 0

--- stderr


error occurred: Command "x86_64-linux-musl-gcc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-static" "-I" "rocksdb/include/" "-I" "rocksdb/" "-I" "rocksdb/third-party/gtest-1.7.0/fused-src/" "-I" "snappy/" "-I" "lz4/lib/" "-I" "zstd/lib/" "-I" "zstd/lib/dictBuilder/" "-I" "zlib/" "-I" "bzip2/" "-I" "." "-Wall" "-Wextra" "-msse2" "-msse4.1" "-msse4.2" "-mpclmul" "-std=c++11" "-Wno-unused-parameter" "-DSNAPPY=1" "-DLZ4=1" "-DZSTD=1" "-DZLIB=1" "-DBZIP2=1" "-DNDEBUG=1" "-DHAVE_PCLMUL=1" "-DHAVE_SSE42=1" "-DOS_MACOSX=1" "-DROCKSDB_PLATFORM_POSIX=1" "-DROCKSDB_LIB_IO_POSIX=1" "-o" "/Users/a/d/tmp/rust-rocksdb/target/x86_64-unknown-linux-musl/release/build/librocksdb-sys-a35f3ad4e7061929/out/rocksdb/util/dynamic_bloom.o" "-c" "rocksdb/util/dynamic_bloom.cc" with args "x86_64-linux-musl-gcc" did not execute successfully (status code exit code: 1).

Cause:

librocksdb-sys/build.rs uses cfg!(target_arch = "...") to set flags for compilation. This is subtly incorrect. In the context of a build.rs file cfg!(target_arch = "...") is actually checking the host architecture; the architecture for which build.rs is being built.

In the case of macos compiling for linux, since -DOS_MACOSX=1 ends up getting passed, rocksdb/port/port_posix.h attempts to import machine/endian.h which does not exist for the linux target.

Fix:

Change instances of cfg!(target_os = "...") to target.contains("...") where target = env::var("TARGET").unwrap(). example

@bddap bddap changed the title Cross compilation not supported. Cross compilation fails. Aug 26, 2019
@aleksuss aleksuss closed this in 54aff62 Aug 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.