From bf74ef0e5e4dbadc9977d447fbbc07e576a3b8e8 Mon Sep 17 00:00:00 2001 From: "Guillaume M." <58004135+GuillaumeMZ@users.noreply.github.com> Date: Tue, 24 Dec 2024 04:03:53 +0900 Subject: [PATCH] Fix crt detection for Arch Linux (#1705) * Fix crt detection for arch linux On archlinux, the crt is located directly in /usr/lib. Thus, the globbing done in find_linux_crt fails since it expects the crt to be in a subdirectory of /usr/lib. This patch fixes this issue. --- releasenotes.md | 1 + src/compiler/linker.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/releasenotes.md b/releasenotes.md index 3e21d112a..a867b1ac1 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -16,6 +16,7 @@ - `static-lib` and `dynamic-lib` options from the command line now produces headers. - Fix bug outputting exported functions without predefined extname. - Fix problem where crt1 was linked for dynamic libraries on Linux and BSD. #1710 +- Fix CRT detection on Arch Linux. ### Stdlib changes - Increase BitWriter.write_bits limit up to 32 bits. diff --git a/src/compiler/linker.c b/src/compiler/linker.c index fb0a0fc5a..872f2afcd 100644 --- a/src/compiler/linker.c +++ b/src/compiler/linker.c @@ -308,6 +308,13 @@ static const char *find_arch_glob_path(const char *glob_path, int file_len) static const char *find_linux_crt(void) { if (compiler.build.linuxpaths.crt) return compiler.build.linuxpaths.crt; + const char *arch_linux_crt1_path = "/usr/lib/crt1.o"; + if (file_exists(arch_linux_crt1_path)) + { + const char *arch_linux_path = "/usr/lib"; + 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); if (!path) {