From 47447dc069a8b663db53fa1c356d30c7395c7e57 Mon Sep 17 00:00:00 2001 From: Avaxar <44055981+avaxar@users.noreply.github.com> Date: Wed, 2 Apr 2025 15:26:48 +0700 Subject: [PATCH] Glob `crt1.o` on Linux depending on architecture --- src/compiler/linker.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/compiler/linker.c b/src/compiler/linker.c index 2fc9cc536..bba19f25c 100644 --- a/src/compiler/linker.c +++ b/src/compiler/linker.c @@ -328,6 +328,23 @@ static const char *find_arch_glob_path(const char *glob_path, int file_len) return NULL; } +static const char *get_linux_crt_arch_glob(void) +{ + switch (compiler.build.arch_os_target) + { + case LINUX_X64: + return "/usr/lib/x86_64*linux*/crt1.o"; + case LINUX_X86: + return "/usr/lib/i686*linux*/crt1.o"; + case LINUX_AARCH64: + return "/usr/lib/aarch64*linux*/crt1.o"; + case LINUX_RISCV32: + case LINUX_RISCV64: + default: + return "/usr/lib/*/crt1.o"; + } +} + static const char *get_linux_crt_begin_arch_glob(void) { switch (compiler.build.arch_os_target) @@ -355,7 +372,8 @@ static const char *find_linux_crt(void) INFO_LOG("Found crt at %s", arch_linux_path); return arch_linux_path; } - const char *path = find_arch_glob_path("/usr/lib/*/crt1.o", 6); + const char *arch_glob_path = get_linux_crt_arch_glob(); + const char *path = find_arch_glob_path(arch_glob_path, 6); if (!path) { INFO_LOG("No crt in /usr/lib/*/");