I looked at the Compiler User Guide, and it also implies that `-d:release` is 
sufficient to turn on compiler optimizations. As do your comments above. 
Weird...

Here's my environment:

  * MacBook Pro, macOS 10.15.5
  * Xcode 11.5; `clang --version` reports "Apple clang version 11.0.3 
(clang-1103.0.32.62)"
  * I used to have Nim 1.2 installed from HomeBrew; this morning I uninstalled 
that, installed choosenim, and installed 1.2.2.



I'm building a Nimble package that I created a few days ago, which imports 
asynchttpserver and the 'news' WebSocket library. I'm using `nimble build` to 
compile. My `nim.cfg` file contains: 
    
    
    --path:src
    --outdir:bin
    --hints:off
    
    
    Run

I'll use binary size as a rough indicator of optimization, for now.

  * Default (debug): binary size is 752K
  * With `-d:release`: 701K
  * With `-d:release --opt:speed`: 608K
  * With `-d:release --opt:size`: 528K
  * With `-d:release --opt:size --stackTrace:off --lineTrace:off 
--assertions:off --checks:off`: 273K
  * With `-d:danger`: 752K
  * With `-d:danger --opt:speed`: 647K
  * With `-d: danger --opt:size`: 570K
  * With `-d: danger --opt:size --stackTrace:off --lineTrace:off 
--assertions:off --checks:off`: 307K



Conclusions: It definitely appears `-d:release` is not turning on 
optimizations. And it's weird that `-d:danger` results in a larger binary; it 
should be the other way around since it disables generating runtime checks, 
right? 

Reply via email to