@@ -116,6 +116,10 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
116116                AttributeKind :: Naked ( _)  => codegen_fn_attrs. flags  |= CodegenFnAttrFlags :: NAKED , 
117117                AttributeKind :: Align  {  align,  .. }  => codegen_fn_attrs. alignment  = Some ( * align) , 
118118                AttributeKind :: LinkName  {  name,  .. }  => codegen_fn_attrs. link_name  = Some ( * name) , 
119+                 AttributeKind :: LinkOrdinal  {  ordinal,  span }  => { 
120+                     codegen_fn_attrs. link_ordinal  = Some ( * ordinal) ; 
121+                     link_ordinal_span = Some ( * span) ; 
122+                 } 
119123                AttributeKind :: LinkSection  {  name,  .. }  => { 
120124                    codegen_fn_attrs. link_section  = Some ( * name) 
121125                } 
@@ -250,12 +254,6 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
250254                    } 
251255                } 
252256            } 
253-             sym:: link_ordinal => { 
254-                 link_ordinal_span = Some ( attr. span ( ) ) ; 
255-                 if  let  ordinal @ Some ( _)  = check_link_ordinal ( tcx,  attr)  { 
256-                     codegen_fn_attrs. link_ordinal  = ordinal; 
257-                 } 
258-             } 
259257            sym:: no_sanitize => { 
260258                no_sanitize_span = Some ( attr. span ( ) ) ; 
261259                if  let  Some ( list)  = attr. meta_item_list ( )  { 
@@ -568,45 +566,6 @@ fn inherited_align<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> Option<Align> {
568566    tcx. codegen_fn_attrs ( opt_trait_item ( tcx,  def_id) ?) . alignment 
569567} 
570568
571- fn  check_link_ordinal ( tcx :  TyCtxt < ' _ > ,  attr :  & hir:: Attribute )  -> Option < u16 >  { 
572-     use  rustc_ast:: { LitIntType ,  LitKind ,  MetaItemLit } ; 
573-     let  meta_item_list = attr. meta_item_list ( ) ?; 
574-     let  [ sole_meta_list]  = & meta_item_list[ ..]  else  { 
575-         tcx. dcx ( ) . emit_err ( errors:: InvalidLinkOrdinalNargs  {  span :  attr. span ( )  } ) ; 
576-         return  None ; 
577-     } ; 
578-     if  let  Some ( MetaItemLit  {  kind :  LitKind :: Int ( ordinal,  LitIntType :: Unsuffixed ) ,  .. } )  =
579-         sole_meta_list. lit ( ) 
580-     { 
581-         // According to the table at 
582-         // https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#import-header, the 
583-         // ordinal must fit into 16 bits. Similarly, the Ordinal field in COFFShortExport (defined 
584-         // in llvm/include/llvm/Object/COFFImportFile.h), which we use to communicate import 
585-         // information to LLVM for `#[link(kind = "raw-dylib"_])`, is also defined to be uint16_t. 
586-         // 
587-         // FIXME: should we allow an ordinal of 0?  The MSVC toolchain has inconsistent support for 
588-         // this: both LINK.EXE and LIB.EXE signal errors and abort when given a .DEF file that 
589-         // specifies a zero ordinal. However, llvm-dlltool is perfectly happy to generate an import 
590-         // library for such a .DEF file, and MSVC's LINK.EXE is also perfectly happy to consume an 
591-         // import library produced by LLVM with an ordinal of 0, and it generates an .EXE.  (I 
592-         // don't know yet if the resulting EXE runs, as I haven't yet built the necessary DLL -- 
593-         // see earlier comment about LINK.EXE failing.) 
594-         if  * ordinal <= u16:: MAX  as  u128  { 
595-             Some ( ordinal. get ( )  as  u16 ) 
596-         }  else  { 
597-             let  msg = format ! ( "ordinal value in `link_ordinal` is too large: `{ordinal}`" ) ; 
598-             tcx. dcx ( ) 
599-                 . struct_span_err ( attr. span ( ) ,  msg) 
600-                 . with_note ( "the value may not exceed `u16::MAX`" ) 
601-                 . emit ( ) ; 
602-             None 
603-         } 
604-     }  else  { 
605-         tcx. dcx ( ) . emit_err ( errors:: InvalidLinkOrdinalFormat  {  span :  attr. span ( )  } ) ; 
606-         None 
607-     } 
608- } 
609- 
610569fn  check_link_name_xor_ordinal ( 
611570    tcx :  TyCtxt < ' _ > , 
612571    codegen_fn_attrs :  & CodegenFnAttrs , 
0 commit comments