Skip to content

Commit e130e7b

Browse files
committed
Display an error when linking fails
1 parent e60cb91 commit e130e7b

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/comp/driver/rustc.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,13 @@ fn main(vec[str] args) {
419419
}
420420
}
421421

422-
gcc_args += sess.get_used_crate_files();
422+
for (str cratepath in sess.get_used_crate_files()) {
423+
auto dir = fs::dirname(cratepath);
424+
if (dir != "") {
425+
gcc_args += ["-L" + dir];
426+
}
427+
gcc_args += [fs::basename(cratepath)];
428+
}
423429

424430
auto used_libs = sess.get_used_libraries();
425431
for (str l in used_libs) {
@@ -435,7 +441,12 @@ fn main(vec[str] args) {
435441
}
436442
// We run 'gcc' here
437443

438-
run::run_program(prog, gcc_args);
444+
auto err_code = run::run_program(prog, gcc_args);
445+
if (0 != err_code) {
446+
sess.err(#fmt("linking with gcc failed with code %d", err_code));
447+
sess.note(#fmt("gcc arguments: %s", str::connect(gcc_args, " ")));
448+
sess.abort_if_errors();
449+
}
439450
// Clean up on Darwin
440451

441452
if (sess.get_targ_cfg().os == session::os_macos) {

0 commit comments

Comments
 (0)