You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: text/0000-rustflags.md
+24-6
Original file line number
Diff line number
Diff line change
@@ -77,12 +77,19 @@ libraries thus losing out on collecting any code coverage.
77
77
78
78
## Other examples: debuginfo, saving temp files
79
79
80
-
Other examples of this include having the ability to set the debuginfo levelfor only a single crate to save on binary size. One scenario
81
-
where this is helpful is debugging tests that are not having the expected behavior. This feature will allow a Rust developer to set the
82
-
debuginfo level for the current crate and have full debugging symbols but still allow all other dependencies to be fully optimized. This
83
-
will save on both compilation time and binary size.
80
+
Other examples of this include having the ability to set the debuginfo level, (`-C debuginfo=<val>`), for only a single crate to save on
81
+
binary size. One scenario where this is helpful is debugging tests that are not having the expected behavior. This feature will allow a
82
+
Rust developer to set the debuginfo level for the current crate and have full debugging symbols but still allow all other dependencies to
83
+
be fully optimized. This will save on both compilation time and binary size.
84
84
85
-
As with the previous example, being able to specify only saving the temporary files for the current crate as opposed to all crates in the dependency graph. This will save on disk space by not having all of the unnecessary temp files being saved on each invocation of the Rust compiler.
85
+
As with the previous example, being able to specify only saving the temporary files, (`-C save-temps`), for the current crate as opposed
86
+
to all crates in the dependency graph. This will save on disk space by not having all of the unnecessary temp files being saved on each
87
+
invocation of the Rust compiler.
88
+
89
+
There are some unstable flags that would also benefit from this feature such as the `-Z unpretty=<val>` option. This could be used to
90
+
expand the input source to allow for easier debugging of macros and proc macros. This will allow a single crate to have its input
91
+
expanded and lessen the amount of source expanded which would allow for Rust developer to better understand how a macro is affecting
92
+
their source code.
86
93
87
94
## --rustflags
88
95
@@ -299,6 +306,15 @@ This approach has the benefit of extensibility. This meaning it can easily be ex
299
306
for the root crate being built as well dependencies in the dependency graph by updating the crate name in the manifest section.
300
307
For instance, supporting `build.foo.rustflags` would also make it simpler to support `build.<dependency>.rustflags` as well.
301
308
309
+
#### Note
310
+
311
+
The `profile-rustflags` cargo feature makes it possible to support this syntax since it is used in a very similar way. The
312
+
`profile-rustflags` feature has support for setting crate specific rustflags for a profile. This syntax can simply be
313
+
re-used to support crate specific rustflags as mentioned above. This feature is currently unstable but has been widely available
314
+
for some time. Combining this with the recently stabilized `--config` cli option makes it possible to override config values
315
+
on demand on the command line. I believe this option may include the fewest amount of changes to Cargo and would leverage existing
316
+
syntax that Rust developers may already be familiar with.
317
+
302
318
An issue with this approach is that changes to the config file is more cumbersome than simply adding commands at
303
319
the CLI. This approach I believe would also make the feature more complicated in cases where a Rust developer wants to
304
320
enable a specific flag for a set of crates such as the crates within a given workspace. This approach would mean each crate
@@ -326,7 +342,9 @@ for a simple `cargo run` and especially when running tests via `cargo test`.
326
342
# Unresolved questions
327
343
[unresolved-questions]: #unresolved-questions
328
344
329
-
1. Should the cargo feature `--rustflags <RUSTFLAGS>` be dependent on the existing unstable cargo feature `-Z target-applies-to-host` to determine whether or not the rustc flags specified by the user on the cargo CLI should be passed to the invocation of rustc for build scripts defined in a given crate?
345
+
1. Should the cargo feature `--rustflags <RUSTFLAGS>` be dependent on the existing unstable cargo feature `-Z target-applies-to-host`
346
+
to determine whether or not the rustc flags specified by the user on the cargo CLI should be passed to the invocation of rustc for
0 commit comments