File tree 4 files changed +30
-2
lines changed
4 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -207,6 +207,15 @@ passthrough = [
207
207
]
208
208
```
209
209
210
+ ### Unstable Features
211
+
212
+ Certain unstable features can enable additional functionality useful to
213
+ cross-compiling. Note that these are unstable, and may be removed at any
214
+ time (particularly if the feature is stabilized or removed), and will
215
+ only be used on a nightly channel.
216
+
217
+ - ` CROSS_UNSTABLE_ENABLE_DOCTESTS=true ` : also run doctests.
218
+
210
219
### Mounting volumes into the build environment
211
220
212
221
In addition to passing environment variables, you can also specify environment
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ pub struct Args {
14
14
pub target : Option < Target > ,
15
15
pub target_dir : Option < PathBuf > ,
16
16
pub docker_in_docker : bool ,
17
+ pub enable_doctests : bool ,
17
18
}
18
19
19
20
// Fix for issue #581. target_dir must be absolute.
@@ -75,6 +76,9 @@ pub fn parse(target_list: &TargetList) -> Result<Args> {
75
76
let docker_in_docker = env:: var ( "CROSS_DOCKER_IN_DOCKER" )
76
77
. map ( |s| bool:: from_str ( & s) . unwrap_or_default ( ) )
77
78
. unwrap_or_default ( ) ;
79
+ let enable_doctests = env:: var ( "CROSS_UNSTABLE_ENABLE_DOCTESTS" )
80
+ . map ( |s| bool:: from_str ( & s) . unwrap_or_default ( ) )
81
+ . unwrap_or_default ( ) ;
78
82
79
83
Ok ( Args {
80
84
all,
@@ -83,5 +87,6 @@ pub fn parse(target_list: &TargetList) -> Result<Args> {
83
87
target,
84
88
target_dir,
85
89
docker_in_docker,
90
+ enable_doctests,
86
91
} )
87
92
}
Original file line number Diff line number Diff line change @@ -279,6 +279,7 @@ fn run() -> Result<ExitStatus> {
279
279
280
280
let host_version_meta =
281
281
rustc_version:: version_meta ( ) . wrap_err ( "couldn't fetch the `rustc` version" ) ?;
282
+ let is_nightly = rustc:: is_nightly ( & args. channel , & host_version_meta) ;
282
283
if let Some ( root) = cargo:: root ( ) ? {
283
284
let host = host_version_meta. host ( ) ;
284
285
let toml = toml ( & root) ?;
@@ -358,7 +359,7 @@ fn run() -> Result<ExitStatus> {
358
359
. map ( |sc| sc. needs_interpreter ( ) )
359
360
. unwrap_or ( false ) ;
360
361
361
- let filtered_args = if args
362
+ let mut filtered_args = if args
362
363
. subcommand
363
364
. map_or ( false , |s| !s. needs_target_in_command ( ) )
364
365
{
@@ -384,6 +385,11 @@ fn run() -> Result<ExitStatus> {
384
385
args. all . clone ( )
385
386
} ;
386
387
388
+ let is_test = args. subcommand . map ( |sc| sc == Subcommand :: Test ) . unwrap_or ( false ) ;
389
+ if is_test && args. enable_doctests && is_nightly {
390
+ filtered_args. push ( "-Zdoctest-xcompile" . to_string ( ) ) ;
391
+ }
392
+
387
393
if target. needs_docker ( ) && args. subcommand . map ( |sc| sc. needs_docker ( ) ) . unwrap_or ( false )
388
394
{
389
395
if host_version_meta. needs_interpreter ( )
Original file line number Diff line number Diff line change 1
1
use std:: path:: PathBuf ;
2
2
use std:: process:: Command ;
3
3
4
- use rustc_version:: { Version , VersionMeta } ;
4
+ use rustc_version:: { Channel , Version , VersionMeta } ;
5
5
6
6
use crate :: errors:: * ;
7
7
use crate :: extensions:: CommandExt ;
@@ -33,6 +33,14 @@ impl VersionMetaExt for VersionMeta {
33
33
}
34
34
}
35
35
36
+ pub fn is_nightly ( channel : & Option < String > , host_version_meta : & VersionMeta ) -> bool {
37
+ if let Some ( channel) = channel {
38
+ channel. contains ( "nightly" )
39
+ } else {
40
+ host_version_meta. channel == Channel :: Nightly
41
+ }
42
+ }
43
+
36
44
pub fn target_list ( verbose : bool ) -> Result < TargetList > {
37
45
Command :: new ( "rustc" )
38
46
. args ( & [ "--print" , "target-list" ] )
You can’t perform that action at this time.
0 commit comments