Clang using GCC as linker?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
nexos
Member
Member
Posts: 1081
Joined: Tue Feb 18, 2020 3:29 pm
Libera.chat IRC: nexos

Clang using GCC as linker?

Post by nexos »

Hello,
I was doing some work on my OS and noticed how clang calls my host's GCC to perform linking, seemingly discarding -fuse-ld=lld. How come this is?

I would like for my OSes build environment to be completely isolated from the host's tools so that it doesn't rely on anything in the host. Also, I don't want to have whole layer extra where issues could prop up. How can I make clang use LLD directly for linking and not GCC?

Thanks,
nexos
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg
User avatar
eekee
Member
Member
Posts: 891
Joined: Mon May 22, 2017 5:56 am
Location: Kerbin
Discord: eekee
Contact:

Re: Clang using GCC as linker?

Post by eekee »

lld might be a stub which calls gcc. You could query your package manager to see if there's another package which provides lld.

`file $(which lld)` may show obvious signs of it being a stub, but don't rely on it.
Kaph — a modular OS intended to be easy and fun to administer and code for.
"May wisdom, fun, and the greater good shine forth in all your work." — Leo Brodie
nexos
Member
Member
Posts: 1081
Joined: Tue Feb 18, 2020 3:29 pm
Libera.chat IRC: nexos

Re: Clang using GCC as linker?

Post by nexos »

No, because running with -V shows gcc calling /usr/bin/ld.lld (since clang forwarded -fuse-ld=lld to gcc). It works fine currently, it's just that I'd like clang to call my custom built lld.
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg
nexos
Member
Member
Posts: 1081
Joined: Tue Feb 18, 2020 3:29 pm
Libera.chat IRC: nexos

Re: Clang using GCC as linker?

Post by nexos »

I did the simplest thing: simple add the path of my LLD before /usr/bin. How simple :oops:
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg
Post Reply