[Frontend] Remove deprecated -O.xx flag (#29991)

Signed-off-by: Yanan Cao <gmagogsfm@gmail.com>
This commit is contained in:
Yanan Cao
2025-12-05 00:47:22 -08:00
committed by GitHub
parent feecba09af
commit 62b3333448
3 changed files with 21 additions and 29 deletions
+8 -13
View File
@@ -244,9 +244,15 @@ class FlexibleArgumentParser(ArgumentParser):
else:
key = pattern.sub(repl, arg, count=1)
processed_args.append(key)
elif arg.startswith("-O") and arg != "-O" and arg[2] != ".":
elif arg.startswith("-O."):
# Provide clear error for deprecated -O.* syntax
raise ValueError(
f"The -O.* syntax is no longer supported. "
f"Please use -cc.* instead. "
f"For example, replace '{arg}' with '{arg.replace('-O', '-cc', 1)}'"
)
elif arg.startswith("-O") and arg != "-O":
# allow -O flag to be used without space, e.g. -O3 or -Odecode
# -O.<...> handled later
# also handle -O=<optimization_level> here
optimization_level = arg[3:] if arg[2] == "=" else arg[2:]
processed_args += ["--optimization-level", optimization_level]
@@ -257,17 +263,6 @@ class FlexibleArgumentParser(ArgumentParser):
):
# Convert -O <n> to --optimization-level <n>
processed_args.append("--optimization-level")
elif arg.startswith("-O."):
# Handle -O.* dotted syntax - ALL dotted syntax is deprecated
logger.warning_once(
"The -O.* dotted syntax for --compilation-config is "
"deprecated and will be removed in v0.13.0 or v1.0.0"
", whichever is earlier. Please use -cc.* instead. "
"Example: -cc.backend=eager instead of "
"-O.backend=eager."
)
converted_arg = arg.replace("-O", "-cc", 1)
processed_args.append(converted_arg)
else:
processed_args.append(arg)