Skip to content

Commit

Permalink
DONOTSTRIP for kUnifexAsyncStackRootHolderList
Browse files Browse the repository at this point in the history
  • Loading branch information
Riley Berton committed Jan 9, 2025
1 parent 48072b0 commit daece86
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion source/async_stack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ namespace unifex {

#if UNIFEX_ASYNC_STACK_ROOT_USE_VECTOR

// Ensure anything tagged with UNIFEX_DONOTSTRIP is not stripped by the linker.
// This will not protect against the `strip` tool, but it will allow us to
// make a symbol visible to debuggers and profilers even in the face of LTO.
//
// Users of the `strip` tool will need to use the
// `--keep-symbol=kUnifexAsyncStackRootHolderList` flag if they want to keep
// the async stack roots for introspection.
#define UNIFEX_DONOTSTRIP __attribute__((used))

struct AsyncStackRootHolderList {
std::vector<void*> asyncStackRootHolders_;
std::mutex mutex_;
Expand Down Expand Up @@ -97,7 +106,7 @@ struct AsyncStackRootHolderList {
};

extern "C" {
auto* kUnifexAsyncStackRootHolderList = new AsyncStackRootHolderList();
auto* kUnifexAsyncStackRootHolderList UNIFEX_DONOTSTRIP = new AsyncStackRootHolderList();
}

static std::uint64_t get_os_thread_id() {
Expand Down

0 comments on commit daece86

Please sign in to comment.