Clang using LLVM's tools

Hi, Gentoo user here. I’m trying to do some work on the wiki. I apologize in advance if this does not belong here.

I’ve noticed that LLVM ships a bunch of utilities like llvm-ar, llvm-nm, llvm-ranlib, llvm-cov, llvm-objdump and so on. These seem like alternatives to programs provided by gcc, binutils, and coreutils.

When using Clang, does Clang automatically use these? During the config phase of building packages, Gentoo will see binutils ar and nm, for example, and use those as the configure phase checks to see which are in use.

Of course, we can set a global override in make.conf to use LLVM versions, and during the configuration phase, it will call on LLVM provided tools instead once they’re defined. What is the best way to go about this?

AS is a variable we can define in make.conf, and I noticed there is a LLVM provided assembler, llvm-as. Clang also has an integrated assembler? You can define that with the -integrated-as flag? What does that do, exactly? Does it get called by default, or does Clang use the system assembler by default? Any pros/cons to use system over llvm-as, or integrated-as? Is there anything else built into Clang like this?

If anyone can clarify this, I’d be really grateful. Thank you for your time.

Hi,

I've noticed that LLVM ships a bunch of utilities like llvm-ar, llvm-nm,
llvm-ranlib, llvm-cov, llvm-objdump and so on. These seem like alternatives
to programs provided by gcc, binutils, and coreutils.

Pretty much, yep.

When using Clang, does Clang automatically use these? During the config
phase of building packages, Gentoo will see binutils ar and nm, for example,
and use those as the configure phase checks to see which are in use.

At build-time the host's utilities are used. At runtime, Clang only
really uses "as" and "ld" as external utilities, it'll try to pick up
the system version of both of these.

AS is a variable we can define in make.conf, and I noticed there is a LLVM
provided assembler, llvm-as.

This isn't a conventional assembler. It's a program to convert textual
LLVM IR (a .ll file) into its binary format (a .bc file).

Clang also has an integrated assembler? You can define that with the -integrated-as flag? What does that do, exactly?

Yes, Clang can output .o files directly for many targets. The
-integrated-as flag is how you control whether Clang does that or
outputs a .s file and then calls the system assembler.

We enable -integrated-as by default when we're confident that the
assembler is high enough quality for the given target, so in most
cases users wouldn't override that.

Does it get called by default, or does Clang use the system assembler by default?

Depends on the CPU/OS combination. If you run your compile step with
"-v" you'll see a separate run line for the assembler if
-no-integrated-as is active.

Tim.