Skip to content

Commit

Permalink
Serialize compilation with libtcc
Browse files Browse the repository at this point in the history
  • Loading branch information
fwsGonzo committed Jun 22, 2024
1 parent 315d4d3 commit d42cb57
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/libriscv/tr_translate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,8 +489,10 @@ VISIBLE const struct Mapping mappings[] = {
TIME_POINT(t9);
if constexpr (libtcc_enabled) {
extern void* libtcc_compile(const std::string& code, int arch, const std::unordered_map<std::string, std::string>& defines, const std::string&);
static std::mutex libtcc_mutex;
// libtcc uses global state, so we need to serialize compilation
std::lock_guard<std::mutex> lock(libtcc_mutex);
dylib = libtcc_compile(code, W, defines, options.libtcc1_location);

} else {
extern void* compile(const std::string& code, int arch, const std::string& cflags, const std::string&);
extern bool mingw_compile(const std::string& code, int arch, const std::string& cflags, const std::string&, const MachineTranslationCrossOptions&);
Expand Down

0 comments on commit d42cb57

Please sign in to comment.