Skip to content

Commit 465fd06

Browse files
authored
add warnings for gc:option (#19722)
1 parent 2f32b45 commit 465fd06

File tree

1 file changed

+49
-42
lines changed

1 file changed

+49
-42
lines changed

compiler/commands.nim

Lines changed: 49 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,50 @@ proc unregisterArcOrc(conf: ConfigRef) =
527527
excl conf.globalOptions, optSeqDestructors
528528
excl conf.globalOptions, optTinyRtti
529529

530+
proc processMemoryManagementOption(switch, arg: string, pass: TCmdLinePass,
531+
info: TLineInfo; conf: ConfigRef) =
532+
if conf.backend == backendJs: return # for: bug #16033
533+
expectArg(conf, switch, arg, pass, info)
534+
if pass in {passCmd2, passPP}:
535+
case arg.normalize
536+
of "boehm":
537+
unregisterArcOrc(conf)
538+
conf.selectedGC = gcBoehm
539+
defineSymbol(conf.symbols, "boehmgc")
540+
incl conf.globalOptions, optTlsEmulation # Boehm GC doesn't scan the real TLS
541+
of "refc":
542+
unregisterArcOrc(conf)
543+
conf.selectedGC = gcRefc
544+
of "markandsweep":
545+
unregisterArcOrc(conf)
546+
conf.selectedGC = gcMarkAndSweep
547+
defineSymbol(conf.symbols, "gcmarkandsweep")
548+
of "destructors", "arc":
549+
registerArcOrc(pass, conf, false)
550+
of "orc":
551+
registerArcOrc(pass, conf, true)
552+
of "hooks":
553+
conf.selectedGC = gcHooks
554+
defineSymbol(conf.symbols, "gchooks")
555+
incl conf.globalOptions, optSeqDestructors
556+
processOnOffSwitchG(conf, {optSeqDestructors}, arg, pass, info)
557+
if pass in {passCmd2, passPP}:
558+
defineSymbol(conf.symbols, "nimSeqsV2")
559+
of "go":
560+
unregisterArcOrc(conf)
561+
conf.selectedGC = gcGo
562+
defineSymbol(conf.symbols, "gogc")
563+
of "none":
564+
unregisterArcOrc(conf)
565+
conf.selectedGC = gcNone
566+
defineSymbol(conf.symbols, "nogc")
567+
of "stack", "regions":
568+
unregisterArcOrc(conf)
569+
conf.selectedGC = gcRegions
570+
defineSymbol(conf.symbols, "gcregions")
571+
of "v2": warningOptionNoop(arg)
572+
else: localError(conf, info, errNoneBoehmRefcExpectedButXFound % arg)
573+
530574
proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
531575
conf: ConfigRef) =
532576
var
@@ -626,48 +670,11 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
626670
processOnOffSwitchG(conf, {optForceFullMake}, arg, pass, info)
627671
of "project":
628672
processOnOffSwitchG(conf, {optWholeProject, optGenIndex}, arg, pass, info)
629-
of "gc", "mm":
630-
if conf.backend == backendJs: return # for: bug #16033
631-
expectArg(conf, switch, arg, pass, info)
632-
if pass in {passCmd2, passPP}:
633-
case arg.normalize
634-
of "boehm":
635-
unregisterArcOrc(conf)
636-
conf.selectedGC = gcBoehm
637-
defineSymbol(conf.symbols, "boehmgc")
638-
incl conf.globalOptions, optTlsEmulation # Boehm GC doesn't scan the real TLS
639-
of "refc":
640-
unregisterArcOrc(conf)
641-
conf.selectedGC = gcRefc
642-
of "markandsweep":
643-
unregisterArcOrc(conf)
644-
conf.selectedGC = gcMarkAndSweep
645-
defineSymbol(conf.symbols, "gcmarkandsweep")
646-
of "destructors", "arc":
647-
registerArcOrc(pass, conf, false)
648-
of "orc":
649-
registerArcOrc(pass, conf, true)
650-
of "hooks":
651-
conf.selectedGC = gcHooks
652-
defineSymbol(conf.symbols, "gchooks")
653-
incl conf.globalOptions, optSeqDestructors
654-
processOnOffSwitchG(conf, {optSeqDestructors}, arg, pass, info)
655-
if pass in {passCmd2, passPP}:
656-
defineSymbol(conf.symbols, "nimSeqsV2")
657-
of "go":
658-
unregisterArcOrc(conf)
659-
conf.selectedGC = gcGo
660-
defineSymbol(conf.symbols, "gogc")
661-
of "none":
662-
unregisterArcOrc(conf)
663-
conf.selectedGC = gcNone
664-
defineSymbol(conf.symbols, "nogc")
665-
of "stack", "regions":
666-
unregisterArcOrc(conf)
667-
conf.selectedGC = gcRegions
668-
defineSymbol(conf.symbols, "gcregions")
669-
of "v2": warningOptionNoop(arg)
670-
else: localError(conf, info, errNoneBoehmRefcExpectedButXFound % arg)
673+
of "gc":
674+
warningDeprecated(conf, info, "`gc:option` is deprecated; use `mm:option` instead")
675+
processMemoryManagementOption(switch, arg, pass, info, conf)
676+
of "mm":
677+
processMemoryManagementOption(switch, arg, pass, info, conf)
671678
of "warnings", "w":
672679
if processOnOffSwitchOrList(conf, {optWarns}, arg, pass, info): listWarnings(conf)
673680
of "warning": processSpecificNote(arg, wWarning, pass, info, switch, conf)

0 commit comments

Comments
 (0)