mirror of
https://github.com/Ed94/Odin.git
synced 2026-06-18 11:52:22 -07:00
Merge branch 'master' of https://github.com/odin-lang/Odin
This commit is contained in:
@@ -1088,7 +1088,6 @@ gb_global TargetMetrics target_orca_wasm32 = {
|
||||
TargetArch_wasm32,
|
||||
4, 4, 8, 16,
|
||||
str_lit("wasm32-wasi-js"),
|
||||
// str_lit("e-m:e-p:32:32-i64:64-n32:64-S128"),
|
||||
};
|
||||
|
||||
|
||||
@@ -1170,6 +1169,7 @@ gb_global NamedTargetMetrics named_targets[] = {
|
||||
{ str_lit("freestanding_wasm32"), &target_freestanding_wasm32 },
|
||||
{ str_lit("wasi_wasm32"), &target_wasi_wasm32 },
|
||||
{ str_lit("js_wasm32"), &target_js_wasm32 },
|
||||
{ str_lit("orca_wasm32"), &target_orca_wasm32 },
|
||||
|
||||
{ str_lit("freestanding_wasm64p32"), &target_freestanding_wasm64p32 },
|
||||
{ str_lit("js_wasm64p32"), &target_js_wasm64p32 },
|
||||
@@ -2045,11 +2045,10 @@ gb_internal void init_build_context(TargetMetrics *cross_target, Subtarget subta
|
||||
// }
|
||||
if (bc->no_entry_point || bc->metrics.os == TargetOs_orca) {
|
||||
link_flags = gb_string_appendc(link_flags, "--no-entry ");
|
||||
bc->no_entry_point = true; // just in case for the "orca" target
|
||||
}
|
||||
|
||||
|
||||
bc->link_flags = make_string_c(link_flags);
|
||||
|
||||
|
||||
// Disallow on wasm
|
||||
bc->use_separate_modules = false;
|
||||
} else {
|
||||
|
||||
+29
-15
@@ -13,6 +13,7 @@ struct LinkerData {
|
||||
};
|
||||
|
||||
gb_internal i32 system_exec_command_line_app(char const *name, char const *fmt, ...);
|
||||
gb_internal bool system_exec_command_line_app_output(char const *command, gbString *output);
|
||||
|
||||
#if defined(GB_SYSTEM_OSX)
|
||||
gb_internal void linker_enable_system_library_linking(LinkerData *ld) {
|
||||
@@ -69,27 +70,40 @@ gb_internal i32 linker_stage(LinkerData *gen) {
|
||||
if (is_arch_wasm()) {
|
||||
timings_start_section(timings, str_lit("wasm-ld"));
|
||||
|
||||
String extra_orca_flags = {};
|
||||
gbString extra_orca_flags = gb_string_make(temporary_allocator(), "");
|
||||
|
||||
gbString inputs = gb_string_make(temporary_allocator(), "");
|
||||
inputs = gb_string_append_fmt(inputs, "\"%.*s.o\"", LIT(output_filename));
|
||||
|
||||
#if defined(GB_SYSTEM_WINDOWS)
|
||||
if (build_context.metrics.os == TargetOs_orca) {
|
||||
extra_orca_flags = str_lit(" W:/orca/installation/dev-afb9591/bin/liborca_wasm.a --export-dynamic");
|
||||
gbString orca_sdk_path = gb_string_make(temporary_allocator(), "");
|
||||
if (!system_exec_command_line_app_output("orca sdk-path", &orca_sdk_path)) {
|
||||
gb_printf_err("executing `orca sdk-path` failed, make sure Orca is installed and added to your path\n");
|
||||
return 1;
|
||||
}
|
||||
if (gb_string_length(orca_sdk_path) == 0) {
|
||||
gb_printf_err("executing `orca sdk-path` did not produce output\n");
|
||||
return 1;
|
||||
}
|
||||
inputs = gb_string_append_fmt(inputs, " \"%s/orca-libc/lib/crt1.o\" \"%s/orca-libc/lib/libc.o\"", orca_sdk_path, orca_sdk_path);
|
||||
|
||||
extra_orca_flags = gb_string_append_fmt(extra_orca_flags, " -L \"%s/bin\" -lorca_wasm --export-dynamic", orca_sdk_path);
|
||||
}
|
||||
|
||||
result = system_exec_command_line_app("wasm-ld",
|
||||
"\"%.*s\\bin\\wasm-ld\" \"%.*s.o\" -o \"%.*s\" %.*s %.*s %.*s",
|
||||
LIT(build_context.ODIN_ROOT),
|
||||
LIT(output_filename), LIT(output_filename), LIT(build_context.link_flags), LIT(build_context.extra_linker_flags),
|
||||
LIT(extra_orca_flags));
|
||||
#else
|
||||
if (build_context.metrics.os == TargetOs_orca) {
|
||||
extra_orca_flags = str_lit(" -L . -lorca --export-dynamic");
|
||||
}
|
||||
|
||||
#if defined(GB_SYSTEM_WINDOWS)
|
||||
result = system_exec_command_line_app("wasm-ld",
|
||||
"wasm-ld \"%.*s.o\" -o \"%.*s\" %.*s %.*s %.*s",
|
||||
LIT(output_filename), LIT(output_filename), LIT(build_context.link_flags), LIT(build_context.extra_linker_flags),
|
||||
LIT(extra_orca_flags));
|
||||
"\"%.*s\\bin\\wasm-ld\" %s -o \"%.*s\" %.*s %.*s %s",
|
||||
LIT(build_context.ODIN_ROOT),
|
||||
inputs, LIT(output_filename), LIT(build_context.link_flags), LIT(build_context.extra_linker_flags),
|
||||
extra_orca_flags);
|
||||
#else
|
||||
result = system_exec_command_line_app("wasm-ld",
|
||||
"wasm-ld %s -o \"%.*s\" %.*s %.*s %s",
|
||||
inputs, LIT(output_filename),
|
||||
LIT(build_context.link_flags),
|
||||
LIT(build_context.extra_linker_flags),
|
||||
extra_orca_flags);
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -155,6 +155,38 @@ gb_internal i32 system_exec_command_line_app(char const *name, char const *fmt,
|
||||
return exit_code;
|
||||
}
|
||||
|
||||
#if defined(GB_SYSTEM_WINDOWS)
|
||||
#define popen _popen
|
||||
#define pclose _pclose
|
||||
#endif
|
||||
|
||||
gb_internal bool system_exec_command_line_app_output(char const *command, gbString *output) {
|
||||
GB_ASSERT(output);
|
||||
|
||||
u8 buffer[256];
|
||||
FILE *stream;
|
||||
stream = popen(command, "r");
|
||||
if (!stream) {
|
||||
return false;
|
||||
}
|
||||
defer (pclose(stream));
|
||||
|
||||
while (!feof(stream)) {
|
||||
size_t n = fread(buffer, 1, 255, stream);
|
||||
*output = gb_string_append_length(*output, buffer, n);
|
||||
|
||||
if (ferror(stream)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (build_context.show_system_calls) {
|
||||
gb_printf_err("[SYSTEM CALL OUTPUT] %s -> %s\n", command, *output);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
gb_internal Array<String> setup_args(int argc, char const **argv) {
|
||||
gbAllocator a = heap_allocator();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user