Skip to content

Commit b42e551

Browse files
committed
Only link librt on linux
1 parent ad5014b commit b42e551

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/comp/back/link.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,14 @@ fn link_binary(sess: session::session,
582582
gcc_args += ["-lm", main];
583583
}
584584

585-
gcc_args += ["-lrustrt", "-lrt"];
585+
// On linux librt is an indirect dependency via rustrt,
586+
// and binutils 2.22+ won't add it automatically
587+
if sess.get_targ_cfg().os == session::os_linux {
588+
gcc_args += ["-lrt"];
589+
}
590+
591+
// Always want the runtime linked in
592+
gcc_args += ["-lrustrt"];
586593

587594
gcc_args += rpath::get_rpath_flags(sess, saved_out_filename);
588595

0 commit comments

Comments
 (0)