8
8
9
9
The proposed change to Cargo is to add the ability to specify user-defined
10
10
profiles in addition to the five predefined profiles, ` dev ` , ` release ` , ` test ` ,
11
- ` bench ` , and the less talked-about ` doc ` . It is also desired in this scope to
12
- reduce confusion regarding where final outputs reside, and increase the
13
- flexibility to specify the user-defined profile attributes.
11
+ ` bench ` . It is also desired in this scope to reduce confusion regarding where
12
+ final outputs reside, and increase the flexibility to specify the user-defined
13
+ profile attributes.
14
14
15
15
# Motivation
16
16
[ motivation ] : #motivation
@@ -47,6 +47,9 @@ For example:
47
47
inherits = "release"
48
48
lto = true
49
49
50
+ Valid profile names are: must not be empty, use only alphanumeric characters or
51
+ ` - ` or ` _ ` .
52
+
50
53
Passing ` --profile ` with the profile's name to various Cargo commands will
51
54
resolve to the custom profile. Overrides specified in the profiles from which
52
55
the custom profile inherits will be inherited too, and all final outputs may
@@ -71,6 +74,18 @@ This also affects other Cargo commands:
71
74
* ` cargo doc ` also receives ` --profile ` , but unless it is specified, uses
72
75
the predefined ` doc ` profile which is described below.
73
76
77
+ ## Effect over the use of profile in commands
78
+
79
+ The mixtures of profiles used for ` --all-targets ` is still in effect, as
80
+ long as ` --profile ` is not specified.
81
+
82
+ ## Combined specification with ` --release `
83
+
84
+ For now, ` --release ` is supported for backward-compatibility.
85
+
86
+ Using ` --profile ` and ` --release ` together in the same invocation emits an
87
+ error unless ` --profile=release ` . Using ` --release ` on its own is equivalent
88
+ to specifying ` --profile=release `
74
89
75
90
## New ` dir-name ` attribute
76
91
@@ -88,8 +103,13 @@ when left unspecified, defaults to the name of the profile. For example:
88
103
` test ` to their respective directories: ` target/release ` and ` target/debug ` .
89
104
This preserves existing behavior.
90
105
* The ` dir-name ` attribute is the only attribute not passed by inheritance.
91
- * Path separators are not allowed in ` dir-name ` .
106
+ * Valid directory names are: must not be empty, use only alphanumeric
107
+ characters or ` - ` or ` _ ` .
92
108
109
+ ## Cross compilation
110
+
111
+ Under cross compilation with a profile, paths corresponding to
112
+ ` target/<platform-triple>/<dir-name> ` will be created.
93
113
94
114
## Treatment to the pre-defined profiles
95
115
@@ -125,29 +145,16 @@ inherits = "dev"
125
145
dir-name = "debug"
126
146
```
127
147
128
-
129
148
* The (upcoming) ` build ` profile defaults to the following definition:
149
+
130
150
```
131
151
[profile.build]
132
152
inherits = "dev"
133
153
dir-name = "build"
134
154
debug = false
135
155
```
136
156
137
-
138
- ## Treatment to Cargo's 'Finished' print
139
-
140
- For ` cargo build ` , the profile's name is emitted in the "Finished" line:
141
-
142
- Finished release-lto [optimized + lto] target(s) in 3.83s
143
-
144
- * As before, optimization mode is always printed, with ` optimized ` if
145
- ` opt-level > 0 ` and ` unoptimized ` otherwise.
146
- * As before, information regarding debuginfo is printed, with ` debuginfo ` if
147
- ` debug != false ` , and nothing if ` debug == false ` (or ` debug == 0 ` ).
148
- * Other differences from the inherited root profile pre-defined defaults are
149
- printed in a concise manner.
150
-
157
+ (NOTE: the ` build ` profile is experimental and may be removed later)
151
158
152
159
# Reference-level explanation
153
160
[ reference-level-explanation ] : #reference-level-explanation
@@ -175,13 +182,15 @@ Release, Custom(String))`.
175
182
* We would need to compute the actual ` build_override ` for a profile based on
176
183
resolution through the ` inherits ` key.
177
184
* Custom build scripts: For compatibility, the ` PROFILE ` environment currently
178
- being passed to the ` build.rs ` script is going to bear the name of the output
179
- directory and not the name of the profile.
185
+ being passed to the ` build.rs ` script is set to either ` release ` or ` debug ` ,
186
+ based on ` inherits ` relationship of the specified profile, in case it is not
187
+ ` release ` or ` dev ` directly.
180
188
181
- ## Collision under the target directory
189
+ ## Profile name and directory name exclusion
182
190
183
- To guard against the unlikely case that a target name is identical to a profile
184
- name, we should compare the lists for overlap.
191
+ To prevent collisions under the target directory, predefined set of string
192
+ excludes both the custom profile names and the dir-name. For example,
193
+ ` package ` , ` build ` , ` debug ` , ` doc ` , and strings that start with ` . ` .
185
194
186
195
# Drawbacks
187
196
[ drawbacks ] : #drawbacks
@@ -270,6 +279,21 @@ similar functionality in a different way.
270
279
# Future possibilities
271
280
[ future-possibilities ] : #future-possibilities
272
281
273
- This RFC mentioned a global binary cache. A global binary cache can reside
274
- under ` target/.cache ` or in the user home directory under ` .cargo ` , to be
275
- shared by multiple workspaces.
282
+ This RFC mentions a global binary cache. A global binary cache can reside under
283
+ ` target/.cache ` or in the user home directory under ` .cargo ` , to be shared by
284
+ multiple workspaces. This may further assist in reducing compilation times when
285
+ switching between compilation flags.
286
+
287
+ ## Treatment to Cargo's 'Finished' print
288
+
289
+ Currently, the ` Finished ` line being emitted when Cargo is done building, is
290
+ confusing, and sometimes does not bear a relation to the specified profile. We
291
+ may take this opportunity to revise the output of this line to include the name
292
+ of the profile.
293
+
294
+ Some targets use more than one profile in their compilation process, so we may
295
+ want to pick a different scheme than simply printing out the name of the main
296
+ profile being used. One option is to print a line for each one of the built
297
+ targets with concise description of profiles that used to build it, but there
298
+ may be better options worth considering following the implementation of this
299
+ RFC.
0 commit comments