about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-11-02 23:04:42 +0000
committerbors <bors@rust-lang.org>2024-11-02 23:04:42 +0000
commit8ccb78e0d5b1775b42153730d49de6456cf10a70 (patch)
tree04a49315b274b3008c17f7a3ecc1abe52b7429c9 /compiler/rustc_codegen_llvm/src
parentb3f75cc872cfd306860c3ad76a239e719015f855 (diff)
parentba481518da240b5e532785fce51106c962dcd5fa (diff)
downloadrust-8ccb78e0d5b1775b42153730d49de6456cf10a70.tar.gz
rust-8ccb78e0d5b1775b42153730d49de6456cf10a70.zip
Auto merge of #125579 - Noratrieb:print-host, r=davidtwco
Add `--print host-tuple` to print host target tuple

People often parse `-vV` output to get to the host tuple, which is annoying to do. It's easier to just get it directly.

I called it "host-tuple" instead of "host" because it's clearer that it's just the target name. I'm open to different names, but I think this one is fine.

a quick GitHub search for `'^host` reveals many instances of people doing the parsing, for example:

https://github.com/japaric/xargo/blob/68e0ca57cd90837fe02f262f074182f9cfeb6227/README.md?plain=1#L369
https://github.com/taiki-e/setup-cross-toolchain-action/blob/0e38473b0c562d6db19a98d3ec20a80f7ac189ae/main.sh#L96
https://github.com/taiki-e/cargo-llvm-cov/blob/8a3553b86551eabf9c30c060b1f72a5bbccb98c6/README.md?plain=1#L625
https://github.com/SiliconLabs/cpc-nvm3/blob/43f3ec39709b30700ef7f39d91fa647974323bf1/do.sh#L35

needs a compiler FCP. I could also do an MCP but I think just an FCP here makes the most sense.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
-rw-r--r--compiler/rustc_codegen_llvm/src/back/write.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/compiler/rustc_codegen_llvm/src/back/write.rs b/compiler/rustc_codegen_llvm/src/back/write.rs
index 01e2c308ca4..647e9e13fbc 100644
--- a/compiler/rustc_codegen_llvm/src/back/write.rs
+++ b/compiler/rustc_codegen_llvm/src/back/write.rs
@@ -946,7 +946,7 @@ fn create_section_with_flags_asm(section_name: &str, section_flags: &str, data:
 }
 
 fn target_is_apple(cgcx: &CodegenContext<LlvmCodegenBackend>) -> bool {
-    let triple = cgcx.opts.target_triple.triple();
+    let triple = cgcx.opts.target_triple.tuple();
     triple.contains("-ios")
         || triple.contains("-darwin")
         || triple.contains("-tvos")
@@ -955,7 +955,7 @@ fn target_is_apple(cgcx: &CodegenContext<LlvmCodegenBackend>) -> bool {
 }
 
 fn target_is_aix(cgcx: &CodegenContext<LlvmCodegenBackend>) -> bool {
-    cgcx.opts.target_triple.triple().contains("-aix")
+    cgcx.opts.target_triple.tuple().contains("-aix")
 }
 
 pub(crate) fn bitcode_section_name(cgcx: &CodegenContext<LlvmCodegenBackend>) -> &'static CStr {
@@ -1031,7 +1031,7 @@ unsafe fn embed_bitcode(
     let is_aix = target_is_aix(cgcx);
     let is_apple = target_is_apple(cgcx);
     unsafe {
-        if is_apple || is_aix || cgcx.opts.target_triple.triple().starts_with("wasm") {
+        if is_apple || is_aix || cgcx.opts.target_triple.tuple().starts_with("wasm") {
             // We don't need custom section flags, create LLVM globals.
             let llconst = common::bytes_in_context(llcx, bitcode);
             let llglobal = llvm::LLVMAddGlobal(