mirror of
https://github.com/odin-lang/Odin.git
synced 2026-02-15 15:44:04 +00:00
add support for linux_riscv64 and freestanding_riscv64
This commit is contained in:
@@ -388,6 +388,12 @@ gb_internal i32 linker_stage(LinkerData *gen) {
|
||||
} else {
|
||||
timings_start_section(timings, str_lit("ld-link"));
|
||||
|
||||
// Link using `clang`, unless overridden by `ODIN_CLANG_PATH` environment variable.
|
||||
const char* clang_path = gb_get_env("ODIN_CLANG_PATH", permanent_allocator());
|
||||
if (clang_path == NULL) {
|
||||
clang_path = "clang";
|
||||
}
|
||||
|
||||
// NOTE(vassvik): get cwd, for used for local shared libs linking, since those have to be relative to the exe
|
||||
char cwd[256];
|
||||
#if !defined(GB_SYSTEM_WINDOWS)
|
||||
@@ -458,7 +464,20 @@ gb_internal i32 linker_stage(LinkerData *gen) {
|
||||
}
|
||||
#endif // GB_ARCH_*_BIT
|
||||
|
||||
if (is_osx) {
|
||||
if (build_context.metrics.arch == TargetArch_riscv64) {
|
||||
result = system_exec_command_line_app("clang",
|
||||
"%s \"%.*s\" "
|
||||
"-c -o \"%.*s\" "
|
||||
"-target %.*s -march=rv64gc "
|
||||
"%.*s "
|
||||
"",
|
||||
clang_path,
|
||||
LIT(asm_file),
|
||||
LIT(obj_file),
|
||||
LIT(build_context.metrics.target_triplet),
|
||||
LIT(build_context.extra_assembler_flags)
|
||||
);
|
||||
} else if (is_osx) {
|
||||
// `as` comes with MacOS.
|
||||
result = system_exec_command_line_app("as",
|
||||
"as \"%.*s\" "
|
||||
@@ -592,7 +611,7 @@ gb_internal i32 linker_stage(LinkerData *gen) {
|
||||
link_settings = gb_string_appendc(link_settings, "-Wl,-fini,'_odin_exit_point' ");
|
||||
}
|
||||
|
||||
} else if (build_context.metrics.os != TargetOs_openbsd && build_context.metrics.os != TargetOs_haiku) {
|
||||
} else if (build_context.metrics.os != TargetOs_openbsd && build_context.metrics.os != TargetOs_haiku && build_context.metrics.arch != TargetArch_riscv64) {
|
||||
// OpenBSD and Haiku default to PIE executable. do not pass -no-pie for it.
|
||||
link_settings = gb_string_appendc(link_settings, "-no-pie ");
|
||||
}
|
||||
@@ -635,12 +654,6 @@ gb_internal i32 linker_stage(LinkerData *gen) {
|
||||
}
|
||||
}
|
||||
|
||||
// Link using `clang`, unless overridden by `ODIN_CLANG_PATH` environment variable.
|
||||
const char* clang_path = gb_get_env("ODIN_CLANG_PATH", permanent_allocator());
|
||||
if (clang_path == NULL) {
|
||||
clang_path = "clang";
|
||||
}
|
||||
|
||||
gbString link_command_line = gb_string_make(heap_allocator(), clang_path);
|
||||
defer (gb_string_free(link_command_line));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user