Closed timotheecour closed 8 months ago
"-d:release -d:danger don't work as expected in user configs" is really a bad gotcha that we should fix somehow. Unfortunately adding opt
doesn't "fix" it at all.
it would provide a viable workaround, a user would use: --opt:danger
in his config instead of a non-working -d:danger
The people who know about the workaround are exactly the people who know about the problem and can avoid it... Sometimes you simply have to fix a gotcha, not hack around it.
This RFC is stale because it has been open for 1095 days with no activity. Contribute a fix or comment on the issue, or it will be closed in 30 days.
originally suggested here: https://github.com/nim-lang/Nim/pull/15614#issuecomment-713816279
proposal:
extend
--opt
to support additional arguments: lto, strip, release, danger. This effectively turns lto,release,danger,strip into proper flags, like the rest (--experimental, --hint etc).arguments can be negated in the same way as already done with
--hint:foo
, using sequential processing, eg:--opt:lto --opt:lto:off
would result in no lto, whereas--opt:lto:off --opt:lto
would result in lto.optional sugar: allow comma separated arguments, eg:
--opt:lto,strip,danger
introspection: code can query for those flags using
compileOption("opt", "lto")
etc. Existing code usingdefined(release)
would continue to work, so that--opt:release
would implydefined(release)
example
nim --opt:lto,danger --opt:lto:off
results in--opt:strip
rationale
type safety you get CT error when a flag has a typo, both with
--opt:foo
andcompileOption("opt", "foo")
.--opt
introduces its own scoping, avoiding the need for a nim prefix indefined(nimLto)
+ friendsdiscoverability all supported values are listed in
nim --fullhelp
, just like for--experimental
works with user config and command line, unlike -d:release, -d:lto, -d:strip + friends: would fix https://github.com/nim-lang/Nim/pull/15614#issuecomment-712343858 (lto and strip) would fix https://github.com/nim-lang/Nim/issues/14272 would fix https://github.com/nim-lang/Nim/issues/12349