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

2022-12-27 Thread Herman ten Brugge via Tinycc-devel

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 220 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:  /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 1 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 400 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))





___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


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

2022-12-26 Thread Herman ten Brugge via Tinycc-devel

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 220 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:  /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.


___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


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

2022-12-26 Thread Levo D
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 220 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:  /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

import sys, math, random
if len(sys.argv) != 3:
print("Error: example usage lineAmount fileAmount", file=sys.stderr)
exit(0)

random.seed(32384)
lineAmount=int(sys.argv[1])
fileAmount=int(sys.argv[2])
nextOpenIndex=0
nextFunctionIndex=0
fileIndex=0
file=0
functionNumbers=[]
functionStartIndex=0

for i in range(0, lineAmount):
if i == nextOpenIndex:
if fileIndex != 0:
file.close()
file=open(f"file{fileIndex}.c", "wt")
fileIndex += 1
nextOpenIndex = math.ceil((fileIndex/fileAmount)*lineAmount)

if i == nextFunctionIndex:
functionStartIndex = i
file.write(f"int test{i}() {{\n")
nextFunctionIndex = min(nextFunctionIndex + 
math.floor(random.random()*1600)+500, nextOpenIndex)
file.write(f"\tstatic int array[{nextFunctionIndex}];\n")
functionNumbers.append(i)
file.write(f"\tarray[{i-functionStartIndex}] = {i*3};\n")
if i == nextFunctionIndex-1:
r = math.floor(random.random()*nextFunctionIndex)
file.write(f"\treturn array[{r}];\n")
file.write(f"}}\n")

for i in functionNumbers:
file.write(f"int test{i}();\n")
file.write("int main() {\n")
for i in functionNumbers:
file.write(f"\ttest{i}();\n")
file.write("}\n")


___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel