mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-22 23:47:51 +00:00
Merge remote-tracking branch 'offical/master'
This commit is contained in:
+15
-3
@@ -17,7 +17,7 @@
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
|
||||
#if defined(GB_SYSTEM_OPENBSD)
|
||||
#if defined(GB_SYSTEM_OPENBSD) || defined(GB_SYSTEM_NETBSD)
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/utsname.h>
|
||||
#endif
|
||||
@@ -263,6 +263,14 @@ gb_internal void report_ram_info() {
|
||||
if (sysctl(mibs, 2, &ram_amount, &val_size, NULL, 0) != -1) {
|
||||
gb_printf("%lld MiB\n", ram_amount / gb_megabytes(1));
|
||||
}
|
||||
#elif defined(GB_SYSTEM_NETBSD)
|
||||
uint64_t ram_amount;
|
||||
size_t val_size = sizeof(ram_amount);
|
||||
|
||||
int mibs[] = { CTL_HW, HW_PHYSMEM64 };
|
||||
if (sysctl(mibs, 2, &ram_amount, &val_size, NULL, 0) != -1) {
|
||||
gb_printf("%lu MiB\n", ram_amount / gb_megabytes(1));
|
||||
}
|
||||
#elif defined(GB_SYSTEM_OPENBSD)
|
||||
uint64_t ram_amount;
|
||||
size_t val_size = sizeof(ram_amount);
|
||||
@@ -998,13 +1006,17 @@ gb_internal void report_os_info() {
|
||||
gb_printf("macOS Unknown (kernel: %d.%d.%d)\n", major, minor, patch);
|
||||
return;
|
||||
}
|
||||
#elif defined(GB_SYSTEM_OPENBSD)
|
||||
#elif defined(GB_SYSTEM_OPENBSD) || defined(GB_SYSTEM_NETBSD)
|
||||
struct utsname un;
|
||||
|
||||
if (uname(&un) != -1) {
|
||||
gb_printf("%s %s %s %s\n", un.sysname, un.release, un.version, un.machine);
|
||||
} else {
|
||||
gb_printf("OpenBSD: Unknown\n");
|
||||
#if defined(GB_SYSTEM_NETBSD)
|
||||
gb_printf("NetBSD: Unknown\n");
|
||||
#else
|
||||
gb_printf("OpenBSD: Unknown\n");
|
||||
#endif
|
||||
}
|
||||
#elif defined(GB_SYSTEM_FREEBSD)
|
||||
#define freebsd_version_buffer 129
|
||||
|
||||
+20
-1
@@ -18,6 +18,7 @@ enum TargetOsKind : u16 {
|
||||
TargetOs_essence,
|
||||
TargetOs_freebsd,
|
||||
TargetOs_openbsd,
|
||||
TargetOs_netbsd,
|
||||
TargetOs_haiku,
|
||||
|
||||
TargetOs_wasi,
|
||||
@@ -84,6 +85,7 @@ gb_global String target_os_names[TargetOs_COUNT] = {
|
||||
str_lit("essence"),
|
||||
str_lit("freebsd"),
|
||||
str_lit("openbsd"),
|
||||
str_lit("netbsd"),
|
||||
str_lit("haiku"),
|
||||
|
||||
str_lit("wasi"),
|
||||
@@ -644,6 +646,7 @@ struct QueryDataSetSettings {
|
||||
enum BuildModeKind {
|
||||
BuildMode_Executable,
|
||||
BuildMode_DynamicLibrary,
|
||||
BuildMode_StaticLibrary,
|
||||
BuildMode_Object,
|
||||
BuildMode_Assembly,
|
||||
BuildMode_LLVM_IR,
|
||||
@@ -1020,6 +1023,13 @@ gb_global TargetMetrics target_openbsd_amd64 = {
|
||||
str_lit("x86_64-unknown-openbsd-elf"),
|
||||
};
|
||||
|
||||
gb_global TargetMetrics target_netbsd_amd64 = {
|
||||
TargetOs_netbsd,
|
||||
TargetArch_amd64,
|
||||
8, 8, AMD64_MAX_ALIGNMENT, 16,
|
||||
str_lit("x86_64-unknown-netbsd-elf"),
|
||||
};
|
||||
|
||||
gb_global TargetMetrics target_haiku_amd64 = {
|
||||
TargetOs_haiku,
|
||||
TargetArch_amd64,
|
||||
@@ -1127,6 +1137,7 @@ gb_global NamedTargetMetrics named_targets[] = {
|
||||
{ str_lit("freebsd_arm64"), &target_freebsd_arm64 },
|
||||
|
||||
{ str_lit("openbsd_amd64"), &target_openbsd_amd64 },
|
||||
{ str_lit("netbsd_amd64"), &target_netbsd_amd64 },
|
||||
{ str_lit("haiku_amd64"), &target_haiku_amd64 },
|
||||
|
||||
{ str_lit("freestanding_wasm32"), &target_freestanding_wasm32 },
|
||||
@@ -1886,6 +1897,8 @@ gb_internal void init_build_context(TargetMetrics *cross_target, Subtarget subta
|
||||
#endif
|
||||
#elif defined(GB_SYSTEM_OPENBSD)
|
||||
metrics = &target_openbsd_amd64;
|
||||
#elif defined(GB_SYSTEM_NETBSD)
|
||||
metrics = &target_netbsd_amd64;
|
||||
#elif defined(GB_SYSTEM_HAIKU)
|
||||
metrics = &target_haiku_amd64;
|
||||
#elif defined(GB_CPU_ARM)
|
||||
@@ -2272,7 +2285,12 @@ gb_internal bool init_build_paths(String init_filename) {
|
||||
} else if (build_context.metrics.os == TargetOs_darwin) {
|
||||
output_extension = STR_LIT("dylib");
|
||||
}
|
||||
} else if (build_context.build_mode == BuildMode_Object) {
|
||||
} else if (build_context.build_mode == BuildMode_StaticLibrary) {
|
||||
output_extension = STR_LIT("a");
|
||||
if (build_context.metrics.os == TargetOs_windows) {
|
||||
output_extension = STR_LIT("lib");
|
||||
}
|
||||
}else if (build_context.build_mode == BuildMode_Object) {
|
||||
// By default use a .o object extension.
|
||||
output_extension = STR_LIT("o");
|
||||
|
||||
@@ -2423,6 +2441,7 @@ gb_internal bool init_build_paths(String init_filename) {
|
||||
case TargetOs_essence:
|
||||
case TargetOs_freebsd:
|
||||
case TargetOs_openbsd:
|
||||
case TargetOs_netbsd:
|
||||
case TargetOs_haiku:
|
||||
gb_printf_err("-no-crt on unix systems requires either -default-to-nil-allocator or -default-to-panic-allocator to also be present because the default allocator requires crt\n");
|
||||
return false;
|
||||
|
||||
+13
-33
@@ -2440,32 +2440,6 @@ gb_internal bool check_is_not_addressable(CheckerContext *c, Operand *o) {
|
||||
return o->mode != Addressing_Variable && o->mode != Addressing_SoaVariable;
|
||||
}
|
||||
|
||||
gb_internal void check_old_for_or_switch_value_usage(Ast *expr) {
|
||||
Entity *e = entity_of_node(expr);
|
||||
if (e != nullptr && (e->flags & EntityFlag_OldForOrSwitchValue) != 0) {
|
||||
GB_ASSERT(e->kind == Entity_Variable);
|
||||
|
||||
ERROR_BLOCK();
|
||||
|
||||
if ((e->flags & EntityFlag_ForValue) != 0) {
|
||||
Type *parent_type = type_deref(e->Variable.for_loop_parent_type);
|
||||
|
||||
error(expr, "Assuming a for-in defined value is addressable as the iterable is passed by value has been disallowed.");
|
||||
|
||||
if (is_type_map(parent_type)) {
|
||||
error_line("\tSuggestion: Prefer doing 'for key, &%.*s in ...'\n", LIT(e->token.string));
|
||||
} else {
|
||||
error_line("\tSuggestion: Prefer doing 'for &%.*s in ...'\n", LIT(e->token.string));
|
||||
}
|
||||
} else {
|
||||
GB_ASSERT((e->flags & EntityFlag_SwitchValue) != 0);
|
||||
|
||||
error(expr, "Assuming a switch-in defined value is addressable as the iterable is passed by value has been disallowed.");
|
||||
error_line("\tSuggestion: Prefer doing 'switch &%.*s in ...'\n", LIT(e->token.string));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gb_internal void check_unary_expr(CheckerContext *c, Operand *o, Token op, Ast *node) {
|
||||
switch (op.kind) {
|
||||
case Token_And: { // Pointer address
|
||||
@@ -2493,7 +2467,10 @@ gb_internal void check_unary_expr(CheckerContext *c, Operand *o, Token op, Ast *
|
||||
{
|
||||
ERROR_BLOCK();
|
||||
error(op, "Cannot take the pointer address of '%s'", str);
|
||||
if (e != nullptr && (e->flags & EntityFlag_ForValue) != 0) {
|
||||
if (e == nullptr) {
|
||||
break;
|
||||
}
|
||||
if ((e->flags & EntityFlag_ForValue) != 0) {
|
||||
Type *parent_type = type_deref(e->Variable.for_loop_parent_type);
|
||||
|
||||
if (parent_type != nullptr && is_type_string(parent_type)) {
|
||||
@@ -2503,9 +2480,17 @@ gb_internal void check_unary_expr(CheckerContext *c, Operand *o, Token op, Ast *
|
||||
} else {
|
||||
error_line("\tSuggestion: Did you want to pass the iterable value to the for statement by pointer to get addressable semantics?\n");
|
||||
}
|
||||
|
||||
if (is_type_map(parent_type)) {
|
||||
error_line("\t Prefer doing 'for key, &%.*s in ...'\n", LIT(e->token.string));
|
||||
} else {
|
||||
error_line("\t Prefer doing 'for &%.*s in ...'\n", LIT(e->token.string));
|
||||
}
|
||||
}
|
||||
if (e != nullptr && (e->flags & EntityFlag_SwitchValue) != 0) {
|
||||
if ((e->flags & EntityFlag_SwitchValue) != 0) {
|
||||
error_line("\tSuggestion: Did you want to pass the value to the switch statement by pointer to get addressable semantics?\n");
|
||||
|
||||
error_line("\t Prefer doing 'switch &%.*s in ...'\n", LIT(e->token.string));
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -2527,11 +2512,6 @@ gb_internal void check_unary_expr(CheckerContext *c, Operand *o, Token op, Ast *
|
||||
o->type = alloc_type_pointer(o->type);
|
||||
}
|
||||
} else {
|
||||
if (ast_node_expect(node, Ast_UnaryExpr)) {
|
||||
ast_node(ue, UnaryExpr, node);
|
||||
check_old_for_or_switch_value_usage(ue->expr);
|
||||
}
|
||||
|
||||
o->type = alloc_type_pointer(o->type);
|
||||
}
|
||||
|
||||
|
||||
+2
-28
@@ -501,7 +501,6 @@ gb_internal Type *check_assignment_variable(CheckerContext *ctx, Operand *lhs, O
|
||||
return nullptr;
|
||||
|
||||
case Addressing_Variable:
|
||||
check_old_for_or_switch_value_usage(lhs->expr);
|
||||
break;
|
||||
|
||||
case Addressing_MapIndex: {
|
||||
@@ -523,9 +522,8 @@ gb_internal Type *check_assignment_variable(CheckerContext *ctx, Operand *lhs, O
|
||||
break;
|
||||
}
|
||||
|
||||
case Addressing_Context: {
|
||||
case Addressing_Context:
|
||||
break;
|
||||
}
|
||||
|
||||
case Addressing_SoaVariable:
|
||||
break;
|
||||
@@ -1328,7 +1326,6 @@ gb_internal void check_type_switch_stmt(CheckerContext *ctx, Ast *node, u32 mod_
|
||||
}
|
||||
}
|
||||
|
||||
bool is_ptr = is_type_pointer(x.type);
|
||||
|
||||
// NOTE(bill): Check for multiple defaults
|
||||
Ast *first_default = nullptr;
|
||||
@@ -1447,15 +1444,6 @@ gb_internal void check_type_switch_stmt(CheckerContext *ctx, Ast *node, u32 mod_
|
||||
}
|
||||
|
||||
bool is_reference = is_addressed;
|
||||
bool old_style = false;
|
||||
|
||||
if (!is_reference &&
|
||||
is_ptr &&
|
||||
cc->list.count == 1 &&
|
||||
case_type != nullptr) {
|
||||
is_reference = true;
|
||||
old_style = true;
|
||||
}
|
||||
|
||||
if (cc->list.count > 1 || saw_nil) {
|
||||
case_type = nullptr;
|
||||
@@ -1477,9 +1465,6 @@ gb_internal void check_type_switch_stmt(CheckerContext *ctx, Ast *node, u32 mod_
|
||||
if (!is_reference) {
|
||||
tag_var->flags |= EntityFlag_Value;
|
||||
}
|
||||
if (old_style) {
|
||||
tag_var->flags |= EntityFlag_OldForOrSwitchValue;
|
||||
}
|
||||
add_entity(ctx, ctx->scope, lhs, tag_var);
|
||||
add_entity_use(ctx, lhs, tag_var);
|
||||
add_implicit_entity(ctx, stmt, tag_var);
|
||||
@@ -1618,7 +1603,6 @@ gb_internal void check_range_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags)
|
||||
auto entities = array_make<Entity *>(temporary_allocator(), 0, 2);
|
||||
bool is_map = false;
|
||||
bool is_bit_set = false;
|
||||
bool use_by_reference_for_value = false;
|
||||
bool is_soa = false;
|
||||
bool is_reverse = rs->reverse;
|
||||
|
||||
@@ -1679,7 +1663,6 @@ gb_internal void check_range_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags)
|
||||
}
|
||||
}
|
||||
}
|
||||
bool is_ptr = is_type_pointer(operand.type);
|
||||
Type *t = base_type(type_deref(operand.type));
|
||||
|
||||
switch (t->kind) {
|
||||
@@ -1719,32 +1702,27 @@ gb_internal void check_range_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags)
|
||||
break;
|
||||
|
||||
case Type_EnumeratedArray:
|
||||
if (is_ptr) use_by_reference_for_value = true;
|
||||
array_add(&vals, t->EnumeratedArray.elem);
|
||||
array_add(&vals, t->EnumeratedArray.index);
|
||||
break;
|
||||
|
||||
case Type_Array:
|
||||
if (is_ptr) use_by_reference_for_value = true;
|
||||
if (!is_ptr) is_possibly_addressable = operand.mode == Addressing_Variable;
|
||||
is_possibly_addressable = operand.mode == Addressing_Variable;
|
||||
array_add(&vals, t->Array.elem);
|
||||
array_add(&vals, t_int);
|
||||
break;
|
||||
|
||||
case Type_DynamicArray:
|
||||
if (is_ptr) use_by_reference_for_value = true;
|
||||
array_add(&vals, t->DynamicArray.elem);
|
||||
array_add(&vals, t_int);
|
||||
break;
|
||||
|
||||
case Type_Slice:
|
||||
if (is_ptr) use_by_reference_for_value = true;
|
||||
array_add(&vals, t->Slice.elem);
|
||||
array_add(&vals, t_int);
|
||||
break;
|
||||
|
||||
case Type_Map:
|
||||
if (is_ptr) use_by_reference_for_value = true;
|
||||
is_map = true;
|
||||
array_add(&vals, t->Map.key);
|
||||
array_add(&vals, t->Map.value);
|
||||
@@ -1817,7 +1795,6 @@ gb_internal void check_range_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags)
|
||||
case Type_Struct:
|
||||
if (t->Struct.soa_kind != StructSoa_None) {
|
||||
is_soa = true;
|
||||
if (is_ptr) use_by_reference_for_value = true;
|
||||
array_add(&vals, t->Struct.soa_elem);
|
||||
array_add(&vals, t_int);
|
||||
}
|
||||
@@ -1894,9 +1871,6 @@ gb_internal void check_range_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags)
|
||||
char const *idx_name = is_map ? "key" : is_bit_set ? "element" : "index";
|
||||
error(token, "The %s variable '%.*s' cannot be made addressable", idx_name, LIT(str));
|
||||
}
|
||||
} else if (i == addressable_index && use_by_reference_for_value) {
|
||||
entity->flags |= EntityFlag_OldForOrSwitchValue;
|
||||
entity->flags &= ~EntityFlag_Value;
|
||||
}
|
||||
if (is_soa) {
|
||||
if (i == 0) {
|
||||
|
||||
@@ -1013,6 +1013,7 @@ gb_internal void init_universal(void) {
|
||||
{"FreeBSD", TargetOs_freebsd},
|
||||
{"Haiku", TargetOs_haiku},
|
||||
{"OpenBSD", TargetOs_openbsd},
|
||||
{"NetBSD", TargetOs_netbsd},
|
||||
{"WASI", TargetOs_wasi},
|
||||
{"JS", TargetOs_js},
|
||||
{"Freestanding", TargetOs_freestanding},
|
||||
@@ -1043,6 +1044,7 @@ gb_internal void init_universal(void) {
|
||||
GlobalEnumValue values[BuildMode_COUNT] = {
|
||||
{"Executable", BuildMode_Executable},
|
||||
{"Dynamic", BuildMode_DynamicLibrary},
|
||||
{"Static", BuildMode_StaticLibrary},
|
||||
{"Object", BuildMode_Object},
|
||||
{"Assembly", BuildMode_Assembly},
|
||||
{"LLVM_IR", BuildMode_LLVM_IR},
|
||||
|
||||
@@ -85,8 +85,6 @@ enum EntityFlag : u64 {
|
||||
EntityFlag_Require = 1ull<<50,
|
||||
EntityFlag_ByPtr = 1ull<<51, // enforce parameter is passed by pointer
|
||||
|
||||
EntityFlag_OldForOrSwitchValue = 1ull<<52,
|
||||
|
||||
EntityFlag_Overridden = 1ull<<63,
|
||||
};
|
||||
|
||||
|
||||
+42
-1
@@ -83,6 +83,10 @@ extern "C" {
|
||||
#ifndef GB_SYSTEM_OPENBSD
|
||||
#define GB_SYSTEM_OPENBSD 1
|
||||
#endif
|
||||
#elif defined(__NetBSD__)
|
||||
#ifndef GB_SYSTEM_NETBSD
|
||||
#define GB_SYSTEM_NETBSD 1
|
||||
#endif
|
||||
#elif defined(__HAIKU__) || defined(__haiku__)
|
||||
#ifndef GB_SYSTEM_HAIKU
|
||||
#define GB_SYSTEM_HAIKU 1
|
||||
@@ -208,7 +212,7 @@ extern "C" {
|
||||
#endif
|
||||
#include <stdlib.h> // NOTE(bill): malloc on linux
|
||||
#include <sys/mman.h>
|
||||
#if !defined(GB_SYSTEM_OSX) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__HAIKU__)
|
||||
#if !defined(GB_SYSTEM_OSX) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__HAIKU__)
|
||||
#include <sys/sendfile.h>
|
||||
#endif
|
||||
#include <sys/stat.h>
|
||||
@@ -250,6 +254,11 @@ extern "C" {
|
||||
#define lseek64 lseek
|
||||
#endif
|
||||
|
||||
#if defined(GB_SYSTEM_NETBSD)
|
||||
#include <stdio.h>
|
||||
#define lseek64 lseek
|
||||
#endif
|
||||
|
||||
#if defined(GB_SYSTEM_HAIKU)
|
||||
#include <stdio.h>
|
||||
#include <pthread.h>
|
||||
@@ -817,6 +826,13 @@ typedef struct gbAffinity {
|
||||
isize thread_count;
|
||||
isize threads_per_core;
|
||||
} gbAffinity;
|
||||
#elif defined(GB_SYSTEM_NETBSD)
|
||||
typedef struct gbAffinity {
|
||||
b32 is_accurate;
|
||||
isize core_count;
|
||||
isize thread_count;
|
||||
isize threads_per_core;
|
||||
} gbAffinity;
|
||||
#elif defined(GB_SYSTEM_HAIKU)
|
||||
typedef struct gbAffinity {
|
||||
b32 is_accurate;
|
||||
@@ -3269,6 +3285,31 @@ isize gb_affinity_thread_count_for_core(gbAffinity *a, isize core) {
|
||||
GB_ASSERT(0 <= core && core < a->core_count);
|
||||
return a->threads_per_core;
|
||||
}
|
||||
|
||||
#elif defined(GB_SYSTEM_NETBSD)
|
||||
#include <unistd.h>
|
||||
|
||||
void gb_affinity_init(gbAffinity *a) {
|
||||
a->core_count = sysconf(_SC_NPROCESSORS_ONLN);
|
||||
a->threads_per_core = 1;
|
||||
a->is_accurate = a->core_count > 0;
|
||||
a->core_count = a->is_accurate ? a->core_count : 1;
|
||||
a->thread_count = a->core_count;
|
||||
}
|
||||
|
||||
void gb_affinity_destroy(gbAffinity *a) {
|
||||
gb_unused(a);
|
||||
}
|
||||
|
||||
b32 gb_affinity_set(gbAffinity *a, isize core, isize thread_index) {
|
||||
return true;
|
||||
}
|
||||
|
||||
isize gb_affinity_thread_count_for_core(gbAffinity *a, isize core) {
|
||||
GB_ASSERT(0 <= core && core < a->core_count);
|
||||
return a->threads_per_core;
|
||||
}
|
||||
|
||||
#elif defined(GB_SYSTEM_HAIKU)
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
+24
-7
@@ -212,10 +212,12 @@ gb_internal i32 linker_stage(LinkerData *gen) {
|
||||
link_settings = gb_string_append_fmt(link_settings, " /PDB:\"%.*s\"", LIT(pdb_path));
|
||||
}
|
||||
|
||||
if (build_context.no_crt) {
|
||||
link_settings = gb_string_append_fmt(link_settings, " /nodefaultlib");
|
||||
} else {
|
||||
link_settings = gb_string_append_fmt(link_settings, " /defaultlib:libcmt");
|
||||
if (build_context.build_mode != BuildMode_StaticLibrary) {
|
||||
if (build_context.no_crt) {
|
||||
link_settings = gb_string_append_fmt(link_settings, " /nodefaultlib");
|
||||
} else {
|
||||
link_settings = gb_string_append_fmt(link_settings, " /defaultlib:libcmt");
|
||||
}
|
||||
}
|
||||
|
||||
if (build_context.ODIN_DEBUG) {
|
||||
@@ -257,20 +259,31 @@ gb_internal i32 linker_stage(LinkerData *gen) {
|
||||
}
|
||||
}
|
||||
|
||||
String linker_name = str_lit("link.exe");
|
||||
switch (build_context.build_mode) {
|
||||
case BuildMode_Executable:
|
||||
link_settings = gb_string_append_fmt(link_settings, " /NOIMPLIB /NOEXP");
|
||||
break;
|
||||
}
|
||||
|
||||
switch (build_context.build_mode) {
|
||||
case BuildMode_StaticLibrary:
|
||||
linker_name = str_lit("lib.exe");
|
||||
break;
|
||||
default:
|
||||
link_settings = gb_string_append_fmt(link_settings, " /incremental:no /opt:ref");
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
result = system_exec_command_line_app("msvc-link",
|
||||
"\"%.*slink.exe\" %s %.*s -OUT:\"%.*s\" %s "
|
||||
"/nologo /incremental:no /opt:ref /subsystem:%.*s "
|
||||
"\"%.*s%.*s\" %s %.*s -OUT:\"%.*s\" %s "
|
||||
"/nologo /subsystem:%.*s "
|
||||
"%.*s "
|
||||
"%.*s "
|
||||
"%s "
|
||||
"",
|
||||
LIT(vs_exe_path), object_files, LIT(res_path), LIT(output_filename),
|
||||
LIT(vs_exe_path), LIT(linker_name), object_files, LIT(res_path), LIT(output_filename),
|
||||
link_settings,
|
||||
LIT(build_context.ODIN_WINDOWS_SUBSYSTEM),
|
||||
LIT(build_context.link_flags),
|
||||
@@ -458,6 +471,10 @@ gb_internal i32 linker_stage(LinkerData *gen) {
|
||||
link_settings = gb_string_append_fmt(link_settings, "-nostdlib ");
|
||||
}
|
||||
|
||||
if (build_context.build_mode == BuildMode_StaticLibrary) {
|
||||
compiler_error("TODO(bill): -build-mode:static on non-windows targets");
|
||||
}
|
||||
|
||||
// NOTE(dweiler): We use clang as a frontend for the linker as there are
|
||||
// other runtime and compiler support libraries that need to be linked in
|
||||
// very specific orders such as libgcc_s, ld-linux-so, unwind, etc.
|
||||
|
||||
@@ -989,6 +989,8 @@ gb_internal bool parse_build_flags(Array<String> args) {
|
||||
build_context.build_mode = BuildMode_DynamicLibrary;
|
||||
} else if (str == "obj" || str == "object") {
|
||||
build_context.build_mode = BuildMode_Object;
|
||||
} else if (str == "static" || str == "lib") {
|
||||
build_context.build_mode = BuildMode_StaticLibrary;
|
||||
} else if (str == "exe") {
|
||||
build_context.build_mode = BuildMode_Executable;
|
||||
} else if (str == "asm" || str == "assembly" || str == "assembler") {
|
||||
@@ -999,6 +1001,7 @@ gb_internal bool parse_build_flags(Array<String> args) {
|
||||
gb_printf_err("Unknown build mode '%.*s'\n", LIT(str));
|
||||
gb_printf_err("Valid build modes:\n");
|
||||
gb_printf_err("\tdll, shared, dynamic\n");
|
||||
gb_printf_err("\tlib, static\n");
|
||||
gb_printf_err("\tobj, object\n");
|
||||
gb_printf_err("\texe\n");
|
||||
gb_printf_err("\tasm, assembly, assembler\n");
|
||||
@@ -1637,6 +1640,7 @@ gb_internal void remove_temp_files(lbGenerator *gen) {
|
||||
|
||||
switch (build_context.build_mode) {
|
||||
case BuildMode_Executable:
|
||||
case BuildMode_StaticLibrary:
|
||||
case BuildMode_DynamicLibrary:
|
||||
break;
|
||||
|
||||
@@ -1655,6 +1659,7 @@ gb_internal void remove_temp_files(lbGenerator *gen) {
|
||||
if (!build_context.keep_object_files) {
|
||||
switch (build_context.build_mode) {
|
||||
case BuildMode_Executable:
|
||||
case BuildMode_StaticLibrary:
|
||||
case BuildMode_DynamicLibrary:
|
||||
for (String const &path : gen->output_object_paths) {
|
||||
gb_file_remove(cast(char const *)path.text);
|
||||
@@ -1833,6 +1838,9 @@ gb_internal void print_show_help(String const arg0, String const &command) {
|
||||
print_usage_line(3, "-build-mode:exe Builds as an executable.");
|
||||
print_usage_line(3, "-build-mode:dll Builds as a dynamically linked library.");
|
||||
print_usage_line(3, "-build-mode:shared Builds as a dynamically linked library.");
|
||||
print_usage_line(3, "-build-mode:lib Builds as a statically linked library.");
|
||||
print_usage_line(3, "-build-mode:static Builds as a statically linked library.");
|
||||
print_usage_line(3, "-build-mode:lib Builds as an static library.");
|
||||
print_usage_line(3, "-build-mode:obj Builds as an object file.");
|
||||
print_usage_line(3, "-build-mode:object Builds as an object file.");
|
||||
print_usage_line(3, "-build-mode:assembly Builds as an assembly file.");
|
||||
@@ -2866,6 +2874,7 @@ int main(int arg_count, char const **arg_ptr) {
|
||||
|
||||
switch (build_context.build_mode) {
|
||||
case BuildMode_Executable:
|
||||
case BuildMode_StaticLibrary:
|
||||
case BuildMode_DynamicLibrary:
|
||||
i32 result = linker_stage(&linker_data);
|
||||
if (result) {
|
||||
@@ -2887,6 +2896,7 @@ int main(int arg_count, char const **arg_ptr) {
|
||||
if (lb_generate_code(gen)) {
|
||||
switch (build_context.build_mode) {
|
||||
case BuildMode_Executable:
|
||||
case BuildMode_StaticLibrary:
|
||||
case BuildMode_DynamicLibrary:
|
||||
i32 result = linker_stage(gen);
|
||||
if (result) {
|
||||
|
||||
+1
-1
@@ -341,7 +341,7 @@ gb_internal ReadDirectoryError read_directory(String path, Array<FileInfo> *fi)
|
||||
|
||||
return ReadDirectory_None;
|
||||
}
|
||||
#elif defined(GB_SYSTEM_LINUX) || defined(GB_SYSTEM_OSX) || defined(GB_SYSTEM_FREEBSD) || defined(GB_SYSTEM_OPENBSD) || defined(GB_SYSTEM_HAIKU)
|
||||
#elif defined(GB_SYSTEM_LINUX) || defined(GB_SYSTEM_OSX) || defined(GB_SYSTEM_FREEBSD) || defined(GB_SYSTEM_OPENBSD) || defined(GB_SYSTEM_NETBSD) || defined(GB_SYSTEM_HAIKU)
|
||||
|
||||
#include <dirent.h>
|
||||
|
||||
|
||||
+10
-2
@@ -628,15 +628,23 @@ gb_internal void thread_set_name(Thread *t, char const *name) {
|
||||
pthread_setname_np(name);
|
||||
#elif defined(GB_SYSTEM_FREEBSD) || defined(GB_SYSTEM_OPENBSD)
|
||||
pthread_set_name_np(t->posix_handle, name);
|
||||
#elif defined(GB_SYSTEM_NETBSD)
|
||||
pthread_setname_np(t->posix_handle, "%s", (void*)name);
|
||||
#else
|
||||
// TODO(bill): Test if this works
|
||||
pthread_setname_np(t->posix_handle, name);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(GB_SYSTEM_LINUX)
|
||||
#include <linux/futex.h>
|
||||
#if defined(GB_SYSTEM_LINUX) || defined(GB_SYSTEM_NETBSD)
|
||||
|
||||
#include <sys/syscall.h>
|
||||
#ifdef GB_SYSTEM_LINUX
|
||||
#include <linux/futex.h>
|
||||
#else
|
||||
#include <sys/futex.h>
|
||||
#define SYS_futex SYS___futex
|
||||
#endif
|
||||
|
||||
gb_internal void futex_signal(Futex *addr) {
|
||||
int ret = syscall(SYS_futex, addr, FUTEX_WAKE | FUTEX_PRIVATE_FLAG, 1, NULL, NULL, 0);
|
||||
|
||||
Reference in New Issue
Block a user