This is an archive of the discontinued LLVM Phabricator instance.

Prioritize the constructor call of __local_xray_dyninit()
ClosedPublic

Authored by krytarowski on Nov 5 2018, 6:54 PM.

Details

Summary

For platforms without preinit support (such as NetBSD/amd64) the
initialization routine __xray_init() was called in non-deterministic order
compared to other constructors. This caused breakage failures
as xray routines attempted to execute code with assumption of
being initialized, which was no always true.

Use GCC/Clang extension to set maximal priority to the constructor
calling __xray_init(). This code switches away from C++ lambda form,
as it did not allow to specify this compiler extension.

Diff Detail

Event Timeline

krytarowski created this revision.Nov 5 2018, 6:54 PM
krytarowski retitled this revision from Priority the constructor call of __local_xray_dyninit() to Prioritize the constructor call of __local_xray_dyninit().Nov 5 2018, 6:55 PM
dberris accepted this revision.Nov 5 2018, 7:56 PM

LGTM

Has this been tested with GCC/Clang on other systems (like Linux)?

This revision is now accepted and ready to land.Nov 5 2018, 7:56 PM

This isn't normally used on Linux since .preinit_array is used. If I force it, I get the following warning (from gcc):

../projects/compiler-rt/lib/xray/xray_init.cc:110:34: warning: constructor priorities from 0 to 100 are reserved for the implementation
 static void __local_xray_dyninit() {
                                  ^

All tests pass.

krytarowski edited the summary of this revision. (Show Details)Nov 6 2018, 1:36 AM
This revision was automatically updated to reflect the committed changes.