Skip to content

--jemalloc-root actually expects file path, not a directory #35349

@jirutka

Description

@jirutka

--jemalloc-root has description: “set directory where libjemalloc_pic.a is located”, but it actually expects full path of libjemalloc_pic.a, not a directory.

When I set --jemalloc-root=/usr/lib (and --enable-rustbuild), then build fails:

     Running `/home/jirutjak/rust/build/bootstrap/debug/rustc src/liballoc_jemalloc/lib.rs --crate-name alloc_jemalloc --crate-type lib -C opt-level=2 -C metadata=fa1cd829f11122da -C extra-filename=-fa1cd829f11122da --out-dir /home/jirutjak/rust/build/x86_64-unknown-linux-musl/stage0-std/x86_64-unknown-linux-musl/release/deps --emit=dep-info,link --target x86_64-unknown-linux-musl -L dependency=/home/jirutjak/rust/build/x86_64-unknown-linux-musl/stage0-std/x86_64-unknown-linux-musl/release/deps -L dependency=/home/jirutjak/rust/build/x86_64-unknown-linux-musl/stage0-std/x86_64-unknown-linux-musl/release/deps --extern core=/home/jirutjak/rust/build/x86_64-unknown-linux-musl/stage0-std/x86_64-unknown-linux-musl/release/deps/libcore-eccf49d39f88a622.rlib --extern libc=/home/jirutjak/rust/build/x86_64-unknown-linux-musl/stage0-std/x86_64-unknown-linux-musl/release/deps/liblibc-5aeeadd0596ef5a0.rlib -L native=/usr --cfg cargobuild -l dylib=`
       Fresh panic_unwind v0.0.0 (file:///home/jirutjak/rust/src/libpanic_unwind)
error: empty library name given via `-l`
error: aborting due to previous error
error: Could not compile `alloc_jemalloc`.

The problem is in src/liballoc_jemalloc/build.rs:30.

    if let Some(jemalloc) = env::var_os("JEMALLOC_OVERRIDE") {
        let jemalloc = PathBuf::from(jemalloc);  //=> "/usr/lib"
        println!("cargo:rustc-link-search=native={}",
                 jemalloc.parent().unwrap().display());
        let stem = jemalloc.file_stem().unwrap().to_str().unwrap();  //=> "lib"
        println!("cargo:rustc-link-lib={}={}", kind, &stem[3..]);  //=> "cargo:rustc-link-lib=dylib="

It works fine with --jemalloc-root=/usr/lib/libjemalloc_pic.a.

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions