Skip to content

Add support for setting the soname of generated dynamic libraries #31170

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

Closed
wants to merge 2 commits into from
Closed
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
1 change: 1 addition & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions mk/target.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
Expand Down Expand Up @@ -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)) \
Expand Down