Page MenuHomeFreeBSD

clang: install clang-scan-deps
AcceptedPublic

Authored by ivy on Wed, Jun 25, 7:38 PM.

Details

Reviewers
des
kevans
dim
Summary

clang-scan-deps is used to generate dependency information from C++20
modules according to proposed standard ISO/IEC WG21 P1689R5[0]. It is
required by common build tools (e.g., CMake) to build C++ sources
that use modules.

Since this is a core build tool, install it by default, not gated
behind MK_CLANG_EXTRAS.

[0] https://www.open-std.org/JTC1/SC22/WG21/docs/papers/2022/p1689r5.html

MFC after: 3 days

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 65113
Build 61996: arc lint + arc unit

Event Timeline

ivy requested review of this revision.Wed, Jun 25, 7:38 PM
lib/clang/libclang/Makefile
848

Are you sure these aren't FUL rather than MIN?

lib/clang/libclang/Makefile
848

to be honest, i don't know what the difference is. the comment says FUL is "required for MK_CLANG_FULL", which i assume refers to this from src.conf(5):

WITHOUT_CLANG_FULL
        Avoid building the ARCMigrate, Rewriter and StaticAnalyzer
        components of the Clang C/C++ compiler.

so i don't think SRCS_FUL is right.

perhaps we need a new variable like ${SRCS_SD} for clang-scan-deps, or should it be gated behind WITHOUT_CLANG_FULL?

lib/clang/libclang/Makefile
848

The part that's throwing me off is the "including bootstrap" part of the description here

lib/clang/libclang/Makefile
848

This was all meant as an optimization to avoid compiling files that were not needed for certain stages, and for certain src.opts.mk knobs. It used to be relatively simple, but got more complicated over time. :)

In libllvm's Makefile there is also a SRCS_MIW (min + world) variable which has files required for world, after the bootstrap/cross-tools stage. There isn't an equivalent variable for libclang, and I don't think it's worth the effort to add one, really.

For this file, I ended up at the same diff, so these additions are OK.

usr.bin/clang/Makefile
4

I tend to avoid adding multiple items on one line, so each SUBDIR+= should only have one item. But more importantly, this block is used also during the cross-tools phase, and you don't want to build clang-scan-deps during that phase.

I had put it under the TOOLS_PREFIX block below, like so:

--- a/usr.bin/clang/Makefile
+++ b/usr.bin/clang/Makefile
@@ -5,6 +5,10 @@ SUBDIR+=       clang
 .endif

 .if !defined(TOOLS_PREFIX)
+.if ${MK_CLANG} != "no"
+SUBDIR+=       clang-scan-deps
+.endif
+
 # LLVM binutils are needed to support features such as LTO, so we build them
 # by default if clang is enabled. If MK_LLVM_BINUTILS is set, we also use them
 # as the default binutils (ar,nm,addr2line, etc.).
usr.bin/clang/clang-scan-deps/Makefile
3

These two lines should not be added here, but llvm-pre.mk should be added below.

11

This can be deleted, as it is handled by the inclusion of clang.prog.mk below.

14

Replace these two by:

.include "${SRCTOP}/lib/clang/clang.pre.mk"
17

In the other Makefiles, this is done a little differently:

INCFILE=       Opts.inc
TDFILE=                ${LLVM_BASE}/${SRCDIR}/Opts.td
19

In the other Makefiles, there are explicit instead of implicit rules, IIRC because .inc is also used for Makefile.inc and this lead to subtle problems. E.g. I had:

${INCFILE}: ${TDFILE}
       ${LLVM_TBLGEN} ${GENOPT} -I ${LLVM_SRCS}/include -d ${.TARGET:C/$/.d/} \
           -o ${.TARGET} ${TDFILE}
TGHDRS+=       ${INCFILE}
23

Similar here, I had:

DEPENDFILES+=  ${TGHDRS:C/$/.d/}
DPSRCS+=       ${TGHDRS}
CLEANFILES+=   ${TGHDRS} ${TGHDRS:C/$/.d/}

address review comments

i've changed the Opts.td handling to be more like the other examples, but as a
followup commit i might see whether we can move this to llvm.prog.mk to avoid
so much code duplication.

Ok, let's go for this.

lib/clang/libclang/Makefile
848

Oh btw, could you please sort these alphabetically?

This revision is now accepted and ready to land.Fri, Jun 27, 4:33 PM
lib/clang/libclang/Makefile
848

done in my local branch