cnlohr / noeuclid

Non-euclidean GPU Raytraced Game
BSD 3-Clause "New" or "Revised" License
644 stars 48 forks source link

LibTCC: tcc_set_output_type isn't called. #40

Closed kitlith closed 7 years ago

kitlith commented 7 years ago

At least, as of later TCC versions... In tests/libtcc_test.c

/* MUST BE CALLED before any compilation */
tcc_set_output_type(s, TCC_OUTPUT_MEMORY);

This is currently not done, and results in errors like:

tcc: error: library 'libc' not found
tcc: error: file 'crtn.o' not found
uname -r
# 4.10.6-1-ARCH
tcc -v
# tcc version 0.9.26 (x86-64 Linux)

EDIT: Forgot to mention a way of getting it to work. In TCC.h, instead of calling tcc_new() if tcc doesn't exist, I created a function init() that calls tcc_new() and calls tcc_set_output_type() for you, and called that.

cnlohr commented 7 years ago

Do you mind making a pull request for this?

kitlith commented 7 years ago

No, I don't mind. I didn't make a request initially due to me just hacking it about. I should get it together in a 'few' minutes.

kitlith commented 7 years ago

... More than a few, I guess.

I set out to do it "properly" using a class constructor and destructor. "Why is this segfaulting?" pokes around with gdb "Hold on, why is 'tcc' 0?" pokes around some more "Okay, it's definately being set, but by the time it gets over here it's 0... is something else setting it?"

tcc = 0;

Oh. So much for that. (also: memory leak, much?)

I'll make a PR that applies my original fix, and then look into reusing the TCCState object.