This is an archive of the discontinued LLVM Phabricator instance.

[profile] Solaris ld supports __start___llvm_prof_data etc. labels
ClosedPublic

Authored by ro on Dec 12 2017, 4:43 AM.

Details

Summary

This patch is a companion to https://reviews.llvm.org/D40944.

I've got an experimental version of Solaris ld that does support the non-standard
GNU ld extension of adding start_SECNAME and stop_SECNAME labels to
sections whose names are valid as C identifiers.

It documents that support (although the comment in lib/Transforms/Instrumentation/InstrProfiling.cpp
(needsRuntimeRegistrationOfSectionRange) is quite cryptic what it's actually about,
and adapts the affected testcase not to expect the alternativ llvm_profile_register_functions
and
llvm_profile_init.

I'm posting this patch for reference now, but it's problematic in how to deal with
either older Solaris versions or OpenSolaris derivatives where ld doesn't support
this extension.

Diff Detail

Repository
rL LLVM

Event Timeline

ro created this revision.Dec 12 2017, 4:43 AM
vsk added a comment.Dec 12 2017, 10:39 AM

Is there a way to gate the change on the Solaris OS version (maybe it's in the triple somewhere)? Apart from that, this patch lgtm.

ro added a comment.Dec 13 2017, 2:44 AM
In D41111#952623, @vsk wrote:

Is there a way to gate the change on the Solaris OS version (maybe it's in the triple somewhere)? Apart from that, this patch lgtm.

Unfortunately not: all `interesting' Solaris versions identify themselves as *-*-solaris2.11. In gcc land, one would use a configure test
looking at the ld version number in cases like this, since it has turned out that actual linker feature tests are often hard and involved.

The same issue applies to whether or not to use the libclang_rt.sancov_{begin,end}-*.a libraries in https://reviews.llvm.org/D40899 and
https://reviews.llvm.org/D40903.

ro updated this revision to Diff 205802.Jun 20 2019, 7:02 AM

Rebased an slightly fixed version. Without it, man profiling tests on Solaris FAIL like

Command Output (stderr):
--
Undefined                       first referenced
 symbol                             in file
__llvm_profile_register_names_function /tmp/lit_tmp_Nqu4eh/infinite_loop-9dc638.o
__llvm_profile_register_function    /tmp/lit_tmp_Nqu4eh/infinite_loop-9dc638.o

I don't think we need to worry about older versions of Solaris ld that don't support
__start_SECNAME and stop_SECNAME labels any longer: that feature is in
Solaris 11.4 and we already use Solaris 11.4-only features like ld -z gnu-version-script-compat
and fully working .preinit_array suport in compiler-rt.

Tested on amd64-pc-solaris2.11, ok for trunk now?

Herald added a project: Restricted Project. · View Herald TranscriptJun 20 2019, 7:02 AM
vsk accepted this revision.Jun 20 2019, 10:29 AM

Thanks, lgtm.

This revision is now accepted and ready to land.Jun 20 2019, 10:29 AM
This revision was automatically updated to reflect the committed changes.