Page MenuHomeFreeBSD

Enable building libclang_rt (asan, ubsan and profile) for selected arches
ClosedPublic

Authored by dim on Jan 12 2015, 8:37 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, May 16, 3:47 PM
Unknown Object (File)
Fri, May 3, 5:32 AM
Unknown Object (File)
Mon, Apr 29, 1:03 PM
Unknown Object (File)
Mon, Apr 29, 1:03 PM
Unknown Object (File)
Mon, Apr 29, 1:03 PM
Unknown Object (File)
Mon, Apr 29, 1:03 PM
Unknown Object (File)
Apr 16 2024, 3:21 AM
Unknown Object (File)
Apr 10 2024, 9:13 PM

Details

Summary

I added the libclang_rt libraries (Address Sanitizer, Undefined Behavior
Sanitizer and Profile Guided Optimization) from compiler-rt to the tree
recently, but did not connect them to the build yet.

The requirements for these libraries are:

  • Must be built with clang, gcc (not even recent versions) can build them
  • Only make sense to build when either the cross-tools stage (e.g. the stuff installed under ${WORLDTMP}) has clang enabled, or when then final world has clang enabled.
  • The sanitizer libraries can only be built for i386 and amd64.
  • The profile library can only be built for i386, amd64 and LE arm.

Apart from the bit of ugliness in lib/Makefile (which Warner does not
like), there is also still a practical problem, which I have not been
able to solve as of yet:

On amd64, the build32 stage will now build the libclang_rt libraries,
but due to ${LIB32IMAKE} containing MK_TOOLCHAIN=no, the install32 stage
will *not* install them. I don't see any easy way around this, excect
maybe partially reverting r264930, but that will get us back to the
situation with NO_INCS, which Warner tried to avoid with that commit.

Note that I also did not introduce yet another WITH_LIBCLANG_RT knob,
since I don't really see the need: WITH_CLANG should basically always
cause these libraries to be built and installed.

However, if the general opinion is that another knob is good to have, I
can implement it, and move the lib/Makefile ugliness to src.opts.mk
instead.

Test Plan

Build and install in various situations. Do a bunch of runtime tests to
ascertain the asan, ubsan and profile libraries can be found when
building programs with -fsanitize=address, -fsanitize=undefined and
-fprofile-generate, respectively.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

dim retitled this revision from to Enable building libclang_rt (asan, ubsan and profile) for selected arches.
dim updated this object.
dim edited the test plan for this revision. (Show Details)
dim added reviewers: andrew, bapt, emaste, imp.
dim added a subscriber: Unknown Object (MLST).

Minor note: this survived a "make universe" on one of the FreeBSD.org reference machines.

Apart from the bit of ugliness in lib/Makefile

Perhaps the ugliness needs a comment, at least.

Also a BSD.debug.mk entry for WITH_DEBUG_FILES=yes?

Note that I also did not introduce yet another WITH_LIBCLANG_RT knob,

This is fine in my opinion; we don't need another knob.

dim edited edge metadata.
  • Added new directories to BSD.debug.dist
  • Added explanatory comment to lib/Makefile

Avoid specifically listing architectures.

dim updated this revision to Diff 3155.

Closed by commit rS277146 (authored by @dim).