Page MenuHomeFreeBSD

Look for drti.o in WORLDTMP when building dtrace probes.
AbandonedPublic

Authored by bdrewery on Thu, Nov 19, 6:47 PM.

Details

Summary

There are currently no probes built in buildworld but if someone
were to try they would run into this problem.

Sponsored by: Dell EMC

Test Plan

make tinderbox -DMAKE_ONLY_WORLDS passes.

More details in case someone else explores providers for the build:
Using a custom libthr dtrace provider which requires bootstrapping a newer
dtrace and libs early on to get revisions like rS364438 and rS356477 into
the build's dtrace.
I'm not sure on the upstreamability for this yet but most likely it can be.

This patch was used downstream for the bootstrap needs. It predates D27200
which should have it using LOCAL_BSTOOL_DIRS and LOCAL_XTOOL_DIRS
instead.

diff --git Makefile.inc1 Makefile.inc1
index 900817a3fcd2..dc0b052d4623 100644
--- Makefile.inc1
+++ Makefile.inc1
@@ -2117,12 +2117,17 @@ _kerberos5_bootstrap_tools= \

 ${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd

+_isi_dtrace_bs+= lib/librtld_db lib/libproc cddl/lib/libdtrace
+${_bt}-lib/libproc: ${_bt}-lib/librtld_db
+${_bt}-cddl/lib/libdtrace: ${_bt}-lib/libproc ${_bt}-lib/librtld_db
+
 bootstrap-tools: .PHONY

 #      Please document (add comment) why something is in 'bootstrap-tools'.
 #      Try to bound the building of the bootstrap-tool to just the
 #      FreeBSD versions that need the tool built at this stage of the build.
 .for _tool in \
+    ${_isi_dtrace_bs} \
     ${_clang_tblgen} \
     ${_kerberos5_bootstrap_tools} \
     ${_strfile} \
@@ -2237,6 +2242,9 @@ _btxld=           usr.sbin/btxld
 .if ${MK_CDDL} != "no"
 _dtrace_tools= cddl/lib/libctf cddl/usr.bin/ctfconvert \
     cddl/usr.bin/ctfmerge
+_dtrace_tools+= cddl/lib/drti cddl/usr.sbin/dtrace
 .endif

 # If we're given an XAS, don't build binutils.

This was also needed at some point and may make sense to commit separately.

diff --git tools/build/mk/Makefile.boot tools/build/mk/Makefile.boot
index 0b4c41b8d95f..f72a1b40837d 100644
--- tools/build/mk/Makefile.boot
+++ tools/build/mk/Makefile.boot
@@ -1,6 +1,6 @@
 # $FreeBSD$

-CFLAGS+=       -I${WORLDTMP}/legacy/usr/include
+CFLAGS+=       -isystem ${WORLDTMP}/legacy/usr/include
 DPADD+=                ${WORLDTMP}/legacy/usr/lib/libegacy.a
 LDADD+=                -legacy
 LDFLAGS+=      -L${WORLDTMP}/legacy/usr/lib

For libthr in particular this is needed in lib/libthr/Makefile, from
what I recall, to avoid errors with linking readonly sections.

LDFLAGS+=-Wl,-znotext

This is also needed for something like libthr to avoid any (small) performance
overhead caused by loading dtrace even when not used; it only loads dtrace
when required.

DTRACEFLAGS+= -x lazyload

Diff Detail

Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 34918
Build 31936: arc lint + arc unit

Event Timeline

bdrewery created this revision.

So we do build some dtrace probes during buildworld when compiling the dtrace tests (WITH_DTRACE_TESTS=). Is this mostly relevant when building on older revisions of FreeBSD?

This revision is now accepted and ready to land.Thu, Nov 19, 10:01 PM
share/mk/bsd.dep.mk
159

I think /usr/lib should probably be ${LIBDIR_BASE}. I don't think it matters in practice today, but in CheriBSD we've removed the separate WORLDTMP for libcompat builds so a compat probe would need to link against /usr/lib32/dtrace.

The whole story for this is very longwinded. I'll just say that using lazyloading for the probe avoids the need for linking drti.o and is a better solution for libthr.
It's also all reliant on being an incremental build from before the recent incremental fixes to libdtrace. I still need the libdtrace bootstrapping in my work situation but makes no sense for FreeBSD yet.
All in all this change is incomplete and would make more sense to come in with most of the summary patch as well if it is ever needed.

share/mk/bsd.dep.mk
159

Ah! I'll keep it in mind for next time. Dropping this proposal.