Blame SOURCES/rust-pr70163-prepare-for-llvm-10-upgrade.patch

a43525
commit 374ab25585f0a817fe7bd6986737f12347b12d0b (from 1add455ec6f81045e7651c6225902823f5d4fbfa)
a43525
Merge: 1add455ec6f8 497f879b1e24
a43525
Author: bors <bors@rust-lang.org>
a43525
Date:   Tue Mar 24 12:42:54 2020 +0000
a43525
a43525
    Auto merge of #70163 - nikic:llvm-10-preparation, r=cuviper
a43525
    
a43525
    Prepare for LLVM 10 upgrade
a43525
    
a43525
    This is #67759 minus the submodule update.
a43525
    
a43525
     * Fix two compatibility issues in the rustllvm wrapper.
a43525
     * Update data layout strings in tests.
a43525
     * Fix LLVM version comparison (this become a problem because the major version has two digits now).
a43525
    
a43525
    r? @cuviper
a43525
a43525
diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs
a43525
index aa1d1b7c4241..b52fbe4666eb 100644
a43525
--- a/src/bootstrap/test.rs
a43525
+++ b/src/bootstrap/test.rs
a43525
@@ -1141,6 +1141,8 @@ impl Step for Compiletest {
a43525
             let llvm_config = builder.ensure(native::Llvm { target: builder.config.build });
a43525
             if !builder.config.dry_run {
a43525
                 let llvm_version = output(Command::new(&llvm_config).arg("--version"));
a43525
+                // Remove trailing newline from llvm-config output.
a43525
+                let llvm_version = llvm_version.trim_end();
a43525
                 cmd.arg("--llvm-version").arg(llvm_version);
a43525
             }
a43525
             if !builder.is_rust_llvm(target) {
a43525
diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp
a43525
index 90d24d20737d..9e8614e3b6d3 100644
a43525
--- a/src/rustllvm/PassWrapper.cpp
a43525
+++ b/src/rustllvm/PassWrapper.cpp
a43525
@@ -67,7 +67,11 @@ extern "C" void LLVMInitializePasses() {
a43525
 }
a43525
 
a43525
 extern "C" void LLVMTimeTraceProfilerInitialize() {
a43525
-#if LLVM_VERSION_GE(9, 0)
a43525
+#if LLVM_VERSION_GE(10, 0)
a43525
+  timeTraceProfilerInitialize(
a43525
+      /* TimeTraceGranularity */ 0,
a43525
+      /* ProcName */ "rustc");
a43525
+#elif LLVM_VERSION_GE(9, 0)
a43525
   timeTraceProfilerInitialize();
a43525
 #endif
a43525
 }
a43525
diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp
a43525
index 25cfee3373dc..799adb418822 100644
a43525
--- a/src/rustllvm/RustWrapper.cpp
a43525
+++ b/src/rustllvm/RustWrapper.cpp
a43525
@@ -1333,8 +1333,13 @@ extern "C" LLVMValueRef LLVMRustBuildMemSet(LLVMBuilderRef B,
a43525
                                             LLVMValueRef Dst, unsigned DstAlign,
a43525
                                             LLVMValueRef Val,
a43525
                                             LLVMValueRef Size, bool IsVolatile) {
a43525
+#if LLVM_VERSION_GE(10, 0)
a43525
+  return wrap(unwrap(B)->CreateMemSet(
a43525
+      unwrap(Dst), unwrap(Val), unwrap(Size), MaybeAlign(DstAlign), IsVolatile));
a43525
+#else
a43525
   return wrap(unwrap(B)->CreateMemSet(
a43525
       unwrap(Dst), unwrap(Val), unwrap(Size), DstAlign, IsVolatile));
a43525
+#endif
a43525
 }
a43525
 
a43525
 extern "C" LLVMValueRef
a43525
diff --git a/src/test/run-make-fulldeps/target-specs/my-awesome-platform.json b/src/test/run-make-fulldeps/target-specs/my-awesome-platform.json
a43525
index 8d028280a8da..00de3de05f07 100644
a43525
--- a/src/test/run-make-fulldeps/target-specs/my-awesome-platform.json
a43525
+++ b/src/test/run-make-fulldeps/target-specs/my-awesome-platform.json
a43525
@@ -1,5 +1,5 @@
a43525
 {
a43525
-    "data-layout": "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128",
a43525
+    "data-layout": "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128",
a43525
     "linker-flavor": "gcc",
a43525
     "llvm-target": "i686-unknown-linux-gnu",
a43525
     "target-endian": "little",
a43525
diff --git a/src/test/run-make-fulldeps/target-specs/my-x86_64-unknown-linux-gnu-platform.json b/src/test/run-make-fulldeps/target-specs/my-x86_64-unknown-linux-gnu-platform.json
a43525
index 48040ae3da0e..6d5e964ed4fe 100644
a43525
--- a/src/test/run-make-fulldeps/target-specs/my-x86_64-unknown-linux-gnu-platform.json
a43525
+++ b/src/test/run-make-fulldeps/target-specs/my-x86_64-unknown-linux-gnu-platform.json
a43525
@@ -1,6 +1,6 @@
a43525
 {
a43525
     "pre-link-args": {"gcc": ["-m64"]},
a43525
-    "data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
a43525
+    "data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128",
a43525
     "linker-flavor": "gcc",
a43525
     "llvm-target": "x86_64-unknown-linux-gnu",
a43525
     "target-endian": "little",
a43525
diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs
a43525
index 2a24a8c3c948..cb648db8830e 100644
a43525
--- a/src/tools/compiletest/src/header.rs
a43525
+++ b/src/tools/compiletest/src/header.rs
a43525
@@ -191,6 +191,7 @@ impl EarlyProps {
a43525
                 return true;
a43525
             }
a43525
             if let Some(ref actual_version) = config.llvm_version {
a43525
+                let actual_version = version_to_int(actual_version);
a43525
                 if line.starts_with("min-llvm-version") {
a43525
                     let min_version = line
a43525
                         .trim_end()
a43525
@@ -199,7 +200,7 @@ impl EarlyProps {
a43525
                         .expect("Malformed llvm version directive");
a43525
                     // Ignore if actual version is smaller the minimum required
a43525
                     // version
a43525
-                    &actual_version[..] < min_version
a43525
+                    actual_version < version_to_int(min_version)
a43525
                 } else if line.starts_with("min-system-llvm-version") {
a43525
                     let min_version = line
a43525
                         .trim_end()
a43525
@@ -208,7 +209,7 @@ impl EarlyProps {
a43525
                         .expect("Malformed llvm version directive");
a43525
                     // Ignore if using system LLVM and actual version
a43525
                     // is smaller the minimum required version
a43525
-                    config.system_llvm && &actual_version[..] < min_version
a43525
+                    config.system_llvm && actual_version < version_to_int(min_version)
a43525
                 } else if line.starts_with("ignore-llvm-version") {
a43525
                     // Syntax is: "ignore-llvm-version <version1> [- <version2>]"
a43525
                     let range_components = line
a43525
@@ -219,15 +220,15 @@ impl EarlyProps {
a43525
                         .take(3) // 3 or more = invalid, so take at most 3.
a43525
                         .collect::<Vec<&str>>();
a43525
                     match range_components.len() {
a43525
-                        1 => &actual_version[..] == range_components[0],
a43525
+                        1 => actual_version == version_to_int(range_components[0]),
a43525
                         2 => {
a43525
-                            let v_min = range_components[0];
a43525
-                            let v_max = range_components[1];
a43525
+                            let v_min = version_to_int(range_components[0]);
a43525
+                            let v_max = version_to_int(range_components[1]);
a43525
                             if v_max < v_min {
a43525
                                 panic!("Malformed LLVM version range: max < min")
a43525
                             }
a43525
                             // Ignore if version lies inside of range.
a43525
-                            &actual_version[..] >= v_min && &actual_version[..] <= v_max
a43525
+                            actual_version >= v_min && actual_version <= v_max
a43525
                         }
a43525
                         _ => panic!("Malformed LLVM version directive"),
a43525
                     }
a43525
@@ -238,6 +239,20 @@ impl EarlyProps {
a43525
                 false
a43525
             }
a43525
         }
a43525
+
a43525
+        fn version_to_int(version: &str) -> u32 {
a43525
+            let version_without_suffix = version.split('-').next().unwrap();
a43525
+            let components: Vec<u32> = version_without_suffix
a43525
+                .split('.')
a43525
+                .map(|s| s.parse().expect("Malformed version component"))
a43525
+                .collect();
a43525
+            match components.len() {
a43525
+                1 => components[0] * 10000,
a43525
+                2 => components[0] * 10000 + components[1] * 100,
a43525
+                3 => components[0] * 10000 + components[1] * 100 + components[2],
a43525
+                _ => panic!("Malformed version"),
a43525
+            }
a43525
+        }
a43525
     }
a43525
 }
a43525
 
a43525
diff --git a/src/tools/compiletest/src/header/tests.rs b/src/tools/compiletest/src/header/tests.rs
a43525
index 6c478f7e29da..31d991e0c2f8 100644
a43525
--- a/src/tools/compiletest/src/header/tests.rs
a43525
+++ b/src/tools/compiletest/src/header/tests.rs
a43525
@@ -122,9 +122,8 @@ fn llvm_version() {
a43525
     config.llvm_version = Some("9.3.1-rust-1.43.0-dev".to_owned());
a43525
     assert!(!parse_rs(&config, "// min-llvm-version 9.2").ignore);
a43525
 
a43525
-    // FIXME.
a43525
-    // config.llvm_version = Some("10.0.0-rust".to_owned());
a43525
-    // assert!(!parse_rs(&config, "// min-llvm-version 9.0").ignore);
a43525
+    config.llvm_version = Some("10.0.0-rust".to_owned());
a43525
+    assert!(!parse_rs(&config, "// min-llvm-version 9.0").ignore);
a43525
 }
a43525
 
a43525
 #[test]