nim-lang / Nim

Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula. Its design focuses on efficiency, expressiveness, and elegance (in that order of priority).
https://nim-lang.org
Other
16.43k stars 1.47k forks source link

-mm flag is ignored on latest Nim 1.7.1 be4bd8 #20426

Closed pouriyajamshidi closed 1 year ago

pouriyajamshidi commented 1 year ago

What happened?

Compiling a program with -mm flag ignores the instruction.

In the output below, I am instructing the compiler to use orc memory management but we see that it uses refc.

nim c -d:release -mm:orc --threads:off -o:ananim ana.nim
Hint: mm: refc; opt: speed; options: -d:release
43992 lines; 2.694s; 61.184MiB peakmem; proj: /tmp/ana.nim; out: /tmp/ananim [SuccessX]

Nim Version

pouriya@DESKTOP-2EOD7PM:/tmp$  nim --version
Nim Compiler Version 1.7.1 [Linux: amd64]
Compiled at 2022-09-23
Copyright (c) 2006-2022 by Andreas Rumpf

git hash: be4bd8a0edd527b24679372b8cb9d2afa548056d
active boot switches: -d:release

Current Standard Output Logs

pouriya@DESKTOP-2EOD7PM:/tmp$  nim --version
Nim Compiler Version 1.7.1 [Linux: amd64]
Compiled at 2022-09-23
Copyright (c) 2006-2022 by Andreas Rumpf

git hash: be4bd8a0edd527b24679372b8cb9d2afa548056d
active boot switches: -d:release
pouriya@DESKTOP-2EOD7PM:/tmp$  nim c -d:release -mm:orc --threads:off -o:ananim ana.nim
command line(1, 2) Warning: 'm' is deprecated, now a noop [Deprecated]
command line(1, 2) Warning: 'm' is deprecated, now a noop [Deprecated]
Hint: used config file '/home/pouriya/.choosenim/toolchains/nim-#devel/config/nim.cfg' [Conf]
Hint: used config file '/home/pouriya/.choosenim/toolchains/nim-#devel/config/config.nims' [Conf]
...............................................................................
CC: ../home/pouriya/.choosenim/toolchains/nim-#devel/lib/std/private/digitsutils.nim
CC: ../home/pouriya/.choosenim/toolchains/nim-#devel/lib/std/assertions.nim
CC: ../home/pouriya/.choosenim/toolchains/nim-#devel/lib/system/dollars.nim
CC: ../home/pouriya/.choosenim/toolchains/nim-#devel/lib/std/syncio.nim
CC: ../home/pouriya/.choosenim/toolchains/nim-#devel/lib/system.nim
CC: ../home/pouriya/.choosenim/toolchains/nim-#devel/lib/pure/hashes.nim
CC: ../home/pouriya/.choosenim/toolchains/nim-#devel/lib/pure/math.nim
CC: ../home/pouriya/.choosenim/toolchains/nim-#devel/lib/pure/algorithm.nim
CC: ../home/pouriya/.choosenim/toolchains/nim-#devel/lib/pure/collections/tables.nim
CC: ../home/pouriya/.choosenim/toolchains/nim-#devel/lib/pure/parseutils.nim
CC: ../home/pouriya/.choosenim/toolchains/nim-#devel/lib/pure/unicode.nim
CC: ../home/pouriya/.choosenim/toolchains/nim-#devel/lib/pure/strutils.nim
CC: ../home/pouriya/.choosenim/toolchains/nim-#devel/lib/pure/strformat.nim
CC: ana.nim
Hint:  [Link]
Hint: mm: refc; opt: speed; options: -d:release
43992 lines; 2.694s; 61.184MiB peakmem; proj: /tmp/ana.nim; out: /tmp/ananim [SuccessX]

Expected Standard Output Logs

nim c -d:release -mm:orc --threads:off -o:ananim ana.nim
command line(1, 2) Warning: 'm' is deprecated, now a noop [Deprecated]
command line(1, 2) Warning: 'm' is deprecated, now a noop [Deprecated]
Hint: used config file '/home/pouriya/.choosenim/toolchains/nim-#devel/config/nim.cfg' [Conf]
Hint: used config file '/home/pouriya/.choosenim/toolchains/nim-#devel/config/config.nims' [Conf]
...............................................................................
CC: ../home/pouriya/.choosenim/toolchains/nim-#devel/lib/std/private/digitsutils.nim
CC: ../home/pouriya/.choosenim/toolchains/nim-#devel/lib/std/assertions.nim
CC: ../home/pouriya/.choosenim/toolchains/nim-#devel/lib/system/dollars.nim
CC: ../home/pouriya/.choosenim/toolchains/nim-#devel/lib/std/syncio.nim
CC: ../home/pouriya/.choosenim/toolchains/nim-#devel/lib/system.nim
CC: ../home/pouriya/.choosenim/toolchains/nim-#devel/lib/pure/hashes.nim
CC: ../home/pouriya/.choosenim/toolchains/nim-#devel/lib/pure/math.nim
CC: ../home/pouriya/.choosenim/toolchains/nim-#devel/lib/pure/algorithm.nim
CC: ../home/pouriya/.choosenim/toolchains/nim-#devel/lib/pure/collections/tables.nim
CC: ../home/pouriya/.choosenim/toolchains/nim-#devel/lib/pure/parseutils.nim
CC: ../home/pouriya/.choosenim/toolchains/nim-#devel/lib/pure/unicode.nim
CC: ../home/pouriya/.choosenim/toolchains/nim-#devel/lib/pure/strutils.nim
CC: ../home/pouriya/.choosenim/toolchains/nim-#devel/lib/pure/strformat.nim
CC: ana.nim
Hint:  [Link]
Hint: mm: **orc**; opt: speed; options: -d:release
43992 lines; 2.694s; 61.184MiB peakmem; proj: /tmp/ana.nim; out: /tmp/ananim [SuccessX]
console

Possible Solution

use -gc instead of -mm on the latest version.

Additional Information

If you specify -gc:orc instead of -mm:orc, the compiler uses the right memory management algorithm.

ringabout commented 1 year ago

You are supposed to use --mm:orc instead of -mm:orc, otherwise it will be interpreted as -m and its value.

It does give a noop warning

command line(1, 2) Warning: 'm' is deprecated, now a noop [Deprecated]
command line(1, 2) Warning: 'm' is deprecated, now a noop [Deprecated]
pouriyajamshidi commented 1 year ago

you are right. thanks!