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

--libdir is not used by rustc and rustpkg #11671

Closed
fabiand opened this issue Jan 19, 2014 · 5 comments
Closed

--libdir is not used by rustc and rustpkg #11671

fabiand opened this issue Jan 19, 2014 · 5 comments

Comments

@fabiand
Copy link
Contributor

fabiand commented Jan 19, 2014

After configuring and installing rust using the --libdir switch, rustc and rustpkg don't search in that dir:

+ ./configure --build=x86_64-redhat-linux-gnu --host=x86_64-redhat-linux-gnu --program-prefix= --disable-dependency-tracking --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64 --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/var/lib --mandir=/usr/share/man --infodir=/usr/share/info --build=x86_64-unknown-linux-gnu --host=x86_64-unknown-linux-gnu --target=x86_64-unknown-linux-gnu
configure: looking for configure programs
...
configure: processing /builddir/build/BUILD/rust-0.9/configure args
configure: 
configure: CFG_PREFIX           := /usr 
configure: CFG_LOCAL_RUST_ROOT  := /usr/local 
configure: CFG_LLVM_ROOT        :=  
configure: CFG_ANDROID_CROSS_PATH := /opt/ndk_standalone 
configure: CFG_MINGW32_CROSS_PATH :=  
configure: CFG_BUILD            := x86_64-unknown-linux-gnu 
configure: CFG_HOST             := x86_64-unknown-linux-gnu 
configure: CFG_TARGET           := x86_64-unknown-linux-gnu 
configure: CFG_LOCALSTATEDIR    := /var 
configure: CFG_SYSCONFDIR       := /etc 
configure: CFG_DATADIR          := /usr/share 
configure: CFG_INFODIR          := /usr/share/info 
configure: CFG_MANDIR           := /usr/share/man 
configure: CFG_LIBDIR           := /usr/lib64 
configure: CFG_RUSTLIBDIR       := rustlib 
....

When building:

$ RUST_LOG=rustc=4 rustc ex.rs 
using sysroot = /usr
testing name: macro_escape
testing name: doc
testing name: allow
testing name: doc
testing name: doc
testing name: doc
testing name: doc
testing name: doc
testing name: doc
testing name: doc
testing name: doc
testing name: doc
testing name: doc
testing name: doc
testing name: doc
testing name: doc
testing name: doc
testing name: doc
testing name: doc
testing name: doc
testing name: doc
testing name: doc
testing name: doc
testing name: doc
testing name: macro_escape
testing name: doc
testing name: allow
testing name: address_insignificant
testing name: allow
  testing: nogc
  testing: unix
  testing: target_os
  testing: target_family
  testing: target_arch
  testing: target_endian
  testing: target_word_size
  testing: macro_escape
  testing: doc
  testing: allow
  testing: macro_escape
  testing: doc
  testing: allow
  testing: address_insignificant
  testing: allow
  testing: address_insignificant
  testing: allow
  testing: macro_escape
  testing: doc
  testing: allow
  testing: address_insignificant
  testing: allow
