rust-lang / rust-installer

The Bourne shell installer used by Rust and Cargo
Apache License 2.0
61 stars 68 forks source link

install.sh miplaces codegen-backends directory with libdir = "/lib/something" #93

Closed gyakovlev closed 5 years ago

gyakovlev commented 5 years ago

if someone passes libdir = "lib/rust-1.x.x" via config.toml install.sh misplaces codegen-backends directory

this code here at fault: https://github.com/rust-lang/rust-installer/blob/5afc0089f282570f2c39b4345d2706bf97e3d84b/install-template.sh#L573-L578

imagine this scenario

part of config.toml

[install]
libdir = "lib/rust-1.34.2"

DESTDIR=/var/tmp/portage/dev-lang/rust-1.34.2/image ./x.py install

install.sh gets "--libdir=/var/tmp/portage/dev-lang/rust-1.34.2/image/usr/lib/rust-1.34.2" as one of args.

minimal reproducer

#!/bin/sh

CFG_LIBDIR=/var/tmp/portage/dev-lang/rust-1.34.2/image/usr/lib/rust-1.34.2
files=(
    lib/rustlib/i686-unknown-linux-gnu/lib/libLLVM-8-rust-1.34.2-stable.so
    lib/rust-1.34.2/rustlib/i686-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so
    lib/libsyntax_pos-3b2f33a4aab1c362.so
)
for _file in ${files[@]}; do
    if echo "$_file" | grep "^lib/" > /dev/null; then
        _f="$(echo "$_file" | sed 's/^lib\///')"
        _file_install_path="$CFG_LIBDIR/$_f"
    fi
    echo $_file_install_path
done
sh test.sh
/var/tmp/portage/dev-lang/rust-1.34.2/image/usr/lib/rust-1.34.2/rustlib/i686-unknown-linux-gnu/lib/libLLVM-8-rust-1.34.2-stable.so
/var/tmp/portage/dev-lang/rust-1.34.2/image/usr/lib/rust-1.34.2/rust-1.34.2/rustlib/i686-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so
/var/tmp/portage/dev-lang/rust-1.34.2/image/usr/lib/rust-1.34.2/libsyntax_pos-3b2f33a4aab1c362.so

so the resulting codegen-backends gets installed into /usr/lib/rust-1.34.2/rust-1.34.2

it can't be observed on x86_64 hosts because installer replaces lib/, not for lib64/

this breaks rustc as it can't find librustc_codegen_llvm-llvm.so until it's moved to proper location.

gyakovlev commented 5 years ago

fixed by https://github.com/rust-lang/rust/commit/661f42a57a32b3b93d984982525075305eac9471 in bootstrap