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.55k stars 1.47k forks source link

Compiling with tcc needs -DNIM_EmulateOverflowChecks [nim 1.2.x+] #14171

Open kaushalmodi opened 4 years ago

kaushalmodi commented 4 years ago

Compilations break when compiling with --cc:tcc.

Example

echo 0

Current Output

CC: stdlib_io.nim
CC: stdlib_system.nim
CC: t.nim
/tmp/kmodi/.cache/nim/t_d/stdlib_io.nim.c:56: error: invalid type
Error: execution of an external compiler program 'tcc -c -w   -I/home/kmodi/usr_local/apps/6/nim/devel/lib -I/home/kmodi/sandbox/nim/tcc -o /tmp/kmodi/.cache/nim/t_d/stdlib_io.nim.c.o /tmp/kmodi/.cache/nim/t_d/stdlib_io.nim.c' failed with exit code: 1

/tmp/kmodi/.cache/nim/t_d/stdlib_system.nim.c:457: error: invalid type

Here is the full stdlib_io.nim.c.

Expected Output

0

Possible Solution

Additional Information

$ nim -v
Nim Compiler Version 1.3.1 [Linux: amd64]
Compiled at 2020-04-30
Copyright (c) 2006-2020 by Andreas Rumpf

git hash: d6e1b5c070bf58449bf4af210ec099418d496aa5
active boot switches: -d:release
c-blake commented 4 years ago

I would recommend just fixing the ifdef switching at the bottom of nimbase.h with an || defined(__TINYC__). Realistically, tcc is never going to grow all those gcc/clang __builtin_*s.

cooldome commented 4 years ago

yes, please fix nimbase.h instead

kaushalmodi commented 4 years ago

@c-blake I tried building nim locally with https://github.com/kaushalmodi/Nim/commit/dba6ec7b69a4472b4324834b2cfd3fe5e6a24cc7, but this issue doesn't get fixed.

Do you want to bring a closure to this issue with a verified PR?

kaushalmodi commented 4 years ago

ok.. seeing the diff again, may be I need to put the tinycc outside that wrapped OR condition

c-blake commented 4 years ago

I commented on the PR, too. But I think you figured it out.

kaushalmodi commented 4 years ago

But I think you figured it out.

Yep :). I also verified that that PR works fine locally.

c-blake commented 4 years ago

Works for me with both tcc and gcc. Should pass the CI no problem, I'd expect.