@@ -217,24 +217,32 @@ pub fn check_tied_features(
217217
218218pub fn target_features ( sess : & Session ) -> Vec < Symbol > {
219219 let target_machine = create_informational_target_machine ( sess) ;
220- supported_target_features ( sess )
221- . iter ( )
222- . filter_map (
223- |& ( feature, gate) | {
220+ let mut features : Vec < Symbol > =
221+ supported_target_features ( sess )
222+ . iter ( )
223+ . filter_map ( |& ( feature, gate) | {
224224 if sess. is_nightly_build ( ) || gate. is_none ( ) { Some ( feature) } else { None }
225- } ,
226- )
227- . filter ( | feature| {
228- for llvm_feature in to_llvm_feature ( sess , feature ) {
229- let cstr = CString :: new ( llvm_feature ) . unwrap ( ) ;
230- if unsafe { llvm :: LLVMRustHasFeature ( target_machine , cstr . as_ptr ( ) ) } {
231- return true ;
225+ } )
226+ . filter ( |feature| {
227+ for llvm_feature in to_llvm_feature ( sess , feature) {
228+ let cstr = CString :: new ( llvm_feature ) . unwrap ( ) ;
229+ if unsafe { llvm :: LLVMRustHasFeature ( target_machine , cstr . as_ptr ( ) ) } {
230+ return true ;
231+ }
232232 }
233- }
234- false
235- } )
236- . map ( |feature| Symbol :: intern ( feature) )
237- . collect ( )
233+ false
234+ } )
235+ . map ( |feature| Symbol :: intern ( feature) )
236+ . collect ( ) ;
237+
238+ // LLVM 14 changed the ABI for i128 arguments to __float/__fix builtins on Win64
239+ // (see https://reviews.llvm.org/D110413). This unstable target feature is intended for use
240+ // by compiler-builtins, to export the builtins with the expected, LLVM-version-dependent ABI.
241+ // The target feature can be dropped once we no longer support older LLVM versions.
242+ if sess. is_nightly_build ( ) && get_version ( ) >= ( 14 , 0 , 0 ) {
243+ features. push ( Symbol :: intern ( "llvm14-builtins-abi" ) ) ;
244+ }
245+ features
238246}
239247
240248pub fn print_version ( ) {
0 commit comments