Skip to content
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

rustc: Some small changes for the wasm32-wasip2 target #124858

Merged
merged 3 commits into from
May 8, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
rustc: Change wasm32-wasip2 to PIC-by-default
This commit changes the new `wasm32-wasip2` target to being PIC by
default rather than the previous non-PIC by default. This change is
intended to make it easier for the standard library to be used in a
shared object in its precompiled form. This comes with a hypothetical
modest slowdown but it's expected that this is quite minor in most use
cases or otherwise wasm compilers and/or optimizing runtimes can elide
the cost.
  • Loading branch information
alexcrichton committed May 7, 2024
commit 38b2bd782b251b4d729ba8fd9daadc774f9b4008
7 changes: 6 additions & 1 deletion compiler/rustc_target/src/spec/targets/wasm32_wasip2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

use crate::spec::crt_objects;
use crate::spec::LinkSelfContainedDefault;
use crate::spec::{base, Target};
use crate::spec::{base, RelocModel, Target};

pub fn target() -> Target {
let mut options = base::wasm::options();
Expand Down Expand Up @@ -54,6 +54,11 @@ pub fn target() -> Target {
// signatures.
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 {
llvm_target: "wasm32-wasip2".into(),
metadata: crate::spec::TargetMetadata {
Expand Down
Loading