tikv / jemallocator

Rust allocator using jemalloc as a backend
Other
332 stars 52 forks source link

Error while cross-compiling jemallocator for aarch64 #71

Closed chiru091096 closed 5 months ago

chiru091096 commented 5 months ago

Hello, I'm cross-compiling jamallocator for aarch64 using the command cargo build --target=aarch64-unknown-linux-gnu. However, I'm facing the below error

--- stderr
configure: error: cannot find sources (Makefile.in) in jemallocator/target/aarch64-unknown-linux-gnu/debug/build/tikv-jemalloc-sys60309e46c4549367/out/build or ..
tail: cannot open 'jemallocator/target/aarch64-unknown-linux-gnu/debug/build/tikv-jemalloc-sys-60309e46c4549367/out/build/config.log' for reading: No such file or directory
thread 'main' panicked at jemalloc-sys/build.rs:351:9:

How can I fix this issue.

BusyJay commented 5 months ago

Try git submodule update --init.

chiru091096 commented 5 months ago

Try git submodule update --init.

Thank you for the reply. I did git submodule update --init. After building again, I face below error now

configure: exit 77
--- stderr
configure: error: in `jemallocator/target/aarch64-unknown-linux-gnu/debug/build/tikv-jemalloc-sys-60309e46c4549367/out/build':
configure: error: C compiler cannot create executables
See config.log for more details
thread 'main' panicked at jemalloc-sys/build.rs:353:9

I can see below logs in config.log file

configure:3054: clang-16 -V >&5
clang: error: argument to '-V' is missing (expected 1 value)
clang: error: no input files
configure:3065: $? = 1
configure:3054: clang-16 -qversion >&5
clang: error: unknown argument '-qversion'; did you mean '--version'?
clang: error: no input files
BusyJay commented 5 months ago

I haven't done cross compile myself recently. And I asked Github copilot, following is its reply:


The error "configure: error: C compiler cannot create executables" typically means that the build system is unable to successfully compile a test program. This can happen for a variety of reasons, but when cross-compiling, it's often because the build system is not correctly configured to use the cross-compiler.

Here are some steps you can take to troubleshoot this issue:

  1. Check your cross-compiler: Make sure that the cross-compiler for aarch64 is correctly installed on your x86_64 system. You can check this by running aarch64-linux-gnu-gcc --version (or whatever the name of your cross-compiler is). You should see some output that indicates the version of the compiler.

  2. Set the CC environment variable: Before running configure, set the CC environment variable to the name of your cross-compiler. This tells the build system to use the cross-compiler instead of the default C compiler. You can do this with a command like export CC=aarch64-linux-gnu-gcc.

  3. Pass host and build options to configure: When cross-compiling, you often need to pass --host and --build options to configure to tell it what system you're building on and what system you're building for. For example, you might run configure like this: ./configure --host=aarch64-linux-gnu --build=x86_64-linux-gnu.

  4. Check config.log: If configure is still failing, check the config.log file that it generates. This file should contain more detailed information about what went wrong. Look for lines that start with "error:" to find error messages.

Remember to clean the build directory (or create a separate build directory) before re-running configure to ensure that old build files don't interfere with the new build.

chiru091096 commented 5 months ago

@BusyJay (and Github copilot), Thank you for the help on this issue. I was able to fix the error and cross-compile successfully after checking environment variables.