You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While looking at nim-lang/nimble#62 I started bisecting the code and quickly found that the compiler generates bad C code with -d:release for certain programs on OSX. This can be verified using the zip for 0.9.6 running the following commands:
$ sh build.sh
$ bin/nimrod c -d:release --parallelBuild:1 koch
config/nimrod.cfg(38, 2) Hint: added path: '/Users/gradha/.babel/pkgs/' [Path]
Hint: used config file '/private/tmp/distri/nimrod/config/nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: koch [Processing]
Hint: os [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
Hint: times [Processing]
Hint: posix [Processing]
Hint: parseopt [Processing]
lib/pure/parseopt.nim(54, 34) Warning: 'quoteIfContainsWhite' is deprecated [Deprecated]
koch.nim(19, 16) Warning: 'parseopt' is deprecated [Deprecated]
Hint: osproc [Processing]
Hint: strtabs [Processing]
Hint: hashes [Processing]
Hint: streams [Processing]
Hint: cpuinfo [Processing]
lib/pure/osproc.nim(250, 13) Warning: 'startCmd' is deprecated [Deprecated]
lib/pure/osproc.nim(274, 19) Warning: 'startCmd' is deprecated [Deprecated]
lib/pure/osproc.nim(282, 14) Warning: 'startCmd' is deprecated [Deprecated]
lib/pure/osproc.nim(756, 6) Warning: 'osError' is deprecated [Deprecated]
lib/pure/osproc.nim(922, 10) Warning: 'startCmd' is deprecated [Deprecated]
lib/pure/osproc.nim(724, 7) Hint: 'osproc.startProcessAuxFork(data: TStartProcessData): TPid' is declared but not used [XDeclaredButNotUsed]
koch.nim(21, 12) Warning: undeclared conditional symbol; use --symbol to declare it: withUpdate [User]
koch.nim(23, 12) Warning: undeclared conditional symbol; use --symbol to declare it: haveZipLib [User]
koch.nim(186, 11) Hint: 'dir' is declared but not used [XDeclaredButNotUsed]
koch.nim(217, 12) Warning: undeclared conditional symbol; use --symbol to declare it: withUpdate [User]
koch.nim(314, 16) Warning: undeclared conditional symbol; use --symbol to declare it: withUpdate [User]
nimcache/cpuinfo.c:10:1: error: extraneous closing brace ('}')
}
^
1 error generated.
Error: execution of an external program failed
The most simple example which I could reduce to find the problem is:
import osproc
echo "Hey"
Unfortunately compiling cpuinfo.nim alone doesn't fail compilation. However I did find out that the following patch fixes the problem:
diff --git a/lib/pure/concurrency/cpuinfo.nim b/lib/pure/concurrency/cpuinfo.nim
index 8d7f28f..7b0f120 100644
--- a/lib/pure/concurrency/cpuinfo.nim+++ b/lib/pure/concurrency/cpuinfo.nim@@ -28,7 +28,7 @@ when defined(openbsd) or defined(netbsd):
when defined(macosx) or defined(bsd):
# we HAVE to emit param.h before sysctl.h so we cannot use .header here
# either. The amount of archaic bullshit in Poonix based OSes is just insane.
- {.emit:"#include <sys/sysctl.h>".}+ {.emit:"#include <sys/sysctl.h>\n".}
const
CTL_HW = 6
HW_AVAILCPU = 25
The nim compiler doesn't have these problems and compiles nimble and other code fine in release mode. I'm not submitting this as a patch, if the emit was the problem it would also fail compilation of the lone cpuinfo.nim, yet that works, so I suspect the problem is elsewhere. For reference, here are the generated C files in different modes:
May I suggest putting out an official 0.9.6.1 release that includes the newline changes to emit? We have to apply a workaround patch for Homebrew/legacy-homebrew#34693, and I really don't want to push out a development version of Nimrod over Homebrew.
While looking at nim-lang/nimble#62 I started bisecting the code and quickly found that the compiler generates bad C code with
-d:release
for certain programs on OSX. This can be verified using the zip for 0.9.6 running the following commands:The most simple example which I could reduce to find the problem is:
Unfortunately compiling
cpuinfo.nim
alone doesn't fail compilation. However I did find out that the following patch fixes the problem:The nim compiler doesn't have these problems and compiles nimble and other code fine in release mode. I'm not submitting this as a patch, if the
emit
was the problem it would also fail compilation of the lonecpuinfo.nim
, yet that works, so I suspect the problem is elsewhere. For reference, here are the generated C files in different modes:tl;dr, whatever source imports
osproc
won't compile on OSX with unpatched 0.9.6.The text was updated successfully, but these errors were encountered: