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
Currently only a few named compilers can be specified on the Nim command line, and if they are not on the hard-coded list of all compilers then an error will occur, e.g. using --cc:foo. It would be great if there was a new command line option -- e.g. --forceCC:on|off -- which allows any compatible compiler to be used even if it's not on the hard-coded list, e.g. using --cc:foo --forceCC:on.
Description
So Nim can compile to C. So I tried to run cwrap [1] with Nim. cwrap works by pretending to be gcc (so Nim thinks it is just compiling as usual...!) and then using special gcc features to discover all the functions during compilation, and then create all the code necessary to instrument all those functions. Each instrumented function then has its own unique verbosity level which can be set dynamically at runtime. FYI it was possible to get the two working together and I posted instructions for an example Nim hello world program instrumented with cwrap here [2]. The only issue was the hard-coded list of compilers which needed a hacky workaround...
If your C compiler is GCC-compatible, you can just do --gcc.exe:"mycompiler" (--gcc.exe:"cwrap" in your case), no need for hacky workarounds :)
Also, if you want to reduce the "noisiness" from instrumentation, it might be worth to compile in release mode with -d:release (turns off stuff like stack traces - the nimFrame/popFrame you see in your log) and use the new ORC GC with --gc:orc (it's generally more predictive), or even --gc:arc if your program doesn't form cycles.
Sweet! Thanks @Yardanico for all your tips which all worked out well, and I posted my experiences here [1] :-)
I noticed that --define:release invokes gcc with its -O3 option. And --define:release --opt:size invokes gcc with its -Os option. How to get Nim to invoke gcc with e.g. -O2 instead of -O3? In Nim forums then I see Nim developers posting Nim benchmark results with -O2 but after a little Googling I can't figure out how to get Nim to invoke gcc with e.g. -O2 instead of -O3?
Actually yes, I did see that option and try it, but it didn't work for me :-( Why not? So e.g. if I give Nim --passC:"-Os" --define:release or --define:release --passC:"-Os" then the gcc line that gets invoked always contains -Os -O3 in that order, and so the -O3 continues to have precedence.
since user flags are passed after Nim-specific ones
Maybe this desired behavior is no longer working as expected?
Summary
Currently only a few named compilers can be specified on the Nim command line, and if they are not on the hard-coded list of all compilers then an error will occur, e.g. using
--cc:foo
. It would be great if there was a new command line option -- e.g.--forceCC:on|off
-- which allows any compatible compiler to be used even if it's not on the hard-coded list, e.g. using--cc:foo --forceCC:on
.Description
So Nim can compile to C. So I tried to run
cwrap
[1] with Nim.cwrap
works by pretending to begcc
(so Nim thinks it is just compiling as usual...!) and then using specialgcc
features to discover all the functions during compilation, and then create all the code necessary to instrument all those functions. Each instrumented function then has its own unique verbosity level which can be set dynamically at runtime. FYI it was possible to get the two working together and I posted instructions for an example Nim hello world program instrumented withcwrap
here [2]. The only issue was the hard-coded list of compilers which needed a hacky workaround...[1] https://github.com/corelight/cwrap
[2] corelight/cwrap#2
Alternatives
n/a
Additional Information
n/a
The text was updated successfully, but these errors were encountered: