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 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