xref: /aosp_15_r20/external/bcc/src/cc/link_all.cc (revision 387f9dfdfa2baef462e92476d413c7bc2470293e)
1*387f9dfdSAndroid Build Coastguard Worker // Copyright (c) 2017 VMware, Inc.
2*387f9dfdSAndroid Build Coastguard Worker // Licensed under the Apache License, Version 2.0 (the "License")
3*387f9dfdSAndroid Build Coastguard Worker #include <cstdlib>
4*387f9dfdSAndroid Build Coastguard Worker 
5*387f9dfdSAndroid Build Coastguard Worker #include "bcc_usdt.h"
6*387f9dfdSAndroid Build Coastguard Worker 
7*387f9dfdSAndroid Build Coastguard Worker namespace {
8*387f9dfdSAndroid Build Coastguard Worker   // Take this trick from llvm for forcing exported functions in helper
9*387f9dfdSAndroid Build Coastguard Worker   // libraries to be included in the final .so
10*387f9dfdSAndroid Build Coastguard Worker   struct LinkAll {
LinkAll__anon8bbae6e40111::LinkAll11*387f9dfdSAndroid Build Coastguard Worker     LinkAll() {
12*387f9dfdSAndroid Build Coastguard Worker       // getenv never returns -1, but compiler doesn't know!
13*387f9dfdSAndroid Build Coastguard Worker       if (::getenv("bar") != (char *)-1)
14*387f9dfdSAndroid Build Coastguard Worker         return;
15*387f9dfdSAndroid Build Coastguard Worker 
16*387f9dfdSAndroid Build Coastguard Worker #ifdef EXPORT_USDT
17*387f9dfdSAndroid Build Coastguard Worker       (void)bcc_usdt_new_frompid(-1, nullptr);
18*387f9dfdSAndroid Build Coastguard Worker       (void)bcc_usdt_new_frompath(nullptr);
19*387f9dfdSAndroid Build Coastguard Worker       (void)bcc_usdt_close(nullptr);
20*387f9dfdSAndroid Build Coastguard Worker #endif
21*387f9dfdSAndroid Build Coastguard Worker     }
22*387f9dfdSAndroid Build Coastguard Worker   } LinkAll;  // declare one instance to invoke the constructor
23*387f9dfdSAndroid Build Coastguard Worker }
24