@@ -14,7 +14,7 @@ found in the [FFI section of the book][ffi].
1414
1515r[ link.type] 
1616In one session of compilation, the compiler can generate multiple artifacts
17- through the usage of either command line flags or the ` crate_type `  attribute.
17+ through the usage of either command line flags or the [ ` crate_type `  attribute] .
1818If one or more command line flags are specified, all ` crate_type `  attributes will
1919be ignored in favor of only building the artifacts specified by command line.
2020
@@ -105,6 +105,10 @@ same method. If only `crate_type` attributes are specified, then they will all
105105be built, but if one or more ` --crate-type `  command line flags are specified,
106106then only those outputs will be built.
107107
108+ <!--  TODO: Add a rule that combining certain crate types is not allowed.
109+ https://github.com/rust-lang/rust/blob/5526a2f47cd676ceeedc08cf71ae75ce2e9284ae/compiler/rustc_interface/src/passes.rs#L258-L265 
110+ --> 
111+ 
108112r[ link.dependency] 
109113With all these different kinds of outputs, if crate A depends on crate B, then
110114the compiler could find B in various different forms throughout the system. The
@@ -165,6 +169,26 @@ In general, `--crate-type=bin` or `--crate-type=lib` should be sufficient for
165169all compilation needs, and the other options are just available if more
166170fine-grained control is desired over the output format of a crate.
167171
172+ r[ link.crate_type] 
173+ ## The ` crate_type `  attribute  
174+ 
175+ r[ link.crate_type.intro] 
176+ The * ` crate_type `  [ attribute] [ attributes ] *  is used to specify the [ crate type] [ link.type ]  of the crate.
177+ 
178+ >  [ !EXAMPLE] 
179+ >  ``` rust 
180+ > #![crate_type =  " lib"  ] 
181+ > ``` 
182+ 
183+ r [link . crate_type. syntax]
184+ The  `crate_type ` attribute  uses  the  [MetaNameValueStr ] syntax  to  specify  the  crate  type . 
185+ 
186+ r [link . crate_type. allowed- positions ]
187+ The  `crate_type ` attribute  may  only  be  applied  to  the  crate  root . 
188+ 
189+ r [link . crate_type. duplicates]
190+ If  the  `crate_type ` is  specified  multiple  times , then  the  crate  is  built  for  all  of  the  given  crate  types . 
191+ 
168192r [link . crt]
169193## Static  and  dynamic  C  runtimes  
170194
@@ -302,3 +326,4 @@ If a Rust artifact is potentially unwinding, then all its crates must be built w
302326[ procedural macros ] : procedural-macros.md 
303327[ panic strategy ] : panic.md#panic-strategy 
304328[ `-C panic` ] : ../rustc/codegen-options/index.html#panic 
329+ [ `crate_type` attribute ] : link.crate_type 
0 commit comments