@@ -3,6 +3,7 @@ use std::sync::OnceLock;
33
44use rustc_data_structures:: profiling:: VerboseTimingGuard ;
55use rustc_fs_util:: try_canonicalize;
6+ use rustc_hir:: attrs:: NativeLibKind ;
67use rustc_macros:: { Decodable , Encodable , HashStable_Generic } ;
78
89use crate :: session:: Session ;
@@ -17,69 +18,6 @@ impl Session {
1718 }
1819}
1920
20- #[ derive( Copy , Clone , Debug , PartialEq , Eq , PartialOrd , Ord , Hash , Encodable , Decodable ) ]
21- #[ derive( HashStable_Generic ) ]
22- pub enum NativeLibKind {
23- /// Static library (e.g. `libfoo.a` on Linux or `foo.lib` on Windows/MSVC)
24- Static {
25- /// Whether to bundle objects from static library into produced rlib
26- bundle : Option < bool > ,
27- /// Whether to link static library without throwing any object files away
28- whole_archive : Option < bool > ,
29- } ,
30- /// Dynamic library (e.g. `libfoo.so` on Linux)
31- /// or an import library corresponding to a dynamic library (e.g. `foo.lib` on Windows/MSVC).
32- Dylib {
33- /// Whether the dynamic library will be linked only if it satisfies some undefined symbols
34- as_needed : Option < bool > ,
35- } ,
36- /// Dynamic library (e.g. `foo.dll` on Windows) without a corresponding import library.
37- /// On Linux, it refers to a generated shared library stub.
38- RawDylib ,
39- /// A macOS-specific kind of dynamic libraries.
40- Framework {
41- /// Whether the framework will be linked only if it satisfies some undefined symbols
42- as_needed : Option < bool > ,
43- } ,
44- /// Argument which is passed to linker, relative order with libraries and other arguments
45- /// is preserved
46- LinkArg ,
47-
48- /// Module imported from WebAssembly
49- WasmImportModule ,
50-
51- /// The library kind wasn't specified, `Dylib` is currently used as a default.
52- Unspecified ,
53- }
54-
55- impl NativeLibKind {
56- pub fn has_modifiers ( & self ) -> bool {
57- match self {
58- NativeLibKind :: Static { bundle, whole_archive } => {
59- bundle. is_some ( ) || whole_archive. is_some ( )
60- }
61- NativeLibKind :: Dylib { as_needed } | NativeLibKind :: Framework { as_needed } => {
62- as_needed. is_some ( )
63- }
64- NativeLibKind :: RawDylib
65- | NativeLibKind :: Unspecified
66- | NativeLibKind :: LinkArg
67- | NativeLibKind :: WasmImportModule => false ,
68- }
69- }
70-
71- pub fn is_statically_included ( & self ) -> bool {
72- matches ! ( self , NativeLibKind :: Static { .. } )
73- }
74-
75- pub fn is_dllimport ( & self ) -> bool {
76- matches ! (
77- self ,
78- NativeLibKind :: Dylib { .. } | NativeLibKind :: RawDylib | NativeLibKind :: Unspecified
79- )
80- }
81- }
82-
8321#[ derive( Clone , Debug , PartialEq , Eq , PartialOrd , Ord , Hash , Encodable , Decodable ) ]
8422#[ derive( HashStable_Generic ) ]
8523pub struct NativeLib {
0 commit comments