mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
Auto merge of #124858 - alexcrichton:some-wasi-changes, r=michaelwoerister
rustc: Some small changes for the wasm32-wasip2 target This commit has a few changes for the wasm32-wasip2 target. The first two are aimed at improving the compatibility of using `clang` as an external linker driver on this target. The default target to LLVM is updated to match the Rust target and additionally the `-fuse-ld=lld` argument is dropped since that otherwise interferes with clang's own linker detection. The only linker on wasm targets is LLD but on the wasip2 target a wrapper around LLD, `wasm-component-ld`, is used to drive the process and perform steps necessary for componentization. The final commit changes the output of all objects on the wasip2 target to being PIC by default. This improves compatibilty with shared libaries but notably does not mean that there's a turnkey solution for shared libraries. The hope is that by having the standard libray work both with and without dynamic libraries will make experimentation easier.
This commit is contained in:
commit
e3029d220f
@ -3127,7 +3127,13 @@ fn add_lld_args(
|
|||||||
|
|
||||||
// 2. Implement the "linker flavor" part of this feature by asking `cc` to use some kind of
|
// 2. Implement the "linker flavor" part of this feature by asking `cc` to use some kind of
|
||||||
// `lld` as the linker.
|
// `lld` as the linker.
|
||||||
cmd.arg("-fuse-ld=lld");
|
//
|
||||||
|
// Note that wasm targets skip this step since the only option there anyway
|
||||||
|
// is to use LLD but the `wasm32-wasip2` target relies on a wrapper around
|
||||||
|
// this, `wasm-component-ld`, which is overridden if this option is passed.
|
||||||
|
if !sess.target.is_like_wasm {
|
||||||
|
cmd.arg("-fuse-ld=lld");
|
||||||
|
}
|
||||||
|
|
||||||
if !flavor.is_gnu() {
|
if !flavor.is_gnu() {
|
||||||
// Tell clang to use a non-default LLD flavor.
|
// Tell clang to use a non-default LLD flavor.
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
use crate::spec::crt_objects;
|
use crate::spec::crt_objects;
|
||||||
use crate::spec::LinkSelfContainedDefault;
|
use crate::spec::LinkSelfContainedDefault;
|
||||||
use crate::spec::{base, Target};
|
use crate::spec::{base, RelocModel, Target};
|
||||||
|
|
||||||
pub fn target() -> Target {
|
pub fn target() -> Target {
|
||||||
let mut options = base::wasm::options();
|
let mut options = base::wasm::options();
|
||||||
@ -54,8 +54,13 @@ pub fn target() -> Target {
|
|||||||
// signatures.
|
// signatures.
|
||||||
options.entry_name = "__main_void".into();
|
options.entry_name = "__main_void".into();
|
||||||
|
|
||||||
|
// Default to PIC unlike base wasm. This makes precompiled objects such as
|
||||||
|
// the standard library more suitable to be used with shared libaries a la
|
||||||
|
// emscripten's dynamic linking convention.
|
||||||
|
options.relocation_model = RelocModel::Pic;
|
||||||
|
|
||||||
Target {
|
Target {
|
||||||
llvm_target: "wasm32-unknown-unknown".into(),
|
llvm_target: "wasm32-wasip2".into(),
|
||||||
metadata: crate::spec::TargetMetadata {
|
metadata: crate::spec::TargetMetadata {
|
||||||
description: None,
|
description: None,
|
||||||
tier: None,
|
tier: None,
|
||||||
|
Loading…
Reference in New Issue
Block a user