@@ -153,12 +153,21 @@ fn set_env(cx: &Context, cmd: &mut ProcessBuilder) {
153
153
154
154
let rustflags = & mut cx. ws . config . rustflags ( ) . unwrap_or_default ( ) ;
155
155
rustflags. push_str ( " -Z instrument-coverage" ) ;
156
+ // --remap-path-prefix is needed because sometimes macros are displayed with absolute path
157
+ rustflags. push_str ( & format ! ( " --remap-path-prefix {}/=" , cx. ws. metadata. workspace_root) ) ;
158
+ if cfg ! ( windows) {
159
+ // `-C codegen-units=1` is needed to work around link error on windows
160
+ // https://github.com/rust-lang/rust/issues/85461
161
+ // https://github.com/microsoft/windows-rs/issues/1006#issuecomment-887789950
162
+ rustflags. push_str ( " -C codegen-units=1" ) ;
163
+ }
156
164
if !cx. cov . no_cfg_coverage {
157
165
rustflags. push_str ( " --cfg coverage" ) ;
158
166
}
159
- // --remap-path-prefix is needed because sometimes macros are displayed with absolute path
160
- rustflags. push_str ( & format ! ( " --remap-path-prefix {}/=" , cx. ws. metadata. workspace_root) ) ;
161
167
if cx. build . target . is_none ( ) {
168
+ // https://github.com/dtolnay/trybuild/pull/121
169
+ // https://github.com/dtolnay/trybuild/issues/122
170
+ // https://github.com/dtolnay/trybuild/pull/123
162
171
rustflags. push_str ( " --cfg trybuild_no_target" ) ;
163
172
}
164
173
@@ -170,6 +179,9 @@ fn set_env(cx: &Context, cmd: &mut ProcessBuilder) {
170
179
" -Z instrument-coverage -Z unstable-options --persist-doctests {}" ,
171
180
cx. ws. doctests_dir
172
181
) ) ;
182
+ if cfg ! ( windows) {
183
+ rustdocflags. push_str ( " -C codegen-units=1" ) ;
184
+ }
173
185
if !cx. cov . no_cfg_coverage {
174
186
rustdocflags. push_str ( " --cfg coverage" ) ;
175
187
}
0 commit comments