Skip to content

Cross compilation error #81

@fengys1996

Description

@fengys1996

Problems encountered

Compile aarch64-linux-android binary on linux.

Specify profile as release, and it will compile normally.
However, if lto = "thin" is specified, an error will be reported. The details are as follows:

  = note: ld.lld: error: duplicate symbol: pthread_atfork
          >>> defined at crtbegin.c
          >>>            /home/fys/soft/ndk/android-ndk-r26d/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/lib/aarch64-linux-android/23/crtbegin_dynamic.o:(pthread_atfork)
          >>> defined at build_jemalloc.6cd863fbc26b10-cgu.0
          >>>            /home/fys/source/build_jemalloc/target/aarch64-linux-android/nightly/deps/build_jemalloc-c1434931e7fc5ee2.build_jemalloc.6cd863fbc26b10-cgu.0.rcgu.o:(.text.pthread_atfork+0x0)
          clang-17: error: linker command failed with exit code 1 (use -v to see invocation)

How to reproduce

main.rs

#[global_allocator]
static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;

fn main() {
    println!("Hello, world!");
}

Cargo.toml

[package]
name = "build_jemalloc"
version = "0.1.0"
edition = "2021"

[dependencies]
tikv-jemallocator = "0.5"

[profile.nightly]
inherits = "release"
lto = true
  1. Install android ndk, and set the ANDROID_NDK_HOME environment variable.
  2. cargo ndk --platform 23 -t aarch64-linux-android build --profile release is ok.
  3. cargo ndk --platform 23 -t aarch64-linux-android build --profile nightly is wrong.

I tried removing this part of the code and it works fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions