diff --git a/configure b/configure index 7df98d1bd565d..e2c9600cd91d9 100755 --- a/configure +++ b/configure @@ -595,6 +595,7 @@ opt fast-make 0 "use .gitmodules as timestamp for submodule deps" opt ccache 0 "invoke gcc/clang via ccache to reuse object files between builds" opt local-rust 0 "use an installed rustc rather than downloading a snapshot" opt llvm-static-stdcpp 0 "statically link to libstdc++ for LLVM" +opt soname 0 "set the soname when building dynamic libraries" opt rpath 1 "build rpaths into rustc itself" opt stage0-landing-pads 1 "enable landing pads during bootstrap with stage0" # This is used by the automation to produce single-target nightlies diff --git a/mk/target.mk b/mk/target.mk index f90b09479c985..fa65dfa2a34cb 100644 --- a/mk/target.mk +++ b/mk/target.mk @@ -25,6 +25,24 @@ RUST_LIB_FLAGS_ST0 += -W warnings RUST_LIB_FLAGS_ST1 += -D warnings RUST_LIB_FLAGS_ST2 += -D warnings +# Macro that declares additional RUST_LIB_FLAGS for a crate at a particular +# stage and target. Currently this is used to set the soname codegen flag. +# +# $(1) - stage +# $(2) - target +# $(3) - crate +define RUST_CRATE_LIB_FLAGS +ifdef CFG_ENABLE_SONAME +RUST_LIB_FLAGS_ST$(1)_$(3)_T_$(2) += \ + -C link-args=-Wl,-soname,$$(call CFG_LIB_NAME_$(2),$(3)-$(CFG_FILENAME_EXTRA)) +endif +endef + +$(foreach target,$(CFG_TARGET), \ + $(foreach stage,$(STAGES), \ + $(foreach crate,$(CRATES), \ + $(eval $(call RUST_CRATE_LIB_FLAGS,$(stage),$(target),$(crate)))))) + # Macro that generates the full list of dependencies for a crate at a particular # stage/target/host tuple. # @@ -89,6 +107,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$(4): \ $(Q)CFG_LLVM_LINKAGE_FILE=$$(LLVM_LINKAGE_PATH_$(2)) \ $$(subst @,,$$(STAGE$(1)_T_$(2)_H_$(3))) \ $$(RUST_LIB_FLAGS_ST$(1)) \ + $$(RUST_LIB_FLAGS_ST$(1)_$(4)_T_$(2)) \ -L "$$(RT_OUTPUT_DIR_$(2))" \ $$(LLVM_LIBDIR_RUSTFLAGS_$(2)) \ $$(LLVM_STDCPP_RUSTFLAGS_$(2)) \