Skip to content

compiler-rt #12027

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 12, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@
[submodule "src/gyp"]
path = src/gyp
url = https://github.com/rust-lang/gyp.git
[submodule "src/compiler-rt"]
path = src/compiler-rt
url = https://github.com/rust-lang/compiler-rt.git
3 changes: 2 additions & 1 deletion Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,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
Expand Down
3 changes: 3 additions & 0 deletions mk/clean.mk
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ clean-generic-$(2)-$(1):
$(1)/rt \
$(1)/test \
$(1)/stage* \
-type f \( \
-name '*.[odasS]' -o \
-name '*.so' -o \
-name '*.dylib' -o \
Expand All @@ -62,6 +63,7 @@ clean-generic-$(2)-$(1):
-name '*.dll' -o \
-name '*.def' -o \
-name '*.bc' \
\) \
| xargs rm -f
$(Q)find $(1)\
-name '*.dSYM' \
Expand Down Expand Up @@ -96,6 +98,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

Expand Down
2 changes: 1 addition & 1 deletion mk/crates.mk
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ HOST_CRATES := syntax rustc rustdoc fourcc
CRATES := $(TARGET_CRATES) $(HOST_CRATES)
TOOLS := compiletest rustdoc rustc

DEPS_std := native:rustrt
DEPS_std := native:rustrt native:compiler-rt
DEPS_extra := std term sync serialize getopts collections
DEPS_green := std
DEPS_rustuv := std native:uv native:uv_support
Expand Down
2 changes: 2 additions & 0 deletions mk/install.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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), \
Expand Down
31 changes: 31 additions & 0 deletions mk/rt.mk
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,37 @@ $$(LIBUV_DIR_$(1))/Release/libuv.a: $$(LIBUV_DEPS) $$(LIBUV_MAKEFILE_$(1)) \

endif

################################################################################
# compiler-rt
################################################################################

ifdef CFG_ENABLE_FAST_MAKE
COMPRT_DEPS := $(S)/.gitmodules
else
COMPRT_DEPS := $(wildcard \
$(S)src/compiler-rt/* \
$(S)src/compiler-rt/*/* \
$(S)src/compiler-rt/*/*/* \
$(S)src/compiler-rt/*/*/*/*)
endif

COMPRT_NAME_$(1) := $$(call CFG_STATIC_LIB_NAME_$(1),compiler-rt)
COMPRT_LIB_$(1) := $$(RT_OUTPUT_DIR_$(1))/$$(COMPRT_NAME_$(1))
COMPRT_BUILD_DIR_$(1) := $$(RT_OUTPUT_DIR_$(1))/compiler-rt

$$(COMPRT_LIB_$(1)): $$(COMPRT_DEPS)
@$$(call E, make: compiler-rt)
$$(Q)$$(MAKE) -C "$(S)src/compiler-rt" \
ProjSrcRoot="$(S)src/compiler-rt" \
ProjObjRoot="$$(abspath $$(COMPRT_BUILD_DIR_$(1)))" \
CC="$$(CC_$(1))" \
AR="$$(AR_$(1))" \
RANLIB="$$(AR_$(1)) s" \
CFLAGS="$$(CFG_GCCISH_CFLAGS_$(1))" \
TargetTriple=$(1) \
triple-runtime
$$(Q)cp $$(COMPRT_BUILD_DIR_$(1))/triple/runtime/libcompiler_rt.a $$(COMPRT_LIB_$(1))

endef

# Instantiate template for all stages/targets
Expand Down
6 changes: 6 additions & 0 deletions mk/target.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions mk/tests.mk
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ tidy:
| grep '^$(S)src/gyp' -v \
| grep '^$(S)src/etc' -v \
| grep '^$(S)src/doc' -v \
| grep '^$(S)src/compiler-rt' -v \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you exclude compiler-rt from the tidy check above as well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wait, they have nothing related to *.rs, nvmd

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This to to prevent tidy from complaining about "checked-in binaries", which all extension-less files are deemed to be.

| xargs $(CFG_PYTHON) $(S)src/etc/check-binaries.py

endif
Expand Down
1 change: 1 addition & 0 deletions src/compiler-rt
Submodule compiler-rt added at d4606f
17 changes: 14 additions & 3 deletions src/librustc/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,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() {
Expand Down Expand Up @@ -1130,6 +1131,19 @@ fn link_args(sess: Session,
args.push(~"-shared-libgcc");
}

if sess.targ_cfg.os == abi::OsAndroid {
// Many of the symbols defined in compiler-rt are also defined in libgcc.
// Android linker doesn't like that by default.
args.push(~"-Wl,--allow-multiple-definition");
}

// Stack growth requires statically linking a __morestack function
args.push(~"-lmorestack");
// compiler-rt contains implementations of low-level LLVM helpers
// It should go before platform and user libraries, so it has first dibs
// at resolving symbols that also appear in libgcc.
args.push(~"-lcompiler-rt");

add_local_native_libraries(&mut args, sess);
add_upstream_rust_crates(&mut args, sess, dylib, tmpdir);
add_upstream_native_libraries(&mut args, sess);
Expand Down Expand Up @@ -1157,9 +1171,6 @@ fn link_args(sess: Session,
~"-L/usr/local/lib/gcc44"]);
}

// Stack growth requires statically linking a __morestack function
args.push(~"-lmorestack");

// FIXME (#2397): At some point we want to rpath our guesses as to
// where extern libraries might live, based on the
// addl_lib_search_paths
Expand Down