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

Make CFG_LIBDIR configurable. Fixes #5223 #11045

Merged
merged 2 commits into from
Jan 7, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ export CFG_ENABLE_MINGW_CROSS
export CFG_PREFIX
export CFG_LIBDIR
export CFG_RUSTLIBDIR
export LIBDIR_RELATIVE

######################################################################
# Subprograms
Expand All @@ -433,12 +434,12 @@ define SREQ
# Destinations of artifacts for the host compiler
HROOT$(1)_H_$(3) = $(3)/stage$(1)
HBIN$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/bin
HLIB$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/$$(CFG_LIBDIR)
HLIB$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/$$(LIBDIR_RELATIVE)

# Destinations of artifacts for target architectures
TROOT$(1)_T_$(2)_H_$(3) = $$(HLIB$(1)_H_$(3))/$$(CFG_RUSTLIBDIR)/$(2)
TBIN$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/bin
TLIB$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/$$(CFG_LIBDIR)
TLIB$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/lib

# The name of the standard and extra libraries used by rustc
HSTDLIB_DEFAULT$(1)_H_$(3) = \
Expand Down
42 changes: 22 additions & 20 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,17 @@ valopt sysconfdir "/etc" "install system configuration files"
valopt datadir "${CFG_PREFIX}/share" "install data"
valopt infodir "${CFG_PREFIX}/share/info" "install additional info"
valopt mandir "${CFG_PREFIX}/share/man" "install man pages in PATH"
valopt libdir "${CFG_PREFIX}/lib" "install libraries"

# On windows we just store the libraries in the bin directory because
# there's no rpath
# FIXME: Thise needs to parameterized over target triples. Do it in platform.mk
LIBDIR_RELATIVE=lib
if [ "$CFG_OSTYPE" = "pc-mingw32" ]
then
LIBDIR_RELATIVE=bin
fi

valopt libdir "${CFG_PREFIX}/${LIBDIR_RELATIVE}" "install libraries"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There doesn't appear to be any sort of validation that the provided path for this on the command line is an absolute path? I would imagine that havoc would ensue if this case happened.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting a relative path should work fine. Imagine you have rust checked out
at /usr/rust and set libdir to ../lib

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm ... I just gave it some more thought and think that I might be wrong: At some places rustc/rustpkg might use the absolute path and this would then result in strange results since it would then depend on the current working dir to find the correct files.

Anyway I don't think a check here should be needed, because other autotools software doesn't check either AFAIK. Also there aren't any checks for CFG_PREFIX either and setting this one to a relative path would mess up even more.

valopt rustlibdir "rustlib" "subdirectory name for rustc's libraries"

# Validate Options
Expand Down Expand Up @@ -560,10 +570,10 @@ then
step_msg "on OS X 10.9, forcing use of clang"
CFG_ENABLE_CLANG=1
putvar CFG_ENABLE_CLANG
else
# on OS X, with xcode 5 and newer, certain developers may have
else
# on OS X, with xcode 5 and newer, certain developers may have
# cc, gcc and g++ point to a mixture of clang and gcc
# if so, this will create very strange build errors
# if so, this will create very strange build errors
# this last stanza is to detect some such problems and save the future rust
# contributor some time solving that issue.
# this detection could be generalized to other OSes aside from OS X
Expand All @@ -576,8 +586,8 @@ then
# note that for xcode 5, g++ points to clang, not clang++
if !((chk_cc gcc clang && chk_cc g++ clang) ||
(chk_cc gcc gcc &&( chk_cc g++ g++ || chk g++ gcc))) then
err "the gcc and g++ in your path point to different compilers.
Check which versions are in your path with cc --version and g++ --version.
err "the gcc and g++ in your path point to different compilers.
Check which versions are in your path with cc --version and g++ --version.
To resolve this problem, either fix your PATH or run configure with --enable-clang"
fi

Expand Down Expand Up @@ -751,15 +761,6 @@ do
done
done

# On windows we just store the libraries in the bin directory because
# there's no rpath
# FIXME: Thise needs to parameterized over target triples. Do it in platform.mk
CFG_LIBDIR=lib
if [ "$CFG_OSTYPE" = "pc-mingw32" ]
then
CFG_LIBDIR=bin
fi

for h in $CFG_HOST
do
for t in $CFG_TARGET
Expand All @@ -770,21 +771,21 @@ do
make_dir $h/stage$i/bin

# host lib dir
make_dir $h/stage$i/$CFG_LIBDIR
make_dir $h/stage$i/$LIBDIR_RELATIVE

# host test dir
make_dir $h/stage$i/test

# target bin dir
make_dir $h/stage$i/$CFG_LIBDIR/$CFG_RUSTLIBDIR/$t/bin
make_dir $h/stage$i/$LIBDIR_RELATIVE/$CFG_RUSTLIBDIR/$t/bin

# target lib dir
make_dir $h/stage$i/$CFG_LIBDIR/$CFG_RUSTLIBDIR/$t/$CFG_LIBDIR
make_dir $h/stage$i/$LIBDIR_RELATIVE/$CFG_RUSTLIBDIR/$t/lib
done

