Skip to content

Instantly share code, notes, and snippets.

@alexcrichton
Created February 11, 2014 01:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexcrichton/8927784 to your computer and use it in GitHub Desktop.
Save alexcrichton/8927784 to your computer and use it in GitHub Desktop.
diff --git a/Makefile.in b/Makefile.in
index 05b6215..4d2bd0a 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -354,7 +354,8 @@ endif
# Prerequisites for using the stageN compiler to build target artifacts
TSREQ$(1)_T_$(2)_H_$(3) = \
$$(HSREQ$(1)_H_$(3)) \
- $$(TLIB$(1)_T_$(2)_H_$(3))/libmorestack.a
+ $$(TLIB$(1)_T_$(2)_H_$(3))/libmorestack.a \
+ $$(TLIB$(1)_T_$(2)_H_$(3))/libcompiler-rt.a
# Prerequisites for a working stageN compiler and libraries, for a specific
# target
diff --git a/mk/clean.mk b/mk/clean.mk
index edd0554..8484e7b 100644
--- a/mk/clean.mk
+++ b/mk/clean.mk
@@ -96,6 +96,7 @@ clean$(1)_T_$(2)_H_$(3): \
$$(foreach crate,$$(CRATES),clean$(1)_T_$(2)_H_$(3)-lib-$$(crate)) \
$$(foreach tool,$$(TOOLS),clean$(1)_T_$(2)_H_$(3)-tool-$$(tool))
$$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/libmorestack.a
+ $$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/libcompiler-rt.a
$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/librun_pass_stage* # For unix
$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/run_pass_stage* # For windows
diff --git a/mk/install.mk b/mk/install.mk
index 73c8f2c..156a545 100644
--- a/mk/install.mk
+++ b/mk/install.mk
@@ -96,6 +96,7 @@ install-target-$(1)-host-$(2): \
$$(call INSTALL_LIB,$$(call CFG_LIB_GLOB_$(1),$$(crate)));\
$$(call INSTALL_LIB,$$(call CFG_RLIB_GLOB,$$(crate)));)
$$(Q)$$(call INSTALL_LIB,libmorestack.a)
+ $$(Q)$$(call INSTALL_LIB,libcompiler-rt.a)
endef
@@ -110,6 +111,7 @@ install-target-$(1)-host-$(2): $$(CSREQ$$(ISTAGE)_T_$(1)_H_$(2))
$$(Q)$$(foreach crate,$$(TARGET_CRATES),\
$$(call INSTALL_LIB,$$(call CFG_RLIB_GLOB,$$(crate)));)
$$(Q)$$(call INSTALL_LIB,libmorestack.a)
+ $$(Q)$$(call INSTALL_LIB,libcompiler-rt.a)
endef
$(foreach target,$(CFG_TARGET), \
diff --git a/mk/target.mk b/mk/target.mk
index c4bd082..f03cb81 100644
--- a/mk/target.mk
+++ b/mk/target.mk
@@ -138,6 +138,12 @@ $$(TBIN$(1)_T_$(2)_H_$(3))/:
$$(TLIB$(1)_T_$(2)_H_$(3))/:
mkdir -p $$@
+$$(TLIB$(1)_T_$(2)_H_$(3))/libcompiler-rt.a: \
+ $$(RT_OUTPUT_DIR_$(2))/$$(call CFG_STATIC_LIB_NAME_$(2),compiler-rt) \
+ | $$(TLIB$(1)_T_$(2)_H_$(3))/ $$(SNAPSHOT_RUSTC_POST_CLEANUP)
+ @$$(call E, cp: $$@)
+ $$(Q)cp $$< $$@
+
$$(TLIB$(1)_T_$(2)_H_$(3))/libmorestack.a: \
$$(RT_OUTPUT_DIR_$(2))/$$(call CFG_STATIC_LIB_NAME_$(2),morestack) \
| $$(TLIB$(1)_T_$(2)_H_$(3))/ $$(SNAPSHOT_RUSTC_POST_CLEANUP)
diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs
index 70dbac4..c3a8c27 100644
--- a/src/librustc/back/link.rs
+++ b/src/librustc/back/link.rs
@@ -987,6 +987,7 @@ fn link_rlib(sess: Session,
fn link_staticlib(sess: Session, obj_filename: &Path, out_filename: &Path) {
let mut a = link_rlib(sess, None, obj_filename, out_filename);
a.add_native_library("morestack").unwrap();
+ a.add_native_library("compiler-rt").unwrap();
let crates = sess.cstore.get_used_crates(cstore::RequireStatic);
for &(cnum, ref path) in crates.iter() {
@@ -1149,6 +1150,7 @@ fn link_args(sess: Session,
// Stack growth requires statically linking a __morestack function
args.push(~"-lmorestack");
+ args.push(~"-lcompiler-rt");
// FIXME (#2397): At some point we want to rpath our guesses as to
// where extern libraries might live, based on the
diff --git a/src/libstd/rtdeps.rs b/src/libstd/rtdeps.rs
index b19d97f..045cdf5 100644
--- a/src/libstd/rtdeps.rs
+++ b/src/libstd/rtdeps.rs
@@ -12,9 +12,8 @@
//! the standard library This varies per-platform, but these libraries are
//! necessary for running libstd.
-// All platforms need to link to rustrt and compiler-rt
+// All platforms need to link to rustrt
#[link(name = "rustrt", kind = "static")]
-#[link(name = "compiler-rt", kind = "static")]
extern {}
// LLVM implements the `frem` instruction as a call to `fmod`, which lives in
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment