0002-compiler-Change-LLVM-targets.patch 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
  2. From: "Jan Alexander Steffens (heftig)" <jan.steffens@gmail.com>
  3. Date: Fri, 12 Mar 2021 17:31:56 +0100
  4. Subject: [PATCH] compiler: Change LLVM targets
  5. - Change x86_64-unknown-linux-gnu to use x86_64-pc-linux-gnu
  6. - Change i686-unknown-linux-gnu to use i686-pc-linux-gnu
  7. Reintroduce the aliasing that was removed in 1.52.0 and alias the -pc-
  8. triples to the -unknown- triples. This avoids defining proper -pc-
  9. targets, as things break when this is done:
  10. - The crate ecosystem expects the -unknown- targets. Making -pc-
  11. rustc's host triple (and thus default target) would break various
  12. crates.
  13. - Firefox's build breaks when the host triple (from
  14. `rustc --version --verbose`) is different from the target triple
  15. (from `rustc --print target-list`) that best matches autoconf.
  16. ---
  17. compiler/rustc_session/src/config.rs | 2 +-
  18. compiler/rustc_target/src/spec/i686_unknown_linux_gnu.rs | 2 +-
  19. compiler/rustc_target/src/spec/mod.rs | 9 +++++++++
  20. .../rustc_target/src/spec/x86_64_unknown_linux_gnu.rs | 2 +-
  21. 4 files changed, 12 insertions(+), 3 deletions(-)
  22. diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs
  23. index 2b547f8be92..09e1152dde4 100644
  24. --- a/compiler/rustc_session/src/config.rs
  25. +++ b/compiler/rustc_session/src/config.rs
  26. @@ -1538,7 +1538,7 @@ pub fn parse_target_triple(
  27. early_error(error_format, &format!("target file {:?} does not exist", path))
  28. })
  29. }
  30. - Some(target) => TargetTriple::TargetTriple(target),
  31. + Some(target) => TargetTriple::from_alias(target),
  32. _ => TargetTriple::from_triple(host_triple()),
  33. }
  34. }
  35. diff --git a/compiler/rustc_target/src/spec/i686_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/i686_unknown_linux_gnu.rs
  36. index 165505ee731..00a7f5c2f8c 100644
  37. --- a/compiler/rustc_target/src/spec/i686_unknown_linux_gnu.rs
  38. +++ b/compiler/rustc_target/src/spec/i686_unknown_linux_gnu.rs
  39. @@ -9,7 +9,7 @@ pub fn target() -> Target {
  40. base.stack_probes = StackProbeType::Call;
  41. Target {
  42. - llvm_target: "i686-unknown-linux-gnu".to_string(),
  43. + llvm_target: "i686-pc-linux-gnu".to_string(),
  44. pointer_width: 32,
  45. data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
  46. f64:32:64-f80:32-n8:16:32-S128"
  47. diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs
  48. index 0f2aaeb533a..ce27142ec86 100644
  49. --- a/compiler/rustc_target/src/spec/mod.rs
  50. +++ b/compiler/rustc_target/src/spec/mod.rs
  51. @@ -2164,6 +2164,15 @@ pub fn from_path(path: &Path) -> Result<Self, io::Error> {
  52. Ok(TargetTriple::TargetPath(canonicalized_path))
  53. }
  54. + /// Creates a target triple from its alias
  55. + pub fn from_alias(triple: String) -> Self {
  56. + match triple.as_str() {
  57. + "x86_64-pc-linux-gnu" => TargetTriple::from_triple("x86_64-unknown-linux-gnu"),
  58. + "i686-pc-linux-gnu" => TargetTriple::from_triple("i686-unknown-linux-gnu"),
  59. + _ => TargetTriple::TargetTriple(triple),
  60. + }
  61. + }
  62. +
  63. /// Returns a string triple for this target.
  64. ///
  65. /// If this target is a path, the file name (without extension) is returned.
  66. diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/x86_64_unknown_linux_gnu.rs
  67. index 085079e06e5..2dfa6a040b1 100644
  68. --- a/compiler/rustc_target/src/spec/x86_64_unknown_linux_gnu.rs
  69. +++ b/compiler/rustc_target/src/spec/x86_64_unknown_linux_gnu.rs
  70. @@ -11,7 +11,7 @@ pub fn target() -> Target {
  71. SanitizerSet::ADDRESS | SanitizerSet::LEAK | SanitizerSet::MEMORY | SanitizerSet::THREAD;
  72. Target {
  73. - llvm_target: "x86_64-unknown-linux-gnu".to_string(),
  74. + llvm_target: "x86_64-pc-linux-gnu".to_string(),
  75. pointer_width: 64,
  76. data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
  77. .to_string(),