diff options
Diffstat (limited to 'src/main.c')
| -rw-r--r-- | src/main.c | 26 |
1 files changed, 24 insertions, 2 deletions
@@ -56,7 +56,11 @@ void print_usage() int main(int argc, char **argv) { memset(&g_config, 0, sizeof(g_config)); +#ifdef __COSMOPOLITAN__ + strcpy(g_config.cc, "cosmocc"); +#else strcpy(g_config.cc, "gcc"); +#endif if (argc < 2) { @@ -339,9 +343,23 @@ int main(int argc, char **argv) char cmd[8192]; char *outfile = g_config.output_file ? g_config.output_file : "a.out"; - snprintf(cmd, sizeof(cmd), "%s %s %s %s %s -o %s %s -lm %s -I./src %s", g_config.cc, + const char *thread_flag = g_parser_ctx->has_async ? "-lpthread" : ""; + const char *math_flag = "-lm"; + +#ifdef _WIN32 + // Windows might use different flags or none for math/threads + math_flag = ""; + if (g_parser_ctx->has_async) + { + thread_flag = ""; + } +#endif + + // If using cosmocc, it handles these usually, but keeping them is okay for Linux targets + + snprintf(cmd, sizeof(cmd), "%s %s %s %s %s -o %s %s %s %s -I./src %s", g_config.cc, g_config.gcc_flags, g_cflags, g_config.is_freestanding ? "-ffreestanding" : "", "", - outfile, temp_source_file, g_parser_ctx->has_async ? "-lpthread" : "", g_link_flags); + outfile, temp_source_file, math_flag, thread_flag, g_link_flags); if (g_config.verbose) { @@ -368,7 +386,11 @@ int main(int argc, char **argv) if (g_config.mode_run) { char run_cmd[2048]; +#ifdef _WIN32 + sprintf(run_cmd, "%s", outfile); +#else sprintf(run_cmd, "./%s", outfile); +#endif ret = system(run_cmd); remove(outfile); zptr_plugin_mgr_cleanup(); |
