Page MenuHomeFreeBSD

llvm-*: Move LLVM_BINUTILS toosl to toolchain package
Needs ReviewPublic

Authored by emaste on Mar 6 2026, 3:23 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Apr 5, 1:15 PM
Unknown Object (File)
Wed, Mar 25, 5:36 AM
Unknown Object (File)
Tue, Mar 24, 11:34 PM
Unknown Object (File)
Tue, Mar 24, 9:58 PM
Unknown Object (File)
Tue, Mar 24, 3:18 PM
Unknown Object (File)
Sun, Mar 22, 8:27 AM
Unknown Object (File)
Sun, Mar 22, 5:58 AM
Unknown Object (File)
Sun, Mar 22, 4:50 AM
Subscribers

Details

Reviewers
ivy
brooks
Group Reviewers
build
pkgbase
Summary
Some of the LLVM binary utilities were included in the Clang package
(because they did not set an explicit PACKAGE).  Add where missing,
and move the setting under MK_LLVM_BINUTILS.

With LLVM_BINUTILS (default) these tools are included in the toolchain
package, including a link without the llvm- prefix.  When LLVM_BINUTILS
is disabled only the llvm-prefixed versions are included, in the clang
package.

PR:             293610

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

emaste requested review of this revision.Mar 6 2026, 3:23 PM
emaste created this revision.

With LLVM_BINUTILS (default) these tools are included in the toolchain
package, including a link without the llvm- prefix. When LLVM_BINUTILS
is disabled only the llvm-prefixed versions are included, in the clang
package.

i'm not sure if i like this; it seems odd that the same binary can move between packages like that. is the rationale here to avoid bringing in LLVM libraries as a dependency of toolchain when LLVM_BINUTILS is disabled?

one way i think this could cause problems is once we add pkgbase depends support to ports. say there's a port that specifically requires "llvm-objcopy", which package should it depend on to get that?

i'm not sure if i like this; it seems odd that the same binary can move between packages like that. is the rationale here to avoid bringing in LLVM libraries as a dependency of toolchain when LLVM_BINUTILS is disabled?

Yeah, I can see arguments either way.

My thinking is the toolchain package ought to offer the standard binutils-like tools (needed if you were using a different compiler, say). With the current approach it seems odd to me that setting LLVM_BINUTILS=no results in a toolchain package that includes ELF Tool Chain's objcopy and also llvm-objcopy and has a dependency on llvm libraries.

one way i think this could cause problems is once we add pkgbase depends support to ports. say there's a port that specifically requires "llvm-objcopy", which package should it depend on to get that?

Arguably the correct way to handle this would be for llvm-objcopy to be in a Clang (or LLVM) package, and objcopy to be in the toolchain package. It's currently a hard link though and would have to become a symlink instead.

Right now c++filt, objcopy, readelf, addr2line are either in the clang or toolchain package, depending on LLVM_BINUTILS.

Arguably the correct way to handle this would be for llvm-objcopy to be in a Clang (or LLVM) package, and objcopy to be in the toolchain package. It's currently a hard link though and would have to become a symlink instead.

i think this would be my preferred solution (although i'm open to other arguments): it puts everything in its rightful place, and the symlink + dependency in the LLVM_BINUTILS case makes it semantically clear that e.g. objcopy is llvm-objcopy. i know we've historically preferred hard links here, but they don't play nicely with pkg in general, and i'm not sure the reasoning for that is still relevant (e.g., saving inodes, which hardly matters in 2026).

this would require a conditional dependency from toolchain to clang, which we don't currently support. i don't mind adding support for that though, i think it's useful in general.

what do you think?

what do you think?

Originally I thought it would be excessive, but upon a little more thought I think it makes sense. I opened D55693 to switch to symlinks.

We'll have to sort out the conditional dependency, and we'll also need to split these Makefiles. I can look at the second part.

As discussed w/ @ivy, I think the better path is to:

  1. Move the unprefixed links to SYMLINKS
  2. Move the unprefixed symlinks into their own Makefile with PACKAGE=toolchain (prefixed tools will move back to the clang package).
  3. Add a conditional dependency to the toolchain package on clang

Make a new usr.bin/clang/toolchain/Makefile to put the LLVM binutils symlinks in the toolchain package when LLVM_BINUTILS is set.

i decided that, rather than waste time adding more features to the current package build, i'd do the subdir-based rewrite that i've been planning for a while. that means you will be able to do something like this in packages/toolchain/Makefile:

.include <src.opts.mk>

.if ${MK_LLVM_BINUTILS} != "no"
PKG_DEPS.toolchain+= llvm
.endif

this should be ready for review in a couple of days.

In D55692#1277265, @ivy wrote:

this should be ready for review in a couple of days.

D56087