My application is a Tcl interpreter, so it doesn't directly link with libtcc1.a and rather tries to dynamically load it. This is working fine with 32-bit Linux but not Windows.
In trying to force linking with libtcc1.a, I hit more problems. The main issue is that without "-Wl,-whole-archive", the linker sees no reason to include any part of libtcc1.a, since no part of the application uses it. Then when I do use "-Wl,-whole-archive", I get other link errors due to other object files in libtcc1.a that I don't care about, stuff about WinMain or whatever. Sorry, I didn't bother to take detailed notes on that, since I moved on to directly trying to pull in libtcc1.o and alloca86.o since that's all I think I need. But while I did get them to link by hand, I couldn't figure out how to mechanize the required link command within the framework of the Tcl application build system, so I couldn't invoke the rest of the build process needed to give the interpreter its virtual filesystem.
So I'm stepping back from that to ask how it's supposed to work for my application to link to libtcc1.a rather than rely on tcc to dynamically load libtcc1.a, which is what it's doing nicely on Linux already.
Granted, this libtcc1.a dynamic loading might be bolted onto tcc by the patches that come with tcc4tcl, so if anything I'm saying sounds alien to the design of tcc, let me know so I can bug the tcc4tcl author instead.
I tried hard to use gdb to debug dynamic loading, but it's proving to be a nightmare in Windows. gdb is not showing me my arguments, it's claiming all functions are defined in some unrelated C++ header file, and I had to find and build debugbreak.c just to be able to Ctrl+C my process and get back to the gdb prompt. And stdout isn't working for me either. So I'm really not sure how to debug. Nevertheless, I do see that pe_add_runtime() is being called, which in turn tries and fails to load libtcc1.a using tcc_add_dll(). I wish I could inspect the arguments being passed to tcc_add_file_internal(), but gdb is not cooperating, despite me compiling everything with -ggdb3 and forgoing the strip stage of the Tcl build process.