This is how I made my fork of libtcc lock-free.
Mainline has a lock so that all backends can use global variables, but only one instance can do codegen at a time.
It was a giant refactoring Especially fun was when multiple compilation units used the same static variable name, but it all worked in the end.