From 1dbc0442cddb0317938a481b7afb7e4113658d78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20=C3=81vila=20de=20Esp=C3=ADndola?= Date: Fri, 17 Jun 2011 13:36:08 -0400 Subject: [PATCH] Automatically add a -L to the directory the binary is in. --- Makefile.in | 6 +++--- src/comp/driver/rustc.rs | 9 +++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Makefile.in b/Makefile.in index 9c471ee2aae..3c56c5694db 100644 --- a/Makefile.in +++ b/Makefile.in @@ -109,13 +109,13 @@ STAGE0 := $(Q)$(call CFG_RUN_TARG,stage0,\ stage0/rustc$(X) $(CFG_RUSTC_FLAGS) -L stage0) STAGE1 := $(Q)$(call CFG_RUN_TARG,stage0, \ $(CFG_VALGRIND_COMPILE) stage1/rustc$(X) \ - $(CFG_RUSTC_FLAGS) -L stage1) + $(CFG_RUSTC_FLAGS)) STAGE2 := $(Q)$(call CFG_RUN_TARG,stage1, \ $(CFG_VALGRIND_COMPILE) stage2/rustc$(X) \ - $(CFG_RUSTC_FLAGS) -L stage2) + $(CFG_RUSTC_FLAGS)) STAGE3 := $(Q)$(call CFG_RUN_TARG,stage2, \ $(CFG_VALGRIND_COMPILE) stage3/rustc$(X) \ - $(CFG_RUSTC_FLAGS) -L stage3) + $(CFG_RUSTC_FLAGS)) # "Source" files we generate in builddir along the way. GENERATED := diff --git a/src/comp/driver/rustc.rs b/src/comp/driver/rustc.rs index 8dfa6cb7b46..0a340e4758e 100644 --- a/src/comp/driver/rustc.rs +++ b/src/comp/driver/rustc.rs @@ -202,10 +202,11 @@ fn build_target_config() -> @session::config { ret target_cfg; } -fn build_session_options(str binary, getopts::match match) -> +fn build_session_options(str binary, getopts::match match, str binary_dir) -> @session::options { auto shared = opt_present(match, "shared"); - auto library_search_paths = getopts::opt_strs(match, "L"); + auto library_search_paths = [binary_dir]; + library_search_paths += getopts::opt_strs(match, "L"); auto output_type = if (opt_present(match, "parse-only")) { link::output_type_none @@ -297,6 +298,7 @@ fn main(vec[str] args) { optflag("time-llvm-passes"), optflag("no-typestate"), optflag("noverify")]; auto binary = vec::shift[str](args); + auto binary_dir = fs::dirname(binary); auto match = alt (getopts::getopts(args, opts)) { case (getopts::success(?m)) { m } @@ -313,7 +315,7 @@ fn main(vec[str] args) { version(binary); ret; } - auto sopts = build_session_options(binary, match); + auto sopts = build_session_options(binary, match, binary_dir); auto sess = build_session(sopts); auto n_inputs = vec::len[str](match.free); auto output_file = getopts::opt_maybe_str(match, "o"); @@ -391,7 +393,6 @@ fn main(vec[str] args) { // // TODO: Factor this out of main. if (sopts.output_type == link::output_type_exe) { - auto binary_dir = fs::dirname(binary); let str glu = binary_dir + "/glue.o"; let str main = "rt/main.o"; let str stage = "-L" + binary_dir;