tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] Large files causes infinite loop on mac


From: Herman ten Brugge
Subject: Re: [Tinycc-devel] Large files causes infinite loop on mac
Date: Tue, 27 Dec 2022 13:28:13 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0

On 12/27/22 07:58, Herman ten Brugge wrote:
On 12/27/22 05:45, Levo D wrote:
I'm messing around with tcc. I don't need this to be fixed, I just thought someone may want the report. I'm trying to figure out how fast the tcc backend is for my compiler. I seem to hit an infinite loop on mac osx venture. I built tcc earlier this month (Dec 2022). I suspect it's an overflow bug. Here's how to reproduce, on linux x86-64 it errors out at a smaller number.

Run the following python script (I copied it below) https://bolinlang.com/genc.py

python3 ./genc.py 2200000 4

Create object files then try to link. It'll loop forever

tcc -c *.c
tcc *.o

You can try building it straight which will build but won't execute

$ tcc *.c
$ ./a.out
dyld[4330]: dyld cache '(null)' not loaded: syscall to map cache into shared region failed
dyld[4330]: Library not loaded: /usr/lib/libSystem.B.dylib
   Referenced from: <no uuid> /private/tmp/t/test/a.out
   Reason: tried: '/usr/lib/libSystem.B.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/lib/libSystem.B.dylib' (no such file), '/usr/lib/libSystem.B.dylib' (no such file, no dyld cache), '/usr/local/lib/libSystem.B.dylib' (no such file)
Abort trap: 6

Using a smaller number everything works fine. I'll repeat that I'm just playing around and don't need this to work. Here's a copy paste of the python script
I fixed the forever loop.
The code now compiles but does not run. I get:

dyld[74088]: dyld cache '/System/Library/dyld/dyld_shared_cache_arm64e' not loaded: syscall to map cache into shared region failed
dyld[74088]: Library not loaded: '/usr/lib/libSystem.B.dylib'
  Referenced from: '/Users/hermantb/tinycc/tst/a.out'
  Reason: tried: '/usr/lib/libSystem.B.dylib' (no such file), '/usr/local/lib/libSystem.B.dylib' (no such file)
Abort trap: 6

Probably because the bss section is larger then 4G.

I also tried to compile you code with gcc/clang on fedora(x86_64) and also get overflow reports when compiling.
So probably there is a limit some where. I did not check.

So if gcc/clang cannot compile the code tcc can fail as well.


I updated the python script. I can now run:

$ python3 ./genc.py 100000000 100
$ tcc -bench -c *.c
* 78156 idents, 1157015 lines, 28090333 bytes
* 91.295 s, 12673 lines/s, 0.3 MB/s
* text 11784304, data.rw 0, data.ro 0, bss 4000000 bytes
$ tcc -bench *.o
* 0 idents, 0 lines, 1 bytes
* 3.383 s, 0 lines/s, 0.0 MB/s
* text 0, data.rw 0, data.ro 0, bss 0 bytes

updated lines in script:
29c29
<                 file.write(f"\tstatic int array[{nextFunctionIndex}];\n")
---
>                 file.write(f"\tstatic int array[{nextFunctionIndex-functionStartIndex}];\n")
33c33
<                 r = math.floor(random.random()*nextFunctionIndex)
---
>                 r = math.floor(random.random()*(nextFunctionIndex-functionStartIndex))






reply via email to

[Prev in Thread] Current Thread [Next in Thread]