Skip to content

Commit 007422c

Browse files
committed
Change the linkage order on linux and add -ldl
-lrt and -ldl need to be specified after -lrustrt since they are only used by rustrt.
1 parent b42e551 commit 007422c

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/comp/back/link.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -582,15 +582,16 @@ fn link_binary(sess: session::session,
582582
gcc_args += ["-lm", main];
583583
}
584584

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-
}
590585

591586
// Always want the runtime linked in
592587
gcc_args += ["-lrustrt"];
593588

589+
// On linux librt and libdl are an indirect dependencies via rustrt,
590+
// and binutils 2.22+ won't add them automatically
591+
if sess.get_targ_cfg().os == session::os_linux {
592+
gcc_args += ["-lrt", "-ldl"];
593+
}
594+
594595
gcc_args += rpath::get_rpath_flags(sess, saved_out_filename);
595596

596597
log #fmt("gcc link args: %s", str::connect(gcc_args, " "));

0 commit comments

Comments
 (0)