This is an archive of the discontinued LLVM Phabricator instance.

[profile] Install headers for custom runtime maintainers
Needs ReviewPublic

Authored by vsk on Sep 17 2018, 5:26 PM.

Details

Reviewers
delcypher
beanz
Summary

Some users maintain custom runtimes which provide support for
-fprofile-instr-generate instrumentation in non-standard environments
(e.g the kernel).

It may not be obvious which functions need to be implemented or what
their signatures are. Silent breakage is possible if the runtime's
internal interface changes.

This patch installs a few headers from the profiling runtime to serve as
a reference:

$ ninja install-compiler-rt-headers -v
...
-- Installing: /usr/local/lib/clang/10.0.0/include/profile/InstrProfiling.h
-- Installing: /usr/local/lib/clang/10.0.0/include/profile/InstrProfilingInternal.h
-- Installing: /usr/local/lib/clang/10.0.0/include/profile/InstrProfData.inc

rdar://44375648

Diff Detail

Event Timeline

vsk created this revision.Sep 17 2018, 5:26 PM
beanz accepted this revision.Oct 4 2018, 8:25 PM

LGTM.

This revision is now accepted and ready to land.Oct 4 2018, 8:25 PM
delcypher requested changes to this revision.Oct 5 2018, 2:13 AM

@vsk I'm not entirely convinced this is correct but this might be because I don't understand how these header files are meant to be consumed.

Your implementation of add_compiler_rt_header() calls add_compiler_rt_resource_file() which installs into the Clang resource directory (<install_root>/share/). This is not the same path that other sanitizer interface headers get installed (see include/CMakeLists.txt in the compiler-rt source tree) which is <install_root>/include.

This means that clients of won't be able consume these header files in the same way that they consume other sanitizer header files. Perhaps this is intentional because these header files might be internal headers (I don't know. I've not really looked at the profile portion of compiler-rt before).
If that is your intention I really think you need to rename add_compiler_rt_header to something that expresses the intent more explicitly. The name add_compiler_rt_header could easily lead someone to believe it will get installed to <install_root>/include which doesn't appear to be the case.

This revision now requires changes to proceed.Oct 5 2018, 2:13 AM
vsk updated this revision to Diff 221650.Sep 24 2019, 6:15 PM
vsk edited the summary of this revision. (Show Details)

@delcypher apologies for the massive delay, and thanks for pointing out that issue. This just came up again internally -- PTAL :)?

Herald added a project: Restricted Project. · View Herald TranscriptSep 24 2019, 6:15 PM
vsk updated this revision to Diff 221651.Sep 24 2019, 6:16 PM
  • Drop an extraneous lldb change.

@vsk other than the minor nit LGTM.

compiler-rt/include/CMakeLists.txt
33 ↗(On Diff #221651)

@vsk Minor nit. Any particular reason why those header files live under lib instead on under include/ in the source tree?

vsk marked an inline comment as done.Sep 26 2019, 1:01 PM
vsk added inline comments.
compiler-rt/include/CMakeLists.txt
33 ↗(On Diff #221651)

Not that I'm aware of -- this could be a nice chance to clean things up.

Unfortunately I'm having a bear of a time figuring out why the rest of the sanitizers don't seem to pass -I ${COMPILER_RT_SOURCE_DIR}/include, but still manage to find the right headers. The profile runtime isn't built with this -I -- I suppose I could just add it in the profile runtime's CMakeLists.txt (and that works), but feel like I'm missing something. Any chance you've stumbled into this before?

vsk marked an inline comment as done.Sep 27 2019, 11:08 AM
vsk added inline comments.
compiler-rt/include/CMakeLists.txt
33 ↗(On Diff #221651)

Oh, actually, it looks like the sanitizer implementations don't include their public interface headers on purpose. In light of that, it actually seems more consistent to keep the profile headers in lib.

vsk added a comment.Oct 11 2019, 2:21 PM

Friendly ping