* fixes #14209 [backport:1.2] * improve stability
This commit is contained in:
parent
e86a6d24d5
commit
64e839d5fd
3 changed files with 32 additions and 1 deletions
|
|
@ -613,6 +613,34 @@ proc getCompilerExe(conf: ConfigRef; compiler: TSystemCC; cfile: AbsoluteFile):
|
||||||
"Compiler '$1' doesn't support the requested target" %
|
"Compiler '$1' doesn't support the requested target" %
|
||||||
CC[compiler].name)
|
CC[compiler].name)
|
||||||
|
|
||||||
|
proc ccHasSaneOverflow*(conf: ConfigRef): bool =
|
||||||
|
if conf.cCompiler == ccGcc:
|
||||||
|
result = false # assume an old or crappy GCC
|
||||||
|
var exe = getConfigVar(conf, conf.cCompiler, ".exe")
|
||||||
|
if exe.len == 0: exe = CC[conf.cCompiler].compilerExe
|
||||||
|
let (s, exitCode) = try: execCmdEx(exe & " --version") except: ("", 1)
|
||||||
|
if exitCode == 0:
|
||||||
|
var i = 0
|
||||||
|
var j = 0
|
||||||
|
# the version is the last part of the first line:
|
||||||
|
while i < s.len and s[i] != '\n':
|
||||||
|
if s[i] in {' ', '\t'}: j = i+1
|
||||||
|
inc i
|
||||||
|
if j > 0:
|
||||||
|
var major = 0
|
||||||
|
while j < s.len and s[j] in {'0'..'9'}:
|
||||||
|
major = major * 10 + (ord(s[j]) - ord('0'))
|
||||||
|
inc j
|
||||||
|
if i < s.len and s[j] == '.': inc j
|
||||||
|
while j < s.len and s[j] in {'0'..'9'}:
|
||||||
|
inc j
|
||||||
|
if j+1 < s.len and s[j] == '.' and s[j+1] in {'0'..'9'}:
|
||||||
|
# we found a third version number, chances are high
|
||||||
|
# we really parsed the version:
|
||||||
|
result = major >= 5
|
||||||
|
else:
|
||||||
|
result = conf.cCompiler == ccCLang
|
||||||
|
|
||||||
proc getLinkerExe(conf: ConfigRef; compiler: TSystemCC): string =
|
proc getLinkerExe(conf: ConfigRef; compiler: TSystemCC): string =
|
||||||
result = if CC[compiler].linkerExe.len > 0: CC[compiler].linkerExe
|
result = if CC[compiler].linkerExe.len > 0: CC[compiler].linkerExe
|
||||||
elif optMixedMode in conf.globalOptions and conf.cmd != cmdCompileToCpp: CC[compiler].cppCompiler
|
elif optMixedMode in conf.globalOptions and conf.cmd != cmdCompileToCpp: CC[compiler].cppCompiler
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,9 @@ proc commandCompileToC(graph: ModuleGraph) =
|
||||||
graph.config.notes = graph.config.mainPackageNotes
|
graph.config.notes = graph.config.mainPackageNotes
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if not extccomp.ccHasSaneOverflow(conf):
|
||||||
|
conf.symbols.defineSymbol("nimEmulateOverflowChecks")
|
||||||
|
|
||||||
compileProject(graph)
|
compileProject(graph)
|
||||||
if graph.config.errorCounter > 0:
|
if graph.config.errorCounter > 0:
|
||||||
return # issue #9933
|
return # issue #9933
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ proc raiseDivByZero {.compilerproc, noinline.} =
|
||||||
|
|
||||||
{.pragma: nimbaseH, importc, nodecl, noSideEffect, compilerproc.}
|
{.pragma: nimbaseH, importc, nodecl, noSideEffect, compilerproc.}
|
||||||
|
|
||||||
when (defined(gcc) or defined(clang) or defined(zig)) and not defined(nimEmulateOverflowChecks):
|
when not defined(nimEmulateOverflowChecks):
|
||||||
# take the #define from nimbase.h
|
# take the #define from nimbase.h
|
||||||
|
|
||||||
proc nimAddInt(a, b: int, res: ptr int): bool {.nimbaseH.}
|
proc nimAddInt(a, b: int, res: ptr int): bool {.nimbaseH.}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue