Skip to content

Commit 374ab25

Browse files
committed
Auto merge of rust-lang#70163 - nikic:llvm-10-preparation, r=cuviper
Prepare for LLVM 10 upgrade This is rust-lang#67759 minus the submodule update. * Fix two compatibility issues in the rustllvm wrapper. * Update data layout strings in tests. * Fix LLVM version comparison (this become a problem because the major version has two digits now). r? @cuviper
2 parents 1add455 + 497f879 commit 374ab25

File tree

7 files changed

+37
-12
lines changed

7 files changed

+37
-12
lines changed

Diff for: src/bootstrap/test.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1141,6 +1141,8 @@ impl Step for Compiletest {
11411141
let llvm_config = builder.ensure(native::Llvm { target: builder.config.build });
11421142
if !builder.config.dry_run {
11431143
let llvm_version = output(Command::new(&llvm_config).arg("--version"));
1144+
// Remove trailing newline from llvm-config output.
1145+
let llvm_version = llvm_version.trim_end();
11441146
cmd.arg("--llvm-version").arg(llvm_version);
11451147
}
11461148
if !builder.is_rust_llvm(target) {

Diff for: src/rustllvm/PassWrapper.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@ extern "C" void LLVMInitializePasses() {
6767
}
6868

6969
extern "C" void LLVMTimeTraceProfilerInitialize() {
70-
#if LLVM_VERSION_GE(9, 0)
70+
#if LLVM_VERSION_GE(10, 0)
71+
timeTraceProfilerInitialize(
72+
/* TimeTraceGranularity */ 0,
73+
/* ProcName */ "rustc");
74+
#elif LLVM_VERSION_GE(9, 0)
7175
timeTraceProfilerInitialize();
7276
#endif
7377
}

Diff for: src/rustllvm/RustWrapper.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -1333,8 +1333,13 @@ extern "C" LLVMValueRef LLVMRustBuildMemSet(LLVMBuilderRef B,
13331333
LLVMValueRef Dst, unsigned DstAlign,
13341334
LLVMValueRef Val,
13351335
LLVMValueRef Size, bool IsVolatile) {
1336+
#if LLVM_VERSION_GE(10, 0)
1337+
return wrap(unwrap(B)->CreateMemSet(
1338+
unwrap(Dst), unwrap(Val), unwrap(Size), MaybeAlign(DstAlign), IsVolatile));
1339+
#else
13361340
return wrap(unwrap(B)->CreateMemSet(
13371341
unwrap(Dst), unwrap(Val), unwrap(Size), DstAlign, IsVolatile));
1342+
#endif
13381343
}
13391344

13401345
extern "C" LLVMValueRef

Diff for: src/test/run-make-fulldeps/target-specs/my-awesome-platform.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"data-layout": "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128",
2+
"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",
33
"linker-flavor": "gcc",
44
"llvm-target": "i686-unknown-linux-gnu",
55
"target-endian": "little",

Diff for: src/test/run-make-fulldeps/target-specs/my-x86_64-unknown-linux-gnu-platform.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"pre-link-args": {"gcc": ["-m64"]},
3-
"data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
3+
"data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128",
44
"linker-flavor": "gcc",
55
"llvm-target": "x86_64-unknown-linux-gnu",
66
"target-endian": "little",

Diff for: src/tools/compiletest/src/header.rs

+21-6
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ impl EarlyProps {
191191
return true;
192192
}
193193
if let Some(ref actual_version) = config.llvm_version {
194+
let actual_version = version_to_int(actual_version);
194195
if line.starts_with("min-llvm-version") {
195196
let min_version = line
196197
.trim_end()
@@ -199,7 +200,7 @@ impl EarlyProps {
199200
.expect("Malformed llvm version directive");
200201
// Ignore if actual version is smaller the minimum required
201202
// version
202-
&actual_version[..] < min_version
203+
actual_version < version_to_int(min_version)
203204
} else if line.starts_with("min-system-llvm-version") {
204205
let min_version = line
205206
.trim_end()
@@ -208,7 +209,7 @@ impl EarlyProps {
208209
.expect("Malformed llvm version directive");
209210
// Ignore if using system LLVM and actual version
210211
// is smaller the minimum required version
211-
config.system_llvm && &actual_version[..] < min_version
212+
config.system_llvm && actual_version < version_to_int(min_version)
212213
} else if line.starts_with("ignore-llvm-version") {
213214
// Syntax is: "ignore-llvm-version <version1> [- <version2>]"
214215
let range_components = line
@@ -219,15 +220,15 @@ impl EarlyProps {
219220
.take(3) // 3 or more = invalid, so take at most 3.
220221
.collect::<Vec<&str>>();
221222
match range_components.len() {
222-
1 => &actual_version[..] == range_components[0],
223+
1 => actual_version == version_to_int(range_components[0]),
223224
2 => {
224-
let v_min = range_components[0];
225-
let v_max = range_components[1];
225+
let v_min = version_to_int(range_components[0]);
226+
let v_max = version_to_int(range_components[1]);
226227
if v_max < v_min {
227228
panic!("Malformed LLVM version range: max < min")
228229
}
229230
// Ignore if version lies inside of range.
230-
&actual_version[..] >= v_min && &actual_version[..] <= v_max
231+
actual_version >= v_min && actual_version <= v_max
231232
}
232233
_ => panic!("Malformed LLVM version directive"),
233234
}
@@ -238,6 +239,20 @@ impl EarlyProps {
238239
false
239240
}
240241
}
242+
243+
fn version_to_int(version: &str) -> u32 {
244+
let version_without_suffix = version.split('-').next().unwrap();
245+
let components: Vec<u32> = version_without_suffix
246+
.split('.')
247+
.map(|s| s.parse().expect("Malformed version component"))
248+
.collect();
249+
match components.len() {
250+
1 => components[0] * 10000,
251+
2 => components[0] * 10000 + components[1] * 100,
252+
3 => components[0] * 10000 + components[1] * 100 + components[2],
253+
_ => panic!("Malformed version"),
254+
}
255+
}
241256
}
242257
}
243258

Diff for: src/tools/compiletest/src/header/tests.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,8 @@ fn llvm_version() {
122122
config.llvm_version = Some("9.3.1-rust-1.43.0-dev".to_owned());
123123
assert!(!parse_rs(&config, "// min-llvm-version 9.2").ignore);
124124

125-
// FIXME.
126-
// config.llvm_version = Some("10.0.0-rust".to_owned());
127-
// assert!(!parse_rs(&config, "// min-llvm-version 9.0").ignore);
125+
config.llvm_version = Some("10.0.0-rust".to_owned());
126+
assert!(!parse_rs(&config, "// min-llvm-version 9.0").ignore);
128127
}
129128

130129
#[test]

0 commit comments

Comments
 (0)