mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-16 08:01:24 -07:00
Replace js_wasm32 with freestanding_wasm32
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
//+build !windows
|
||||
//+build !freestanding
|
||||
//+build !js
|
||||
package runtime
|
||||
|
||||
when ODIN_DEFAULT_TO_NIL_ALLOCATOR {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//+build freestanding, js
|
||||
//+build freestanding
|
||||
package runtime
|
||||
|
||||
// mem.nil_allocator reimplementation
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
//+build !freestanding
|
||||
//+build !windows
|
||||
//+build !js
|
||||
package runtime
|
||||
|
||||
import "core:os"
|
||||
|
||||
+12
-6
@@ -10,7 +10,6 @@ enum TargetOsKind {
|
||||
TargetOs_darwin,
|
||||
TargetOs_linux,
|
||||
TargetOs_essence,
|
||||
TargetOs_js,
|
||||
TargetOs_freebsd,
|
||||
|
||||
TargetOs_freestanding,
|
||||
@@ -44,7 +43,6 @@ String target_os_names[TargetOs_COUNT] = {
|
||||
str_lit("darwin"),
|
||||
str_lit("linux"),
|
||||
str_lit("essence"),
|
||||
str_lit("js"),
|
||||
str_lit("freebsd"),
|
||||
|
||||
str_lit("freestanding"),
|
||||
@@ -312,8 +310,8 @@ gb_global TargetMetrics target_essence_amd64 = {
|
||||
str_lit("x86_64-pc-none-elf"),
|
||||
};
|
||||
|
||||
gb_global TargetMetrics target_js_wasm32 = {
|
||||
TargetOs_js,
|
||||
gb_global TargetMetrics target_freestanding_wasm32 = {
|
||||
TargetOs_freestanding,
|
||||
TargetArch_wasm32,
|
||||
4,
|
||||
8,
|
||||
@@ -330,15 +328,15 @@ struct NamedTargetMetrics {
|
||||
|
||||
gb_global NamedTargetMetrics named_targets[] = {
|
||||
{ str_lit("darwin_amd64"), &target_darwin_amd64 },
|
||||
{ str_lit("darwin_arm64"), &target_darwin_arm64 },
|
||||
{ str_lit("darwin_arm64"), &target_darwin_arm64 },
|
||||
{ str_lit("essence_amd64"), &target_essence_amd64 },
|
||||
{ str_lit("js_wasm32"), &target_js_wasm32 },
|
||||
{ str_lit("linux_386"), &target_linux_386 },
|
||||
{ str_lit("linux_amd64"), &target_linux_amd64 },
|
||||
{ str_lit("windows_386"), &target_windows_386 },
|
||||
{ str_lit("windows_amd64"), &target_windows_amd64 },
|
||||
{ str_lit("freebsd_386"), &target_freebsd_386 },
|
||||
{ str_lit("freebsd_amd64"), &target_freebsd_amd64 },
|
||||
{ str_lit("freestanding_wasm32"), &target_freestanding_wasm32 },
|
||||
};
|
||||
|
||||
NamedTargetMetrics *selected_target_metrics;
|
||||
@@ -443,6 +441,14 @@ bool find_library_collection_path(String name, String *path) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool is_arch_wasm(void) {
|
||||
return build_context.metrics.arch == TargetArch_wasm32;
|
||||
}
|
||||
|
||||
bool allow_check_foreign_filepath(void) {
|
||||
return build_context.metrics.arch != TargetArch_wasm32;
|
||||
}
|
||||
|
||||
|
||||
// TODO(bill): OS dependent versions for the BuildContext
|
||||
// join_path
|
||||
|
||||
+1
-1
@@ -151,7 +151,7 @@ void lb_add_function_type_attributes(LLVMValueRef fn, lbFunctionType *ft, ProcCa
|
||||
|
||||
lbCallingConventionKind cc_kind = lbCallingConvention_C;
|
||||
// TODO(bill): Clean up this logic
|
||||
if (build_context.metrics.os != TargetOs_js) {
|
||||
if (!is_arch_wasm()) {
|
||||
cc_kind = lb_calling_convention_map[calling_convention];
|
||||
}
|
||||
LLVMSetFunctionCallConv(fn, cc_kind);
|
||||
|
||||
+19
-17
@@ -2753,7 +2753,7 @@ lbProcedure *lb_create_procedure(lbModule *m, Entity *entity, bool ignore_body)
|
||||
if (false) {
|
||||
lbCallingConventionKind cc_kind = lbCallingConvention_C;
|
||||
// TODO(bill): Clean up this logic
|
||||
if (build_context.metrics.os != TargetOs_js) {
|
||||
if (!is_arch_wasm()) {
|
||||
cc_kind = lb_calling_convention_map[pt->Proc.calling_convention];
|
||||
}
|
||||
LLVMSetFunctionCallConv(p->value, cc_kind);
|
||||
@@ -2815,13 +2815,13 @@ lbProcedure *lb_create_procedure(lbModule *m, Entity *entity, bool ignore_body)
|
||||
LLVMSetDLLStorageClass(p->value, LLVMDLLExportStorageClass);
|
||||
LLVMSetVisibility(p->value, LLVMDefaultVisibility);
|
||||
|
||||
if (build_context.metrics.os == TargetOs_js) {
|
||||
if (is_arch_wasm()) {
|
||||
char const *export_name = alloc_cstring(permanent_allocator(), p->name);
|
||||
LLVMAddTargetDependentFunctionAttr(p->value, "wasm-export-name", export_name);
|
||||
}
|
||||
}
|
||||
if (p->is_foreign) {
|
||||
if (build_context.metrics.os == TargetOs_js) {
|
||||
if (is_arch_wasm()) {
|
||||
char const *import_name = alloc_cstring(permanent_allocator(), p->name);
|
||||
char const *module_name = "env";
|
||||
if (entity->Procedure.foreign_library != nullptr) {
|
||||
@@ -2959,7 +2959,7 @@ lbProcedure *lb_create_dummy_procedure(lbModule *m, String link_name, Type *type
|
||||
Type *pt = p->type;
|
||||
lbCallingConventionKind cc_kind = lbCallingConvention_C;
|
||||
// TODO(bill): Clean up this logic
|
||||
if (build_context.metrics.os != TargetOs_js) {
|
||||
if (!is_arch_wasm()) {
|
||||
cc_kind = lb_calling_convention_map[pt->Proc.calling_convention];
|
||||
}
|
||||
LLVMSetFunctionCallConv(p->value, cc_kind);
|
||||
@@ -14901,18 +14901,20 @@ String lb_filepath_obj_for_module(lbModule *m) {
|
||||
if (build_context.build_mode == BuildMode_Assembly) {
|
||||
ext = STR_LIT(".S");
|
||||
} else {
|
||||
switch (build_context.metrics.os) {
|
||||
case TargetOs_windows:
|
||||
ext = STR_LIT(".obj");
|
||||
break;
|
||||
case TargetOs_darwin:
|
||||
case TargetOs_linux:
|
||||
case TargetOs_essence:
|
||||
ext = STR_LIT(".o");
|
||||
break;
|
||||
case TargetOs_js:
|
||||
ext = STR_LIT(".wasm-obj");
|
||||
break;
|
||||
if (is_arch_wasm()) {
|
||||
ext = STR_LIT(".wasm.o");
|
||||
} else {
|
||||
switch (build_context.metrics.os) {
|
||||
case TargetOs_windows:
|
||||
ext = STR_LIT(".obj");
|
||||
break;
|
||||
default:
|
||||
case TargetOs_darwin:
|
||||
case TargetOs_linux:
|
||||
case TargetOs_essence:
|
||||
ext = STR_LIT(".o");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15099,7 +15101,7 @@ void lb_generate_code(lbGenerator *gen) {
|
||||
TIME_SECTION("LLVM Create Target Machine");
|
||||
|
||||
LLVMCodeModel code_mode = LLVMCodeModelDefault;
|
||||
if (build_context.metrics.arch == TargetArch_wasm32) {
|
||||
if (is_arch_wasm()) {
|
||||
code_mode = LLVMCodeModelJITDefault;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -152,7 +152,7 @@ i32 linker_stage(lbGenerator *gen) {
|
||||
|
||||
String output_base = gen->output_base;
|
||||
|
||||
if (build_context.metrics.os == TargetOs_js) {
|
||||
if (is_arch_wasm()) {
|
||||
timings_start_section(timings, str_lit("wasm-ld"));
|
||||
system_exec_command_line_app("wasm-ld",
|
||||
"\"%.*s\\bin\\wasm-ld\" \"%.*s.wasm-obj\" -o \"%.*s.wasm\" %.*s %.*s",
|
||||
|
||||
+1
-1
@@ -5121,7 +5121,7 @@ void parse_setup_file_decls(Parser *p, AstFile *f, String base_dir, Slice<Ast *>
|
||||
for_array(fp_idx, fl->filepaths) {
|
||||
String file_str = fl->filepaths[fp_idx].string;
|
||||
String fullpath = file_str;
|
||||
if (build_context.metrics.os != TargetOs_js) {
|
||||
if (allow_check_foreign_filepath()) {
|
||||
String foreign_path = {};
|
||||
bool ok = determine_path_from_string(&p->file_decl_mutex, node, base_dir, file_str, &foreign_path);
|
||||
if (!ok) {
|
||||
|
||||
Reference in New Issue
Block a user