# Fix stage0:
make_dir $h/stage0/$CFG_LIBDIR/rustc/$t/bin
make_dir $h/stage0/$CFG_LIBDIR/rustc/$t/$CFG_LIBDIR
make_dir $h/stage0/$LIBDIR_RELATIVE/rustc/$t/bin
make_dir $h/stage0/$LIBDIR_RELATIVE/rustc/$t/$LIBDIR_RELATIVE

done

Expand Down Expand Up @@ -1038,6 +1039,7 @@ putvar CFG_TARGET
putvar CFG_C_COMPILER
putvar CFG_LIBDIR
putvar CFG_RUSTLIBDIR
putvar LIBDIR_RELATIVE
putvar CFG_DISABLE_MANAGE_SUBMODULES
putvar CFG_ANDROID_CROSS_PATH
putvar CFG_MINGW32_CROSS_PATH
Expand Down
2 changes: 1 addition & 1 deletion mk/host.mk
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ $$(HLIB$(2)_H_$(4))/$(CFG_LIBNATIVE_$(4)): \
$$(HBIN$(2)_H_$(4))/:
mkdir -p $$@

ifneq ($(CFG_LIBDIR),bin)
ifneq ($(LIBDIR_RELATIVE),bin)
$$(HLIB$(2)_H_$(4))/:
mkdir -p $$@
endif
Expand Down
4 changes: 2 additions & 2 deletions mk/install.mk
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ ISTAGE = 2

PREFIX_ROOT = $(CFG_PREFIX)
PREFIX_BIN = $(PREFIX_ROOT)/bin
PREFIX_LIB = $(PREFIX_ROOT)/$(CFG_LIBDIR)
PREFIX_LIB = $(CFG_LIBDIR)

define INSTALL_PREPARE_N
# $(1) is the target triple
Expand All @@ -76,7 +76,7 @@ TL$(1)$(2) = $$(TLIB$$(ISTAGE)_T_$(1)_H_$(2))
# PT{R,B,L} == Prefix Target {Root, Bin, Lib}
PTR$(1)$(2) = $$(PREFIX_LIB)/$(CFG_RUSTLIBDIR)/$(1)
PTB$(1)$(2) = $$(PTR$(1)$(2))/bin
PTL$(1)$(2) = $$(PTR$(1)$(2))/$(CFG_LIBDIR)
PTL$(1)$(2) = $$(PTR$(1)$(2))/lib

endef

Expand Down
2 changes: 0 additions & 2 deletions mk/target.mk
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,8 @@ endif
$$(TBIN$(1)_T_$(2)_H_$(3))/:
mkdir -p $$@

ifneq ($(CFG_LIBDIR),bin)
$$(TLIB$(1)_T_$(2)_H_$(3))/:
mkdir -p $$@
endif

endef

Expand Down
10 changes: 5 additions & 5 deletions mk/tests.mk
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ endif
ifdef CFG_WINDOWSY_$(1)
CFG_TESTLIB_$(1)=$$(CFG_BUILD_DIR)$$(2)/$$(strip \
$$(if $$(findstring stage0,$$(1)), \
stage0/$$(CFG_LIBDIR), \
stage0/$$(LIBDIR_RELATIVE), \
$$(if $$(findstring stage1,$$(1)), \
stage1/$$(CFG_LIBDIR), \
stage1/$$(LIBDIR_RELATIVE), \
$$(if $$(findstring stage2,$$(1)), \
stage2/$$(CFG_LIBDIR), \
stage2/$$(LIBDIR_RELATIVE), \
$$(if $$(findstring stage3,$$(1)), \
stage3/$$(CFG_LIBDIR), \
)))))/$$(CFG_RUSTLIBDIR)/$$(CFG_BUILD)/$$(CFG_LIBDIR)
stage3/$$(LIBDIR_RELATIVE), \
)))))/$$(CFG_RUSTLIBDIR)/$$(CFG_BUILD)/lib
CFG_RUN_TEST_$(1)=$$(call CFG_RUN_$(1),$$(call CFG_TESTLIB_$(1),$$(1),$$(3)),$$(1))
endif

Expand Down
7 changes: 3 additions & 4 deletions src/librustc/metadata/filesearch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,11 @@ pub fn search(filesearch: @FileSearch, pick: pick) {
}

pub fn relative_target_lib_path(target_triple: &str) -> Path {
let dir = libdir();
let mut p = Path::new(dir.as_slice());
let mut p = Path::new(libdir());
assert!(p.is_relative());
p.push(rustlibdir());
p.push(target_triple);
p.push(dir);
p.push("lib");
p
}

Expand Down Expand Up @@ -245,7 +244,7 @@ pub fn rust_path() -> ~[Path] {
// The name of the directory rustc expects libraries to be located.
// On Unix should be "lib", on windows "bin"
pub fn libdir() -> ~str {
(env!("CFG_LIBDIR")).to_owned()
(env!("LIBDIR_RELATIVE")).to_owned()
}

// The name of rustc's own place to organize libraries.
Expand Down