smlinux/base/rust/need-rpath.patch
PktSurf 9d657e0a1d Upgraded base/perl to 5.38.0
Renamed .SMBuild files to smbuild for simplicity
Added musl-fts, musl-obstack, glslang, python-glad, libptytty, libmilter, elfutils and fuse to base section build list
Discarded fuse2 and fuse3 from base section
Temporarily discarded slapt-get, syslinux, p7zip, acpid, libelf-compat, gnu-eif, libtirpc, mozilla-nss,
lua53, qpdf, kernel-source and signify from base section build list
Disabled nls and made amends to base/e2fsprogs
Upgraded base/git to 2.46.2
Upgraded extra/gnumeric to 1.12.57
Disabled nls in base/gnutls, extra/dia
Disabled a patch and made amends in base/llvm
Fixed configure.local file in base/mandoc
Upgraded base/rust to 1.79
Fixed a ton of build files to use build prefix as /usr and miscellaneous changes
Discarded extra/bluez,blueman,scrcpy,adafruit-io
Added tomb to extra
Added new build option to extra/libass
Upgraded extra/mpv to 0.37.0
Disabled tests in gtk/gdk-pixbuf
Upgraded gtk/goffice to 0.10.57
Added gtk-doc to gtk section
Fixed build options in gtk/gtk2
Added new patches to gtk/gtk3
Added gtksourceview to gtk section
Added vulkan-headers to xorg section
Upgraded xorg/mesa to 23.1.9
Added libplacebo to xorg section
Fixed build stuff in xorg/glew
2024-10-29 20:25:20 +05:30

62 lines
2.8 KiB
Diff

From: Shiz <hi@shiz.me>
Date: Thu, 20 Aug 2017 01:48:22 +0200
Subject: [PATCH] Add need_rpath target option to force RPATH generation
This adds a `need_rpath` option to the target options in order to implicitly
have the equivalent of `-C rpath` specified by default for final products
(executables and dynamic libraries), so that RPATHs are always added.
We have to skip this step in the bootstrap phase as it does its own manual
RPATH additions, but unfortunately there's no clean way to detect this.
As such, we have to resort to checking the `RUSTC_BOOTSTRAP` variable.
Hacky hacky!
--- a/compiler/rustc_target/src/spec/mod.rs
+++ b/compiler/rustc_target/src/spec/mod.rs
@@ -2028,6 +2028,8 @@ pub struct TargetOptions {
pub allows_weak_linkage: bool,
/// Whether the linker support rpaths or not. Defaults to false.
pub has_rpath: bool,
+ /// Whether to force rpath support on by default. Defaults to false.
+ pub need_rpath: bool,
/// Whether to disable linking to the default libraries, typically corresponds
/// to `-nodefaultlibs`. Defaults to true.
pub no_default_libraries: bool,
@@ -2372,6 +2374,7 @@ impl Default for TargetOptions {
default_dwarf_version: 4,
allows_weak_linkage: true,
has_rpath: false,
+ need_rpath: false,
no_default_libraries: true,
position_independent_executables: false,
static_position_independent_executables: false,
@@ -3122,6 +3125,7 @@ impl Target {
key!(default_dwarf_version, u32);
key!(allows_weak_linkage, bool);
key!(has_rpath, bool);
+ key!(need_rpath, bool);
key!(no_default_libraries, bool);
key!(position_independent_executables, bool);
key!(static_position_independent_executables, bool);
@@ -3379,6 +3383,7 @@ impl ToJson for Target {
target_option_val!(default_dwarf_version);
target_option_val!(allows_weak_linkage);
target_option_val!(has_rpath);
+ target_option_val!(need_rpath);
target_option_val!(no_default_libraries);
target_option_val!(position_independent_executables);
target_option_val!(static_position_independent_executables);
--- a/compiler/rustc_codegen_ssa/src/back/link.rs.orig
+++ b/compiler/rustc_codegen_ssa/src/back/link.rs
@@ -2072,7 +2072,10 @@
// FIXME (#2397): At some point we want to rpath our guesses as to
// where extern libraries might live, based on the
// add_lib_search_paths
- if sess.opts.cg.rpath {
+ // XXX: hacky hacky
+ let bootstrap = env::var("RUSTC_BOOTSTRAP").is_ok();
+ if !bootstrap && !sess.crt_static(None) &&
+ (sess.opts.cg.rpath || sess.target.options.need_rpath) {
let libs = codegen_results
.crate_info
.used_crates