Hi, Marco Fortina <marco_fort...@hotmail.it> skribis:
> I have this issue when with guix time-machine shell when using --emulate-fhs > option and having gcc-toolset and clang-toolset in my manifest.scm. I tried, and for those reading along, the problem is: --8<---------------cut here---------------start------------->8--- $ guix shell -CF gcc-toolchain clang-toolchain guix shell: error: symlink: File exists: "/bin/cc" --8<---------------cut here---------------end--------------->8--- > --- a/gnu/packages/llvm.scm > +++ b/gnu/packages/llvm.scm > @@ -512,8 +512,10 @@ (define-public (make-clang-toolchain clang libomp) > ;; Create 'cc' and 'c++' so that one can use it as a > ;; drop-in replacement for the default tool chain and > ;; have configure scripts find the compiler. > - (symlink "clang" (string-append out "/bin/cc")) > - (symlink "clang++" (string-append out "/bin/c++")) > + (unless (file-exists? "/bin/cc") > + (symlink "clang" (string-append out "/bin/cc"))) > + (unless (file-exists? "/bin/c++") > + (symlink "clang++" (string-append out "/bin/c++"))) This part has no effect (there’s no /bin/cc in the build environment.) > +++ b/guix/scripts/environment.scm > @@ -465,7 +465,8 @@ (define* (link-contents dir #:key (exclude '())) > ;; bin directories will link to /bin. > (let ((gcc-path (string-append profile "/bin/gcc"))) > (if (file-exists? gcc-path) > - (symlink gcc-path "/bin/cc"))) > + (unless (file-exists? "/bin/cc") > + (symlink gcc-path "/bin/cc")))) Good catch! I’m proposing a slightly modified variant of this change:
diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm index a219b2ac89..fc7fa84be7 100644 --- a/guix/scripts/environment.scm +++ b/guix/scripts/environment.scm @@ -464,8 +464,15 @@ (define (setup-fhs profile) ;; /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.
I’ll push it soon if there are no objections. Thanks for reporting the problem! Ludo’.