You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
3.8 KiB
79 lines
3.8 KiB
From 79bb610c8fc5d9df7dd4720ae847b8f17e7b1ad4 Mon Sep 17 00:00:00 2001
|
|
From: Josh Stone <jistone@redhat.com>
|
|
Date: Thu, 28 Sep 2023 18:18:16 -0700
|
|
Subject: [PATCH 2/2] set an external library path for wasm32-wasi
|
|
|
|
---
|
|
compiler/rustc_codegen_ssa/src/back/link.rs | 9 +++++++++
|
|
compiler/rustc_target/src/spec/mod.rs | 2 ++
|
|
compiler/rustc_target/src/spec/targets/wasm32_wasi.rs | 6 +++++-
|
|
3 files changed, 16 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs
|
|
index dd9d277fb775..3d0f0502f255 100644
|
|
--- a/compiler/rustc_codegen_ssa/src/back/link.rs
|
|
+++ b/compiler/rustc_codegen_ssa/src/back/link.rs
|
|
@@ -1496,6 +1496,12 @@ fn get_object_file_path(sess: &Session, name: &str, self_contained: bool) -> Pat
|
|
return file_path;
|
|
}
|
|
}
|
|
+ if let Some(lib_path) = &sess.target.options.external_lib_path {
|
|
+ let file_path = Path::new(lib_path.as_ref()).join(name);
|
|
+ if file_path.exists() {
|
|
+ return file_path;
|
|
+ }
|
|
+ }
|
|
for search_path in fs.search_paths() {
|
|
let file_path = search_path.dir.join(name);
|
|
if file_path.exists() {
|
|
@@ -1982,6 +1988,9 @@ fn add_library_search_dirs(cmd: &mut dyn Linker, sess: &Session, self_contained:
|
|
let lib_path = sess.target_filesearch(PathKind::All).get_self_contained_lib_path();
|
|
cmd.include_path(&fix_windows_verbatim_for_gcc(&lib_path));
|
|
}
|
|
+ if let Some(lib_path) = &sess.target.options.external_lib_path {
|
|
+ cmd.include_path(Path::new(lib_path.as_ref()));
|
|
+ }
|
|
}
|
|
|
|
/// Add options making relocation sections in the produced ELF files read-only
|
|
diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs
|
|
index f04799482c83..25410b37ba24 100644
|
|
--- a/compiler/rustc_target/src/spec/mod.rs
|
|
+++ b/compiler/rustc_target/src/spec/mod.rs
|
|
@@ -1874,6 +1874,7 @@ pub struct TargetOptions {
|
|
/// Objects to link before and after all other object code.
|
|
pub pre_link_objects: CrtObjects,
|
|
pub post_link_objects: CrtObjects,
|
|
+ pub external_lib_path: Option<StaticCow<str>>,
|
|
/// Same as `(pre|post)_link_objects`, but when self-contained linking mode is enabled.
|
|
pub pre_link_objects_self_contained: CrtObjects,
|
|
pub post_link_objects_self_contained: CrtObjects,
|
|
@@ -2352,6 +2353,7 @@ fn default() -> TargetOptions {
|
|
relro_level: RelroLevel::None,
|
|
pre_link_objects: Default::default(),
|
|
post_link_objects: Default::default(),
|
|
+ external_lib_path: None,
|
|
pre_link_objects_self_contained: Default::default(),
|
|
post_link_objects_self_contained: Default::default(),
|
|
link_self_contained: LinkSelfContainedDefault::False,
|
|
diff --git a/compiler/rustc_target/src/spec/targets/wasm32_wasi.rs b/compiler/rustc_target/src/spec/targets/wasm32_wasi.rs
|
|
index 6dbcb01ea436..2151f86d0648 100644
|
|
--- a/compiler/rustc_target/src/spec/targets/wasm32_wasi.rs
|
|
+++ b/compiler/rustc_target/src/spec/targets/wasm32_wasi.rs
|
|
@@ -86,7 +86,11 @@ pub fn target() -> Target {
|
|
options.post_link_objects_self_contained = crt_objects::post_wasi_self_contained();
|
|
|
|
// FIXME: Figure out cases in which WASM needs to link with a native toolchain.
|
|
- options.link_self_contained = LinkSelfContainedDefault::True;
|
|
+ options.link_self_contained = LinkSelfContainedDefault::False;
|
|
+
|
|
+ options.pre_link_objects = options.pre_link_objects_self_contained.clone();
|
|
+ options.post_link_objects = options.post_link_objects_self_contained.clone();
|
|
+ options.external_lib_path = Some("/usr/wasm32-wasi/lib/wasm32-wasi".into());
|
|
|
|
// Right now this is a bit of a workaround but we're currently saying that
|
|
// the target by default has a static crt which we're taking as a signal
|
|
--
|
|
2.41.0
|
|
|