Skip to content

Commit 023e6c4

Browse files
committed
Add --warnings warn flag to x.py
So that bootstrap itself can be built with warnings not being treated as errors.
1 parent 498553f commit 023e6c4

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/bootstrap/bootstrap.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ def bootstrap_binary(self):
835835
"""
836836
return os.path.join(self.build_dir, "bootstrap", "debug", "bootstrap")
837837

838-
def build_bootstrap(self, color, verbose_count):
838+
def build_bootstrap(self, color, warnings, verbose_count):
839839
"""Build bootstrap"""
840840
env = os.environ.copy()
841841
if "GITHUB_ACTIONS" in env:
@@ -888,7 +888,11 @@ def build_bootstrap(self, color, verbose_count):
888888
if target_linker is not None:
889889
env["RUSTFLAGS"] += " -C linker=" + target_linker
890890
env["RUSTFLAGS"] += " -Wrust_2018_idioms -Wunused_lifetimes"
891-
if self.get_toml("deny-warnings", "rust") != "false":
891+
if warnings == "default":
892+
deny_warnings = self.get_toml("deny-warnings", "rust") != "false"
893+
else:
894+
deny_warnings = warnings == "deny"
895+
if deny_warnings:
892896
env["RUSTFLAGS"] += " -Dwarnings"
893897

894898
env["PATH"] = os.path.join(self.bin_root(), "bin") + \
@@ -977,6 +981,7 @@ def parse_args():
977981
parser.add_argument('--color', choices=['always', 'never', 'auto'])
978982
parser.add_argument('--clean', action='store_true')
979983
parser.add_argument('--json-output', action='store_true')
984+
parser.add_argument('--warnings', choices=['deny', 'warn', 'default'], default='default')
980985
parser.add_argument('-v', '--verbose', action='count', default=0)
981986

982987
return parser.parse_known_args(sys.argv)[0]
@@ -1042,7 +1047,7 @@ def bootstrap(args):
10421047
# Fetch/build the bootstrap
10431048
build.download_toolchain()
10441049
sys.stdout.flush()
1045-
build.build_bootstrap(args.color, verbose_count)
1050+
build.build_bootstrap(args.color, args.warnings, verbose_count)
10461051
sys.stdout.flush()
10471052

10481053
# Run the bootstrap

0 commit comments

Comments
 (0)