New Essence OS layer; cross-compiling improvements

This commit is contained in:
nakst
2019-09-02 16:46:50 +01:00
parent 6d614ef07c
commit 22e982c8fb
6 changed files with 1414 additions and 244 deletions

View File

@@ -56,8 +56,6 @@ TargetEndianKind target_endians[TargetArch_COUNT] = {
String const ODIN_VERSION = str_lit("0.10.1");
String cross_compile_target = str_lit("");
String cross_compile_lib_dir = str_lit("");
@@ -66,6 +64,7 @@ struct TargetMetrics {
TargetArchKind arch;
isize word_size;
isize max_align;
String target_triplet;
};
@@ -109,6 +108,7 @@ struct BuildContext {
bool has_resource;
String opt_flags;
String llc_flags;
String target_triplet;
String link_flags;
bool is_dll;
bool generate_docs;
@@ -121,6 +121,7 @@ struct BuildContext {
bool no_crt;
bool use_lld;
bool vet;
bool cross_compiling;
QueryDataSetSettings query_data_set_settings;
@@ -135,18 +136,19 @@ struct BuildContext {
gb_global BuildContext build_context = {0};
gb_global TargetMetrics target_windows_386 = {
TargetOs_windows,
TargetArch_386,
4,
8,
str_lit("i686-pc-windows"),
};
gb_global TargetMetrics target_windows_amd64 = {
TargetOs_windows,
TargetArch_amd64,
8,
16,
str_lit("x86_64-pc-windows-gnu"),
};
gb_global TargetMetrics target_linux_386 = {
@@ -154,12 +156,14 @@ gb_global TargetMetrics target_linux_386 = {
TargetArch_386,
4,
8,
str_lit("i686-pc-linux-gnu"),
};
gb_global TargetMetrics target_linux_amd64 = {
TargetOs_linux,
TargetArch_amd64,
8,
16,
str_lit("x86_64-pc-linux-gnu"),
};
gb_global TargetMetrics target_osx_amd64 = {
@@ -167,10 +171,32 @@ gb_global TargetMetrics target_osx_amd64 = {
TargetArch_amd64,
8,
16,
str_lit("x86_64-apple-darwin"),
};
gb_global TargetMetrics target_essence_amd64 = {
TargetOs_essence,
TargetArch_amd64,
8,
16,
str_lit("x86_64-pc-none-elf"),
};
struct NamedTargetMetrics {
String name;
TargetMetrics *metrics;
};
gb_global NamedTargetMetrics named_targets[] = {
{ str_lit("essence_amd64"), &target_essence_amd64 },
{ str_lit("macos_amd64"), &target_osx_amd64 },
{ 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 },
};
NamedTargetMetrics *selected_target_metrics;
TargetOsKind get_target_os_from_string(String str) {
for (isize i = 0; i < TargetOs_COUNT; i++) {
@@ -522,7 +548,7 @@ String get_fullpath_core(gbAllocator a, String path) {
void init_build_context(void) {
void init_build_context(TargetMetrics *cross_target) {
BuildContext *bc = &build_context;
gb_affinity_init(&bc->affinity);
@@ -554,8 +580,9 @@ void init_build_context(void) {
#endif
#endif
if (cross_compile_target.len) {
bc->ODIN_OS = cross_compile_target;
if (cross_target) {
metrics = *cross_target;
bc->cross_compiling = true;
}
GB_ASSERT(metrics.os != TargetOs_Invalid);
@@ -573,6 +600,7 @@ void init_build_context(void) {
bc->max_align = metrics.max_align;
bc->link_flags = str_lit(" ");
bc->opt_flags = str_lit(" ");
bc->target_triplet = metrics.target_triplet;
gbString llc_flags = gb_string_make_reserve(heap_allocator(), 64);