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

CC support for wasm32-wali-linux-musl Tier-3 Linux target #1373

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

arjunr2
Copy link

@arjunr2 arjunr2 commented Jan 17, 2025

To support the new Tier-3 target wasm32-wali-linux-musl within the rust compiler: rust-lang/rust#135651

Minimally, this just supports providing appropriate musl library linking and flags for the target

@arjunr2 arjunr2 changed the title CC support for wasm32-wali-linux-musl Tier-3 Linux target CC support for wasm32-wali-linux-musl Tier-3 Linux target Jan 17, 2025
@@ -1363,6 +1363,12 @@ impl Build {
target
));
}
} else if target.contains("wasm32") && target.contains("linux") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to do an exact match?

Suggested change
} else if target.contains("wasm32") && target.contains("linux") {
} else if target == "wasm32-wali-linux-musl" {

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to avoid .contains, and use target.arch == "wasm32" && target.os == "linux" (or similar)

@@ -2178,6 +2184,25 @@ impl Build {
}

cmd.push_cc_arg(format!("--target={}", target).into());
} else if target.contains("wasm32") && target.contains("linux") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Comment on lines +2188 to +2205
// wasm32-linux currently uses the LLVM-18 wasi threads target
cmd.push_cc_arg("--target=wasm32-wasi-threads".into());
for x in &[
"atomics",
"bulk-memory",
"mutable-globals",
"sign-ext",
"exception-handling",
] {
cmd.push_cc_arg(format!("-m{}", x).into());
}
for x in &["wasm-exceptions", "declspec"] {
cmd.push_cc_arg(format!("-f{}", x).into());
}
let musl_sysroot = self.wasm_musl_sysroot().unwrap();
cmd.push_cc_arg(
format!("--sysroot={}", Path::new(&musl_sysroot).display()).into(),
);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @madsmtm do you think we can use gen-target-info to auto generate this information?

Copy link
Collaborator

@madsmtm madsmtm Jan 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, the --target at least definitely looks odd? EDIT: Wrote this in other review comments.

But yeah, we should definitely look into taking atomics/buld-memory/... from rustc's target data instead of hardcoding it here.

@arjunr2
Copy link
Author

arjunr2 commented Jan 20, 2025

Having these conditions rely on just wasm32 and linux seem to make more sense to me. WALI/musl is just a specific ABI/env, and future non-WALI/non-musl targets can then reuse them. Is there a reason for why using the full target is better?

@madsmtm
Copy link
Collaborator

madsmtm commented Jan 20, 2025

I'd also really rather prefer not using the full target if we can.

@@ -2178,6 +2184,25 @@ impl Build {
}

cmd.push_cc_arg(format!("--target={}", target).into());
} else if target.contains("wasm32") && target.contains("linux") {
// wasm32-linux currently uses the LLVM-18 wasi threads target
cmd.push_cc_arg("--target=wasm32-wasi-threads".into());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of --target seems odd? It is not clear why we are passing a different target here than the llvm_target in rustc's Target, which is set to wasm32-wasi?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This configuration is similar to wasm32-wasip1-threads, which uses the wasm32-wasi llvm target. I am not sure using llvm_target as wasm32-wasi-threads breaks any pattern matching within rustc, so I stuck to what the former currently does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants