Skip to content

Commit 75277c7

Browse files
committed
Auto merge of #45566 - cuviper:option-checking, r=alexcrichton
configure.py: fix --disable-option-checking and extra config paths - indexing 'option-checking' out of `known_args` had a type error - when option checking is disabled, don't error on duplicate args, just take the last - add config.toml stubs for datadir, infodir, and localstatedir (which were already accepted, but broken) --- This fixes a regression from 1.21 to beta, when the configure script was rewritten in python.
2 parents c1a0b6d + 19714f5 commit 75277c7

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

config.toml.example

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,16 @@
203203
# Where to install man pages in `prefix` above
204204
#mandir = "share/man"
205205

206+
# Where to install data in `prefix` above (currently unused)
207+
#datadir = "share"
208+
209+
# Where to install additional info in `prefix` above (currently unused)
210+
#infodir = "share/info"
211+
212+
# Where to install local state (currently unused)
213+
# If this is a relative path, it will get installed in `prefix` above
214+
#localstatedir = "/var/lib"
215+
206216
# =============================================================================
207217
# Options for compiling Rust code itself
208218
# =============================================================================

src/bootstrap/config.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,11 @@ struct Install {
207207
bindir: Option<String>,
208208
libdir: Option<String>,
209209
mandir: Option<String>,
210+
211+
// standard paths, currently unused
212+
datadir: Option<String>,
213+
infodir: Option<String>,
214+
localstatedir: Option<String>,
210215
}
211216

212217
/// TOML representation of how the LLVM build is configured.

src/bootstrap/configure.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,12 @@ def err(msg):
225225
unknown_args.append(arg)
226226
p("")
227227

228-
if 'option-checking' not in known_args or known_args['option-checking'][1]:
228+
# Note: here and a few other places, we use [-1] to apply the *last* value
229+
# passed. But if option-checking is enabled, then the known_args loop will
230+
# also assert that options are only passed once.
231+
option_checking = ('option-checking' not in known_args
232+
or known_args['option-checking'][-1][1])
233+
if option_checking:
229234
if len(unknown_args) > 0:
230235
err("Option '" + unknown_args[0] + "' is not recognized")
231236
if len(need_value_args) > 0:
@@ -238,7 +243,7 @@ def err(msg):
238243

239244
def build():
240245
if 'build' in known_args:
241-
return known_args['build'][0][1]
246+
return known_args['build'][-1][1]
242247
return bootstrap.default_build_triple()
243248

244249

@@ -276,9 +281,9 @@ def set(key, value):
276281

277282
# Ensure each option is only passed once
278283
arr = known_args[key]
279-
if len(arr) > 1:
284+
if option_checking and len(arr) > 1:
280285
err("Option '{}' provided more than once".format(key))
281-
option, value = arr[0]
286+
option, value = arr[-1]
282287

283288
# If we have a clear avenue to set our value in rustbuild, do so
284289
if option.rustbuild is not None:

0 commit comments

Comments
 (0)