Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Fix LTTng build for build environments with older liblttng-ust-dev #27273

Merged
merged 5 commits into from
Oct 18, 2019

Conversation

sywhang
Copy link

@sywhang sywhang commented Oct 17, 2019

This fixes https://github.com/dotnet/coreclr/issues/27024.

For all of our event sinks for LTTng, we wrap the call to fire events with tracepoint_enabled, which is a macro defined in a header file liblttng-ust-dev. This macro checks whether a particular probe point is enabled before we fire an event, so that we're not unnecessarily making the call to fire events through LTTng when nobody is listening to it.

For environments that don't want to build using LTTng, we have a macro definition for tracepoint_enabled, which used to be defined as:

#define tracepoint_enabled(provider, name) TRUE.

This meant that for custom CoreCLR builds that were produced without LTTng library enabled, the runtime will always try to fire all events only to find out nobody is listening. So this behavior was changed to

#define tracepoint_enabled(provider, name) FALSE.

Unfortunately this caused the compiler to optimize out the bodies for all the event sinks when such thing happens. This would be fine for custom builds that didn't want LTTng since they become no-ops. However, some build environments that we still use, we use old enough distributions that have old LTTng libraries, specifically CentOS 6 which uses liblttng-ust-dev version 2.4. This particular version of the library doesn't have the definition of tracepoint_enabled in its header, so we hit this bad behavior in builds produced in CentOS 6 container.

Even more unfortunately, CentOS 6 is the distro we use for our official SDK build containers for Linux, so this caused LTTng support in CoreCLR to regress in the official builds.

This fix changes the macro definition of tracepoint_enabled to use XplatEventLogger::IsEventLoggingEnabled method, which checks if the environment variable we require for using LTTng tracing (COMPlus_EnableEventLog) is enabled.

The long term fix for this would be to change the official build containers to build and install liblttng-ust-dev versions 2.5 or newer, but this is the short-term fix until that happens.

The fix will be ported to 3.0 and 3.1 once merged.

cc @tommcdon

Copy link
Member

@brianrob brianrob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sywhang, this looks good for 3.0 and 3.1 (modulo comment below), but for 5.0, we really should upgrade and prereq a UST that supports tracepoint_enabled. Then we can remove the #ifndef.

@sywhang
Copy link
Author

sywhang commented Oct 17, 2019

but for 5.0, we really should upgrade and prereq a UST that supports tracepoint_enabled

I agree. Once I am finished with this and the backports, I will file an issue to keep track of this.

Copy link
Member

@noahfalk noahfalk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sywhang sywhang merged commit 1e7552a into dotnet:master Oct 18, 2019
sywhang added a commit to sywhang/coreclr that referenced this pull request Oct 18, 2019
…otnet#27273)

* Fix macro redefinition to use XplatEventLogger instead of simply writing FALSE

* Fix linker error

* undo newline changes

* Some changes to comment

* Move wrapper export from eventpipe.cpp to eventtrace.cpp
sywhang added a commit to sywhang/coreclr that referenced this pull request Oct 18, 2019
…otnet#27273)

* Fix macro redefinition to use XplatEventLogger instead of simply writing FALSE

* Fix linker error

* undo newline changes

* Some changes to comment

* Move wrapper export from eventpipe.cpp to eventtrace.cpp
sywhang added a commit that referenced this pull request Oct 21, 2019
…27273) (#27294)

* Fix macro redefinition to use XplatEventLogger instead of simply writing FALSE

* Fix linker error

* undo newline changes

* Some changes to comment

* Move wrapper export from eventpipe.cpp to eventtrace.cpp
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LTTng Produces No Events On Official Builds
4 participants