Skip to content

Commit b57c499

Browse files
committed
Translate target features for LLVM 9
1 parent eb33822 commit b57c499

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/librustc_codegen_llvm/attributes.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,29 @@ pub fn set_probestack(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
119119
const_cstr!("probe-stack"), const_cstr!("__rust_probestack"));
120120
}
121121

122+
fn translate_obsolete_target_features(feature: &str) -> &str {
123+
const LLVM9_FEATURE_CHANGES: &[(&str, &str)] = &[
124+
("+fp-only-sp", "-fp64"),
125+
("-fp-only-sp", "+fp64"),
126+
("+d16", "-d32"),
127+
("-d16", "+d32"),
128+
];
129+
if llvm_util::get_major_version() >= 9 {
130+
for &(old, new) in LLVM9_FEATURE_CHANGES {
131+
if feature == old {
132+
return new;
133+
}
134+
}
135+
} else {
136+
for &(old, new) in LLVM9_FEATURE_CHANGES {
137+
if feature == new {
138+
return old;
139+
}
140+
}
141+
}
142+
feature
143+
}
144+
122145
pub fn llvm_target_features(sess: &Session) -> impl Iterator<Item = &str> {
123146
const RUSTC_SPECIFIC_FEATURES: &[&str] = &[
124147
"crt-static",
@@ -129,6 +152,7 @@ pub fn llvm_target_features(sess: &Session) -> impl Iterator<Item = &str> {
129152
sess.target.target.options.features.split(',')
130153
.chain(cmdline)
131154
.filter(|l| !l.is_empty())
155+
.map(translate_obsolete_target_features)
132156
}
133157

134158
pub fn apply_target_cpu_attr(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {

0 commit comments

Comments
 (0)