Skip to content

Commit 70ddd2f

Browse files
committed
Update data layout for wasm32 targets
New address spaces were added in https://reviews.llvm.org/D111154.
1 parent a380581 commit 70ddd2f

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

compiler/rustc_codegen_llvm/src/context.rs

+3
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ pub unsafe fn create_module<'ll>(
154154
"e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:32-n8:16:32-a:0:32-S32"
155155
.to_string();
156156
}
157+
if sess.target.arch == "wasm32" {
158+
target_data_layout = target_data_layout.replace("-p10:8:8-p20:8:8", "");
159+
}
157160
}
158161

159162
// Ensure the data-layout values hardcoded remain the defaults.

compiler/rustc_target/src/spec/wasm32_unknown_emscripten.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ pub fn target() -> Target {
4343
Target {
4444
llvm_target: "wasm32-unknown-emscripten".to_string(),
4545
pointer_width: 32,
46-
data_layout: "e-m:e-p:32:32-i64:64-f128:64-n32:64-S128-ni:1:10:20".to_string(),
46+
data_layout: "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-f128:64-n32:64-S128-ni:1:10:20"
47+
.to_string(),
4748
arch: "wasm32".to_string(),
4849
options: opts,
4950
}

compiler/rustc_target/src/spec/wasm32_unknown_unknown.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub fn target() -> Target {
5454
Target {
5555
llvm_target: "wasm32-unknown-unknown".to_string(),
5656
pointer_width: 32,
57-
data_layout: "e-m:e-p:32:32-i64:64-n32:64-S128-ni:1:10:20".to_string(),
57+
data_layout: "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20".to_string(),
5858
arch: "wasm32".to_string(),
5959
options,
6060
}

compiler/rustc_target/src/spec/wasm32_wasi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ pub fn target() -> Target {
109109
Target {
110110
llvm_target: "wasm32-wasi".to_string(),
111111
pointer_width: 32,
112-
data_layout: "e-m:e-p:32:32-i64:64-n32:64-S128-ni:1:10:20".to_string(),
112+
data_layout: "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20".to_string(),
113113
arch: "wasm32".to_string(),
114114
options,
115115
}

0 commit comments

Comments
 (0)