mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
Make rpath work on mac
This commit is contained in:
parent
9c037d2194
commit
d8a85f0758
@ -22,6 +22,7 @@ ifneq ($(findstring freebsd,$(CFG_OSTYPE)),)
|
||||
CFG_UNIXY := 1
|
||||
CFG_LDENV := LD_LIBRARY_PATH
|
||||
CFG_DEF_SUFFIX := .bsd.def
|
||||
CFG_INSTALL_NAME =
|
||||
endif
|
||||
|
||||
ifneq ($(findstring linux,$(CFG_OSTYPE)),)
|
||||
@ -48,6 +49,7 @@ ifneq ($(findstring linux,$(CFG_OSTYPE)),)
|
||||
CFG_PERF_TOOL := /usr/bin/time --verbose
|
||||
endif
|
||||
endif
|
||||
CFG_INSTALL_NAME =
|
||||
endif
|
||||
|
||||
ifneq ($(findstring darwin,$(CFG_OSTYPE)),)
|
||||
@ -71,6 +73,8 @@ ifneq ($(findstring darwin,$(CFG_OSTYPE)),)
|
||||
CFG_GCCISH_LINK_FLAGS += -m32
|
||||
CFG_DSYMUTIL := dsymutil
|
||||
CFG_DEF_SUFFIX := .darwin.def
|
||||
# Mac requires this flag to make rpath work
|
||||
CFG_INSTALL_NAME = -Wl,-install_name,@rpath/$(1)
|
||||
endif
|
||||
|
||||
ifneq ($(findstring mingw,$(CFG_OSTYPE)),)
|
||||
@ -154,7 +158,7 @@ ifdef CFG_WINDOWSY
|
||||
CFG_GCCISH_CFLAGS += -march=i686
|
||||
CFG_GCCISH_LINK_FLAGS += -shared -fPIC
|
||||
endif
|
||||
|
||||
CFG_INSTALL_NAME =
|
||||
endif
|
||||
|
||||
|
||||
@ -169,7 +173,7 @@ ifeq ($(CFG_C_COMPILER),clang)
|
||||
CFG_DEPEND_C = $(CFG_GCCISH_CROSS)$(CXX) $(CFG_GCCISH_CFLAGS) -MT "$(1)" \
|
||||
-MM $(2)
|
||||
CFG_LINK_C = $(CFG_GCCISH_CROSS)$(CXX) $(CFG_GCCISH_LINK_FLAGS) -o $(1) \
|
||||
$(CFG_GCCISH_DEF_FLAG)$(3) $(2)
|
||||
$(CFG_GCCISH_DEF_FLAG)$(3) $(2) $(call CFG_INSTALL_NAME,$(4))
|
||||
else
|
||||
ifeq ($(CFG_C_COMPILER),gcc)
|
||||
CC=gcc
|
||||
@ -181,7 +185,7 @@ ifeq ($(CFG_C_COMPILER),gcc)
|
||||
CFG_DEPEND_C = $(CFG_GCCISH_CROSS)$(CXX) $(CFG_GCCISH_CFLAGS) -MT "$(1)" \
|
||||
-MM $(2)
|
||||
CFG_LINK_C = $(CFG_GCCISH_CROSS)$(CXX) $(CFG_GCCISH_LINK_FLAGS) -o $(1) \
|
||||
$(CFG_GCCISH_DEF_FLAG)$(3) $(2)
|
||||
$(CFG_GCCISH_DEF_FLAG)$(3) $(2) $(call CFG_INSTALL_NAME,$(4))
|
||||
else
|
||||
CFG_ERR := $(error please try on a system with gcc or clang)
|
||||
endif
|
||||
|
2
mk/rt.mk
2
mk/rt.mk
@ -112,7 +112,7 @@ rt/$(CFG_RUNTIME): $(RUNTIME_OBJS) $(MKFILES) $(RUNTIME_HDR) $(RUNTIME_DEF) $(RU
|
||||
@$(call E, link: $@)
|
||||
$(Q)$(call CFG_LINK_C,$@, $(RUNTIME_OBJS) \
|
||||
$(CFG_GCCISH_POST_LIB_FLAGS) $(RUNTIME_LIBS) \
|
||||
$(CFG_LIBUV_LINK_FLAGS),$(RUNTIME_DEF))
|
||||
$(CFG_LIBUV_LINK_FLAGS),$(RUNTIME_DEF),$(CFG_RUNTIME))
|
||||
|
||||
# FIXME: For some reason libuv's makefiles can't figure out the correct definition
|
||||
# of CC on the mingw I'm using, so we are explicitly using gcc. Also, we
|
||||
|
@ -17,7 +17,7 @@ rustllvm/$(CFG_RUSTLLVM): $(RUSTLLVM_OBJS_OBJS) \
|
||||
$(Q)$(call CFG_LINK_C,$@,$(RUSTLLVM_OBJS_OBJS) \
|
||||
$(CFG_GCCISH_PRE_LIB_FLAGS) $(CFG_LLVM_LIBS) \
|
||||
$(CFG_GCCISH_POST_LIB_FLAGS) \
|
||||
$(CFG_LLVM_LDFLAGS),$(RUSTLLVM_DEF))
|
||||
$(CFG_LLVM_LDFLAGS),$(RUSTLLVM_DEF),$(CFG_RUSTLLVM))
|
||||
|
||||
rustllvm/%.o: rustllvm/%.cpp $(MKFILES)
|
||||
@$(call E, compile: $@)
|
||||
|
@ -567,6 +567,13 @@ fn link_binary(sess: session::session,
|
||||
|
||||
if sess.get_opts().library {
|
||||
gcc_args += [lib_cmd];
|
||||
|
||||
// On mac we need to tell the linker to let this library
|
||||
// be rpathed
|
||||
if sess.get_targ_cfg().os == session::os_macos {
|
||||
gcc_args += ["-Wl,-install_name,@rpath/"
|
||||
+ fs::basename(saved_out_filename)];
|
||||
}
|
||||
} else {
|
||||
// FIXME: why do we hardcode -lm?
|
||||
gcc_args += ["-lm", main];
|
||||
|
Loading…
Reference in New Issue
Block a user