From 23ab6fc29f28b0fa9ad94bf2ceed135ee3fdea34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Wed, 23 Oct 2024 22:26:34 +0200 Subject: [PATCH] environment: Gracefully handle preexistence of /bin/cc in FHS. * guix/scripts/environment.scm (setup-fhs): When /bin/cc already exists, keep it. Reported-by: Marco Fortina Change-Id: I73d39d2aa6fbafd236061a0e3b8d1fe327b2bb19 --- guix/scripts/environment.scm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm index a219b2ac89e..fc7fa84be7b 100644 --- a/guix/scripts/environment.scm +++ b/guix/scripts/environment.scm @@ -464,8 +464,15 @@ providing a symlink for CC if GCC is in the container PROFILE, and writing ;; /bin since that already has the sh symlink and the other (optional) FHS ;; bin directories will link to /bin. (let ((gcc-path (string-append profile "/bin/gcc"))) - (if (file-exists? gcc-path) - (symlink gcc-path "/bin/cc"))) + (when (file-exists? gcc-path) + (catch 'system-error + (lambda () + (symlink gcc-path "/bin/cc")) + (lambda args + ;; If /bin/cc already exists because it was provided by another + ;; package in PROFILE, such as 'clang-toolchain', leave it. + (unless (= EEXIST (system-error-errno args)) + (apply throw args)))))) ;; Guix's ldconfig doesn't search in FHS default locations, so provide a ;; minimal ld.so.conf.