resolving extern mod stmt. ident: @"std" path_opt: Some((@"std#0.9", CookedStr))
filesearch: searching additional lib search paths [0u]
filesearch: searching target lib path
searching /usr/lib/rustlib/x86_64-unknown-linux-gnu/lib
is /home/fabiand/tmp/.rust/lib/x86_64-unknown-linux-gnu in visited_dirs? false
searching /home/fabiand/tmp/.rust/lib/x86_64-unknown-linux-gnu
is /home/fabiand/tmp/lib/x86_64-unknown-linux-gnu in visited_dirs? false
searching /home/fabiand/tmp/lib/x86_64-unknown-linux-gnu
ex.rs:1:1: 1:1 error: can't find crate for `std`
ex.rs:1 fn main() {
        ^
task 'rustc' failed at 'explicit failure', /builddir/build/BUILD/rust-0.9/src/libsyntax/diagnostic.rs:41
task '' failed at 'explicit failure', /builddir/build/BUILD/rust-0.9/src/librustc/lib.rs:453

and

$ RUST_LOG=rustpkg=4 rustpkg build rustyworld
WARNING: The Rust package manager is experimental and may be unstable
Finished parsing commandline args ~[~"rustyworld"]
  Using command: BuildCmd
  Using args ~[~"rustyworld"]
  Using cflags: context::RustcFlags{compile_upto: Nothing, linker: None, link_args: None, optimization_level: No, save_temps: false, target: None, target_cpu: None, additional_library_paths: std::hashmap::HashSet{map: std::hashmap::HashMap{k0: 3087137010850483033u64, k1: 10051317995362439294u64, resize_at: 24u, size: 0u, buckets: ~[None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None]}}, experimental_features: None}
  Using rust_path_hack false
  Using cfgs: ~[]
  Using supplied_sysroot: None
Using sysroot: /usr
Will store workcache in /home/fabiand/work/rust-lang/example/.rust
Workcache database file: /home/fabiand/work/rust-lang/example/.rust/rustpkg_db.json
Found rustyworld-0.0 in /home/fabiand/work/rust-lang/example
found pkg rustyworld-0.0 in workspace /home/fabiand/work/rust-lang/example, trying to build
Checking package source for package ID rustyworld-0.0, workspace = /home/fabiand/work/rust-lang/example -> /home/fabiand/work/rust-lang/example, use_rust_path_hack = false
Checking dirs: ~"/home/fabiand/work/rust-lang/example/src/rustyworld-0.0:/home/fabiand/work/rust-lang/example/src/rustyworld:/home/fabiand/work/rust-lang/example/build/x86_64-unknown-linux-gnu/src/rustyworld-0.0:/home/fabiand/work/rust-lang/example/build/x86_64-unknown-linux-gnu/src/rustyworld"
1. build_in_destination = false
3. build_in_destination = false
source: /home/fabiand/work/rust-lang/example dest: /home/fabiand/work/rust-lang/example
For package id rustyworld-0.0, returning /home/fabiand/work/rust-lang/example/src/rustyworld
build: workspace = /home/fabiand/work/rust-lang/example (in Rust path? true is git dir? false crateid = rustyworld-0.0 pkgsrc start_dir = /home/fabiand/work/rust-lang/example/src/rustyworld
build: what to build = &target::WhatToBuild{build_type: MaybeCustom, sources: Everything, inputs_to_discover: ~[]}
Package source directory = Package ID rustyworld-0.0 in start dir /home/fabiand/work/rust-lang/example/src/rustyworld [workspaces = /home/fabiand/work/rust-lang/example -> /home/fabiand/work/rust-lang/example]
package_script_option: checking whether /home/fabiand/work/rust-lang/example/src/rustyworld/pkg.rs exists
Calling pkg_script_option on None
package_script_option: checking whether /home/fabiand/work/rust-lang/example/src/rustyworld/pkg.rs exists
No package script, continuing
Matching against rustyworld
Will compile crate bench.rs
Will compile crate lib.rs
Will compile crate main.rs
Will compile crate test.rs
In /home/fabiand/work/rust-lang/example/src/rustyworld, found 1 libs, 1 mains, 1 tests, 1 benchs
Building libs in /home/fabiand/work/rust-lang/example, destination = /home/fabiand/work/rust-lang/example
build_crates: compiling /home/fabiand/work/rust-lang/example/src/rustyworld/lib.rs
Building crate /home/fabiand/work/rust-lang/example/src/rustyworld/lib.rs, declaring it as an input
Compiling crate /home/fabiand/work/rust-lang/example/src/rustyworld/lib.rs; its output will be in /home/fabiand/work/rust-lang/example
compile_crate: crate=/home/fabiand/work/rust-lang/example/src/rustyworld/lib.rs, workspace=/home/fabiand/work/rust-lang/example
compile_crate: short_name = rustyworld-0.0, flags =...
compile_input: /home/fabiand/work/rust-lang/example/src/rustyworld/lib.rs / Lib
flags: 
cfgs: 
compile_input's sysroot = /usr
rustc flags: extra::getopts::Matches{opts: ~[extra::getopts::Opt{name: Short('c'), hasarg: No, occur: Optional, aliases: ~[]}, extra::getopts::Opt{name: Long(~"cfg"), hasarg: Yes, occur: Multi, aliases: ~[]}, extra::getopts::Opt{name: Long(~"emit-llvm"), hasarg: No, occur: Optional, aliases: ~[]}, extra::getopts::Opt{name: Long(~"help"), hasarg: No, occur: Optional, aliases: ~[extra::getopts::Opt{name: Short('h'), hasarg: No, occur: Optional, aliases: ~[]}]}, extra::getopts::Opt{name: Short('L'), hasarg: Yes, occur: Multi, aliases: ~[]}, extra::getopts::Opt{name: Long(~"bin"), hasarg: No, occur: Optional, aliases: ~[]}, extra::getopts::Opt{name: Long(~"lib"), hasarg: No, occur: Optional, aliases: ~[]}, extra::getopts::Opt{name: Long(~"rlib"), hasarg: No, occur: Optional, aliases: ~[]}, extra::getopts::Opt{name: Long(~"staticlib"), hasarg: No, occur: Optional, aliases: ~[]}, extra::getopts::Opt{name: Long(~"dylib"), hasarg: No, occur: Optional, aliases: ~[]}, extra::getopts::Opt{name: Long(~"linker"), hasarg: Yes, occur: Optional, aliases: ~[]}, extra::getopts::Opt{name: Long(~"ar"), hasarg: Yes, occur: Optional, aliases: ~[]}, extra::getopts::Opt{name: Long(~"crate-id"), hasarg: No, occur: Optional, aliases: ~[]}, extra::getopts::Opt{name: Long(~"crate-name"), hasarg: No, occur: Optional, aliases: ~[]}, extra::getopts::Opt{name: Long(~"crate-file-name"), hasarg: No, occur: Optional, aliases: ~[]}, extra::getopts::Opt{name: Long(~"link-args"), hasarg: Yes, occur: Multi, aliases: ~[]}, extra::getopts::Opt{name: Long(~"ls"), hasarg: No, occur: Optional, aliases: ~[]}, extra::getopts::Opt{name: Long(~"no-trans"), hasarg: No, occur: Optional, aliases: ~[]}, extra::getopts::Opt{name: Long(~"no-analysis"), hasarg: No, occur: Optional, aliases: ~[]}, extra::getopts::Opt{name: Short('O'), hasarg: No, occur: Optional, aliases: ~[]}, extra::getopts::Opt{name: Short('o'), hasarg: Yes, occur: Optional, aliases: ~[]}, extra::getopts::Opt{name: Long(~"opt-level"), hasarg: Yes, occur: Optional, aliases: ~[]}, extra::getopts::Opt{name: Long(~"passes"), hasarg: Yes, occur: Optional, aliases: ~[]}, extra::getopts::Opt{name: Long(~"llvm-args"), hasarg: Yes, occur: Optional, aliases: ~[]}, extra::getopts::Opt{name: Long(~"out-dir"), hasarg: Yes, occur: Optional, aliases: ~[]}, extra::getopts::Opt{name: Long(~"parse-only"), hasarg: No, occur: Optional, aliases: ~[]}, extra::getopts::Opt{name: Long(~"pretty"), hasarg: Maybe, occur: Optional, aliases: ~[]}, extra::getopts::Opt{name: Short('S'), hasarg: No, occur: Optional, aliases: ~[]}, extra::getopts::Opt{name: Long(~"dep-info"), hasarg: Maybe, occur: Optional, aliases: ~[]}, extra::getopts::Opt{name: Long(~"save-temps"), hasarg: No, occur: Optional, aliases: ~[]}, extra::getopts::Opt{name: Long(~"sysroot"), hasarg: Yes, occur: Optional, aliases: ~[]}, extra::getopts::Opt{name: Long(~"test"), hasarg: No, occur: Optional, aliases: ~[]}, extra::getopts::Opt{name: Long(~"target"), hasarg: Yes, occur: Optional, aliases: ~[]}, extra::getopts::Opt{name: Long(~"target-cpu"), hasarg: Yes, occur: Optional, aliases: ~[]}, extra::getopts::Opt{name: Long(~"target-feature"), hasarg: Yes, occur: Optional, aliases: ~[]}, extra::getopts::Opt{name: Long(~"android-cross-path"), hasarg: Yes, occur: Optional, aliases: ~[]}, extra::getopts::Opt{name: Long(~"warn"), hasarg: Maybe, occur: Optional, aliases: ~[extra::getopts::Opt{name: Short('W'), hasarg: Maybe, occur: Optional, aliases: ~[]}]}, extra::getopts::Opt{name: Long(~"allow"), hasarg: Yes, occur: Multi, aliases: ~[extra::getopts::Opt{name: Short('A'), hasarg: Yes, occur: Multi, aliases: ~[]}]}, extra::getopts::Opt{name: Long(~"deny"), hasarg: Yes, occur: Multi, aliases: ~[extra::getopts::Opt{name: Short('D'), hasarg: Yes, occur: Multi, aliases: ~[]}]}, extra::getopts::Opt{name: Long(~"forbid"), hasarg: Yes, occur: Multi, aliases: ~[extra::getopts::Opt{name: Short('F'), hasarg: Yes, occur: Multi, aliases: ~[]}]}, extra::getopts::Opt{name: Short('Z'), hasarg: Yes, occur: Multi, aliases: ~[]}, extra::getopts::Opt{name: Long(~"version"), hasarg: No, occur: Optional, aliases: ~[extra::getopts::Opt{name: Short('v'), hasarg: No, occur: Optional, aliases: ~[]}]}], vals: ~[~[], ~[], ~[], ~[], ~[], ~[], ~[Given], ~[], ~[], ~[], ~[], ~[], ~[], ~[], ~[], ~[], ~[], ~[], ~[], ~[], ~[], ~[], ~[], ~[], ~[], ~[], ~[], ~[], ~[], ~[], ~[], ~[], ~[], ~[], ~[], ~[], ~[], ~[], ~[], ~[], ~[], ~[]], free: ~[]}
Checking whether /usr is in target
compile_input's sysroot = /usr
sysroot_to_use = /usr
Output type = output_type_exe
Created options...
About to build session...
About to build config...
About to call find_and_install_dependencies...
In find_and_install_dependencies...
Finding and installing... std#0.9
Listing directory /usr/lib
dir has 53u entries
lib_prefix = libstd and lib_filetype = so
p = /usr/lib/alsa, p's extension is None
p = /usr/lib/binfmt.d, p's extension is Some("d")
p = /usr/lib/clang, p's extension is None
p = /usr/lib/cpp, p's extension is None
p = /usr/lib/crda, p's extension is None
p = /usr/lib/cups, p's extension is None
p = /usr/lib/debug, p's extension is None
p = /usr/lib/dracut, p's extension is None
p = /usr/lib/firewalld, p's extension is None
p = /usr/lib/firmware, p's extension is None
p = /usr/lib/games, p's extension is None
p = /usr/lib/gcc, p's extension is None
p = /usr/lib/girepository-1.0, p's extension is Some("0")
p = /usr/lib/gnome-settings-daemon-3.0, p's extension is Some("0")
p = /usr/lib/grub, p's extension is None
p = /usr/lib/hsqldb, p's extension is None
p = /usr/lib/java, p's extension is None
p = /usr/lib/java-1.5.0, p's extension is Some("0")
p = /usr/lib/java-1.6.0, p's extension is Some("0")
p = /usr/lib/java-1.7.0, p's extension is Some("0")
p = /usr/lib/java-1.8.0, p's extension is Some("0")
p = /usr/lib/java-ext, p's extension is None
p = /usr/lib/jvm, p's extension is None
p = /usr/lib/jvm-commmon, p's extension is None
p = /usr/lib/jvm-exports, p's extension is None
p = /usr/lib/jvm-private, p's extension is None
p = /usr/lib/kbd, p's extension is None
p = /usr/lib/kde3, p's extension is None
p = /usr/lib/kde4, p's extension is None
p = /usr/lib/kernel, p's extension is None
p = /usr/lib/locale, p's extension is None
p = /usr/lib/modprobe.d, p's extension is Some("d")
p = /usr/lib/modules, p's extension is None
p = /usr/lib/modules-load.d, p's extension is Some("d")
p = /usr/lib/mozilla, p's extension is None
p = /usr/lib/node_modules, p's extension is None
p = /usr/lib/pkgconfig, p's extension is None
p = /usr/lib/polkit-1, p's extension is None
p = /usr/lib/python2.7, p's extension is Some("7")
p = /usr/lib/python3.3, p's extension is Some("3")
p = /usr/lib/rpm, p's extension is None
p = /usr/lib/rustc, p's extension is None
p = /usr/lib/security, p's extension is None
p = /usr/lib/sendmail, p's extension is None
p = /usr/lib/sendmail.sendmail, p's extension is Some("sendmail")
p = /usr/lib/sse2, p's extension is None
p = /usr/lib/sysctl.d, p's extension is Some("d")
p = /usr/lib/systemd, p's extension is None
p = /usr/lib/tmpfiles.d, p's extension is Some("d")
p = /usr/lib/tuned, p's extension is None
p = /usr/lib/udev, p's extension is None
p = /usr/lib/udisks2, p's extension is None
p = /usr/lib/yum-plugins, p's extension is None
warning: library_in_workspace didn't find a library in /usr/lib for std
system library returned None
Trying to install library std#0.9, rebuilding it
Didn't find std-0.9 in /home/fabiand/work/rust-lang/example
Checking package source for package ID std-0.9, workspace = /home/fabiand/work/rust-lang/example/.rust -> /home/fabiand/work/rust-lang/example/.rust, use_rust_path_hack = false
Checking dirs: ~"/home/fabiand/work/rust-lang/example/.rust/src/std-0.9:/home/fabiand/work/rust-lang/example/.rust/src/std:/home/fabiand/work/rust-lang/example/.rust/build/x86_64-unknown-linux-gnu/src/std-0.9:/home/fabiand/work/rust-lang/example/.rust/build/x86_64-unknown-linux-gnu/src/std"
1. build_in_destination = false
Calling fetch_git on /home/fabiand/work/rust-lang/example/.rust/build/x86_64-unknown-linux-gnu/src/std-0.9
Checking whether std-0.9 (path = std) exists locally. Cwd = /home/fabiand/work/rust-lang/example, does it? false
Calling fetch_git on /home/fabiand/work/rust-lang/example/.rust/build/x86_64-unknown-linux-gnu/src/std
Checking whether std-0.9 (path = std) exists locally. Cwd = /home/fabiand/work/rust-lang/example, does it? false
error: Package rustyworld depends on std, but I don't know how to find it
task '' failed at 'explicit failure', /builddir/build/BUILD/rust-0.9/src/librustpkg/util.rs:519
task '' failed at 'receiving on a closed channel', /builddir/build/BUILD/rust-0.9/src/libstd/comm/mod.rs:728
@fabiand
Copy link
Contributor Author

fabiand commented Jan 19, 2014

@jhasse
Copy link
Contributor

jhasse commented Jan 20, 2014

Okay this is not as easily fixable as I thought. But there's a doable (and IMO clean) solution:

Readd what I had in my first version of #11045:

if [[ "$CFG_LIBDIR" != "$CFG_PREFIX"* ]]
then
    err "libdir must begin with the prefix. Use --prefix to set it accordingly."
fi

valopt libdir-relative "${CFG_LIBDIR:${#CFG_PREFIX}+1}" "install libraries (relative to prefix"

Probably don't make CFG_LIBDIR_RELATIVE configurable, but still calculate it from CFG_LIBDIR. Then add linker flags to target.mk like it was here: 89f8bc2

Before I create a PR with these two changes, I would want to know if this would get merged. @alexcrichton what are your thoughts on this?

@jauhien
Copy link
Contributor

jauhien commented Aug 17, 2014

@jhasse, @alexcrichton, what is the status of this? As in current state CFG_LIBDIR makes no sense: when it is set and rust is installed, it can not compile any create because of

error: can't find crate for `std`

and this error is because rustc looks in hardcoded relative path.

Have I missed something or --libdir option is broken at the moment?

@alexcrichton
Copy link
Member

The configure script has changed slightly since this was opened, and so have the state of things. This isn't really relevant to rustpkg (now cargo), but it's still relevant for rustc. The configure script supports the --libdir option, but rustc will not work unless it is manually passed to -L.

@jauhien
Copy link
Contributor

jauhien commented Aug 17, 2014

I've submitted a PR with fix, please, have a look. It changes behavior for case when libdir different from 'lib' is provided.

It is not very common use case, but can be usefull (e.g. I'm planning to use it in rust package in Gentoo to allow different versions of rust to be installed simultaneously).

bors added a commit that referenced this issue Nov 21, 2014
Fixies #11671

This commit changes default relative libdir 'lib' to a relative libdir calculated using LIBDIR provided by --libdir configuration option. In case if no option was provided behavior does not change.
@bors bors closed this as completed in e889f80 Nov 21, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants