File nim-fix-gcc-major-version-detection.patch of Package nim.17613
Index: nim-1.6.6/compiler/extccomp.nim
===================================================================
--- nim-1.6.6.orig/compiler/extccomp.nim
+++ nim-1.6.6/compiler/extccomp.nim
@@ -14,7 +14,7 @@
import ropes, platform, condsyms, options, msgs, lineinfos, pathutils
-import std/[os, strutils, osproc, sha1, streams, sequtils, times, strtabs, json, jsonutils, sugar]
+import std/[os, strutils, osproc, sha1, streams, sequtils, times, strtabs, json, jsonutils, sugar, parseutils]
type
TInfoCCProp* = enum # properties of the C compiler:
@@ -512,26 +512,11 @@ proc ccHasSaneOverflow*(conf: ConfigRef)
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)
+ let (s, exitCode) = try: execCmdEx(exe & " -dumpversion") 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
+ var major: int
+ discard parseInt(s, major)
+ result = major > 5
else:
result = conf.cCompiler == ccCLang