diff options
-rw-r--r-- | compiler/commands.nim | 5 | ||||
-rw-r--r-- | compiler/options.nim | 2 | ||||
-rw-r--r-- | lib/pure/coro.nim | 2 | ||||
-rw-r--r-- | lib/pure/os.nim | 2 | ||||
-rw-r--r-- | lib/system.nim | 22 | ||||
-rw-r--r-- | lib/system/ansi_c.nim | 2 | ||||
-rw-r--r-- | lib/system/coro_detection.nim | 20 | ||||
-rw-r--r-- | lib/system/excpt.nim | 2 | ||||
-rw-r--r-- | lib/system/io.nim | 2 | ||||
-rw-r--r-- | tests/cpp/tcovariancerules.nim | 2 |
10 files changed, 32 insertions, 29 deletions
diff --git a/compiler/commands.nim b/compiler/commands.nim index 278199bc0..32f56ad0e 100644 --- a/compiler/commands.nim +++ b/compiler/commands.nim @@ -34,9 +34,6 @@ from ast import eqTypeFlags, tfGcSafe, tfNoSideEffect # but some have deps to imported modules. Yay. bootSwitch(usedTinyC, hasTinyCBackend, "-d:tinyc") -bootSwitch(usedNativeStacktrace, - defined(nativeStackTrace) and nativeStackTraceSupported, - "-d:nativeStackTrace") bootSwitch(usedFFI, hasFFI, "-d:nimHasLibFFI") type @@ -101,7 +98,7 @@ proc writeVersionInfo(conf: ConfigRef; pass: TCmdLinePass) = msgWriteln(conf, "git hash: " & gitHash, {msgStdout}) msgWriteln(conf, "active boot switches:" & usedRelease & usedDanger & - usedTinyC & useLinenoise & usedNativeStacktrace & + usedTinyC & useLinenoise & usedFFI & usedBoehm & usedMarkAndSweep & usedGoGC & usedNoGC, {msgStdout}) msgQuit(0) diff --git a/compiler/options.nim b/compiler/options.nim index 4773ba284..36e0e64da 100644 --- a/compiler/options.nim +++ b/compiler/options.nim @@ -21,6 +21,8 @@ const hasFFI* = defined(nimHasLibFFI) copyrightYear* = "2021" + nimEnableCovariance* = defined(nimEnableCovariance) + type # please make sure we have under 32 options # (improves code efficiency a lot!) TOption* = enum # **keep binary compatible** diff --git a/lib/pure/coro.nim b/lib/pure/coro.nim index e3ed6aadd..f4495a536 100644 --- a/lib/pure/coro.nim +++ b/lib/pure/coro.nim @@ -21,6 +21,8 @@ ## ## Unstable API. +import system/coro_detection + when not nimCoroutines and not defined(nimdoc): when defined(noNimCoroutines): {.error: "Coroutines can not be used with -d:noNimCoroutines".} diff --git a/lib/pure/os.nim b/lib/pure/os.nim index 50a88b43b..287fbe125 100644 --- a/lib/pure/os.nim +++ b/lib/pure/os.nim @@ -1910,7 +1910,7 @@ proc copyFileToDir*(source, dir: string, options = {cfSymlinkFollow}) copyFile(source, dir / source.lastPathPart, options) when not declared(ENOENT) and not defined(windows): - when NoFakeVars: + when defined(nimscript): when not defined(haiku): const ENOENT = cint(2) # 2 on most systems including Solaris else: diff --git a/lib/system.nim b/lib/system.nim index c2c3306d4..e9c036b8a 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -537,7 +537,7 @@ const include "system/inclrtl" -const NoFakeVars* = defined(nimscript) ## `true` if the backend doesn't support \ +const NoFakeVars = defined(nimscript) ## `true` if the backend doesn't support \ ## "fake variables" like `var EBADF {.importc.}: cint`. const notJSnotNims = not defined(js) and not defined(nimscript) @@ -1132,7 +1132,6 @@ const const hasThreadSupport = compileOption("threads") and not defined(nimscript) hasSharedHeap = defined(boehmgc) or defined(gogc) # don't share heaps; every thread has its own - nimEnableCovariance* = defined(nimEnableCovariance) # or true when hasThreadSupport and defined(tcc) and not compileOption("tlsEmulation"): # tcc doesn't support TLS @@ -1920,24 +1919,7 @@ include "system/gc_interface" # we have to compute this here before turning it off in except.nim anyway ... const NimStackTrace = compileOption("stacktrace") -template coroutinesSupportedPlatform(): bool = - when defined(sparc) or defined(ELATE) or defined(boehmgc) or defined(gogc) or - defined(nogc) or defined(gcRegions) or defined(gcMarkAndSweep): - false - else: - true - -when defined(nimCoroutines): - # Explicit opt-in. - when not coroutinesSupportedPlatform(): - {.error: "Coroutines are not supported on this architecture and/or garbage collector.".} - const nimCoroutines* = true -elif defined(noNimCoroutines): - # Explicit opt-out. - const nimCoroutines* = false -else: - # Autodetect coroutine support. - const nimCoroutines* = false +import system/coro_detection {.push checks: off.} # obviously we cannot generate checking operations here :-) diff --git a/lib/system/ansi_c.nim b/lib/system/ansi_c.nim index 7e156eaab..e5f26e070 100644 --- a/lib/system/ansi_c.nim +++ b/lib/system/ansi_c.nim @@ -74,7 +74,7 @@ elif defined(haiku): SIGPIPE* = cint(7) SIG_DFL* = cast[CSighandlerT](0) else: - when NoFakeVars: + when defined(nimscript): {.error: "SIGABRT not ported to your platform".} else: var diff --git a/lib/system/coro_detection.nim b/lib/system/coro_detection.nim new file mode 100644 index 000000000..f6c1b5c15 --- /dev/null +++ b/lib/system/coro_detection.nim @@ -0,0 +1,20 @@ +## Coroutine detection logic + +template coroutinesSupportedPlatform(): bool = + when defined(sparc) or defined(ELATE) or defined(boehmgc) or defined(gogc) or + defined(nogc) or defined(gcRegions) or defined(gcMarkAndSweep): + false + else: + true + +when defined(nimCoroutines): + # Explicit opt-in. + when not coroutinesSupportedPlatform(): + {.error: "Coroutines are not supported on this architecture and/or garbage collector.".} + const nimCoroutines* = true +elif defined(noNimCoroutines): + # Explicit opt-out. + const nimCoroutines* = false +else: + # Autodetect coroutine support. + const nimCoroutines* = false diff --git a/lib/system/excpt.nim b/lib/system/excpt.nim index da034e57e..8ba3a1601 100644 --- a/lib/system/excpt.nim +++ b/lib/system/excpt.nim @@ -146,7 +146,7 @@ proc closureIterSetupExc(e: ref Exception) {.compilerproc, inline.} = # some platforms have native support for stack traces: const - nativeStackTraceSupported* = (defined(macosx) or defined(linux)) and + nativeStackTraceSupported = (defined(macosx) or defined(linux)) and not NimStackTrace hasSomeStackTrace = NimStackTrace or defined(nimStackTraceOverride) or (defined(nativeStackTrace) and nativeStackTraceSupported) diff --git a/lib/system/io.nim b/lib/system/io.nim index 300e7ea3f..594c78209 100644 --- a/lib/system/io.nim +++ b/lib/system/io.nim @@ -252,7 +252,7 @@ proc write*(f: File, s: string) {.tags: [WriteIOEffect], benign.} = raiseEIO("cannot write string to file") {.pop.} -when NoFakeVars: +when defined(nimscript): when defined(windows): const IOFBF = cint(0) diff --git a/tests/cpp/tcovariancerules.nim b/tests/cpp/tcovariancerules.nim index 49fe8015b..5ac7d8bac 100644 --- a/tests/cpp/tcovariancerules.nim +++ b/tests/cpp/tcovariancerules.nim @@ -31,7 +31,7 @@ import macros macro skipElse(n: untyped): untyped = n[0] template acceptWithCovariance(x, otherwise): untyped = - when nimEnableCovariance: + when defined nimEnableCovariance: x else: reject(x) |