Skip to content

Commit 820caa3

Browse files
committed
Fix osx/freebsd build
1 parent a7afd82 commit 820caa3

File tree

5 files changed

+26
-34
lines changed

5 files changed

+26
-34
lines changed

src/coreclr/scripts/genEventing.py

+15-14
Original file line numberDiff line numberDiff line change
@@ -467,9 +467,8 @@ def parseTemplateNodes(templateNodes):
467467

468468
return allTemplates
469469

470-
def generateClrallEvents(eventNodes, allTemplates, target_cpp, runtimeFlavor, write_xplatheader, providerName, inclusionList, generatedFileType):
470+
def generateClrallEvents(eventNodes, allTemplates, target_cpp, runtimeFlavor, write_xplatheader, providerName, inclusionList, generatedFileType, user_events):
471471
clrallEvents = []
472-
is_linux = sys.platform.startswith('linux')
473472
for eventNode in eventNodes:
474473
eventName = eventNode.getAttribute('symbol')
475474

@@ -497,7 +496,7 @@ def generateClrallEvents(eventNodes, allTemplates, target_cpp, runtimeFlavor, wr
497496

498497
if runtimeFlavor.coreclr or write_xplatheader or runtimeFlavor.nativeaot:
499498
if os.name == 'posix':
500-
if is_linux and runtimeFlavor.coreclr:
499+
if user_events and runtimeFlavor.coreclr:
501500
clrallEvents.append(" || UserEventsEventEnabled" + eventName + "()")
502501
# native AOT does not support non-windows eventing other than via event pipe
503502
if not runtimeFlavor.nativeaot:
@@ -593,7 +592,7 @@ def generateClrallEvents(eventNodes, allTemplates, target_cpp, runtimeFlavor, wr
593592

594593
fnbody.append("ActivityId,RelatedActivityId);\n")
595594

596-
if is_linux and runtimeFlavor.coreclr:
595+
if user_events and runtimeFlavor.coreclr:
597596
fnbody.append("status &= UserEventsWriteEvent" + eventName + "(" + ''.join(line))
598597
if len(line) > 0:
599598
fnbody.append(",")
@@ -872,7 +871,7 @@ def getKeywordsMaskCombined(keywords, keywordsToMask):
872871

873872
return mask
874873

875-
def updateclreventsfile(write_xplatheader, target_cpp, runtimeFlavor, eventpipe_trace_context_typedef, dotnet_trace_context_typedef_windows, tree, clrallevents, inclusion_list, generatedFileType):
874+
def updateclreventsfile(write_xplatheader, target_cpp, runtimeFlavor, eventpipe_trace_context_typedef, dotnet_trace_context_typedef_windows, tree, clrallevents, inclusion_list, generatedFileType, user_events):
876875
is_windows = os.name == 'nt'
877876
is_linux = sys.platform.startswith('linux')
878877
with open_for_update(clrallevents) as Clrallevents:
@@ -927,7 +926,7 @@ def updateclreventsfile(write_xplatheader, target_cpp, runtimeFlavor, eventpipe_
927926
eventNodes = providerNode.getElementsByTagName('event')
928927

929928
#vm header:
930-
Clrallevents.write(generateClrallEvents(eventNodes, allTemplates, target_cpp, runtimeFlavor, write_xplatheader, providerName, inclusion_list, generatedFileType))
929+
Clrallevents.write(generateClrallEvents(eventNodes, allTemplates, target_cpp, runtimeFlavor, write_xplatheader, providerName, inclusion_list, generatedFileType, user_events))
931930

932931
providerName = providerNode.getAttribute('name')
933932
providerSymbol = providerNode.getAttribute('symbol')
@@ -942,7 +941,7 @@ def updateclreventsfile(write_xplatheader, target_cpp, runtimeFlavor, eventpipe_
942941
if generatedFileType == "header":
943942
Clrallevents.write("#endif // __CLR_ETW_ALL_MAIN_H__\n")
944943

945-
def generatePlatformIndependentFiles(sClrEtwAllMan, incDir, etmDummyFile, extern, write_xplatheader, target_cpp, runtimeFlavor, inclusion_list):
944+
def generatePlatformIndependentFiles(sClrEtwAllMan, incDir, etmDummyFile, extern, write_xplatheader, target_cpp, runtimeFlavor, inclusion_list, user_events):
946945

947946
generateEtmDummyHeader(sClrEtwAllMan,etmDummyFile)
948947
tree = DOM.parse(sClrEtwAllMan)
@@ -1002,16 +1001,15 @@ def generatePlatformIndependentFiles(sClrEtwAllMan, incDir, etmDummyFile, extern
10021001
"""
10031002

10041003
is_windows = os.name == 'nt'
1005-
is_linux = sys.platform.startswith('linux')
10061004

10071005
# Write the main source(s) for FireETW* functions
10081006
# nativeaot requires header and source file to be separated as well as a noop implementation
10091007
if runtimeFlavor.nativeaot:
1010-
updateclreventsfile(write_xplatheader, target_cpp, runtimeFlavor, eventpipe_trace_context_typedef, dotnet_trace_context_typedef_windows, tree, os.path.join(incDir, "clretwallmain.cpp"), inclusion_list, "source-impl")
1011-
updateclreventsfile(write_xplatheader, target_cpp, runtimeFlavor, eventpipe_trace_context_typedef, dotnet_trace_context_typedef_windows, tree, os.path.join(incDir, "clretwallmain.h"), inclusion_list, "header")
1012-
updateclreventsfile(write_xplatheader, target_cpp, runtimeFlavor, eventpipe_trace_context_typedef, dotnet_trace_context_typedef_windows, tree, os.path.join(incDir, "disabledclretwallmain.cpp"), inclusion_list, "source-impl-noop")
1008+
updateclreventsfile(write_xplatheader, target_cpp, runtimeFlavor, eventpipe_trace_context_typedef, dotnet_trace_context_typedef_windows, tree, os.path.join(incDir, "clretwallmain.cpp"), inclusion_list, "source-impl", user_events)
1009+
updateclreventsfile(write_xplatheader, target_cpp, runtimeFlavor, eventpipe_trace_context_typedef, dotnet_trace_context_typedef_windows, tree, os.path.join(incDir, "clretwallmain.h"), inclusion_list, "header", user_events)
1010+
updateclreventsfile(write_xplatheader, target_cpp, runtimeFlavor, eventpipe_trace_context_typedef, dotnet_trace_context_typedef_windows, tree, os.path.join(incDir, "disabledclretwallmain.cpp"), inclusion_list, "source-impl-noop", user_events)
10131011
else:
1014-
updateclreventsfile(write_xplatheader, target_cpp, runtimeFlavor, eventpipe_trace_context_typedef, dotnet_trace_context_typedef_windows, tree, os.path.join(incDir, "clretwallmain.h"), inclusion_list, "header-impl")
1012+
updateclreventsfile(write_xplatheader, target_cpp, runtimeFlavor, eventpipe_trace_context_typedef, dotnet_trace_context_typedef_windows, tree, os.path.join(incDir, "clretwallmain.h"), inclusion_list, "header-impl", user_events)
10151013

10161014
if write_xplatheader:
10171015
clrproviders = os.path.join(incDir, "clrproviders.h")
@@ -1084,7 +1082,7 @@ def generatePlatformIndependentFiles(sClrEtwAllMan, incDir, etmDummyFile, extern
10841082
#eventpipe: create clreventpipewriteevents.h
10851083
Clreventpipewriteevents.write(generateClrEventPipeWriteEvents(eventNodes, allTemplates, extern, target_cpp, runtimeFlavor, providerName, inclusion_list) + "\n")
10861084

1087-
if is_linux and runtimeFlavor.coreclr:
1085+
if user_events and runtimeFlavor.coreclr:
10881086
clrusereventswriteeventsPath = os.path.join(incDir, "clrusereventswriteevents.h")
10891087
with open_for_update(clrusereventswriteeventsPath) as clrusereventswriteevents:
10901088
clrusereventswriteevents.write(stdprolog + "\n")
@@ -1135,6 +1133,8 @@ def main(argv):
11351133
help='if specified, will not generated extern function stub headers' )
11361134
required.add_argument('--noxplatheader', action='store_true',
11371135
help='if specified, will not write a generated cross-platform header' )
1136+
required.add_argument('--userevents', action='store_true',
1137+
help='if specified, will emit support for user_events' )
11381138
args, unknown = parser.parse_known_args(argv)
11391139
if unknown:
11401140
print('Unknown argument(s): ', ', '.join(unknown))
@@ -1147,6 +1147,7 @@ def main(argv):
11471147
runtimeFlavor = RuntimeFlavor(args.runtimeflavor)
11481148
extern = not args.nonextern
11491149
write_xplatheader = not args.noxplatheader
1150+
user_events = args.userevents
11501151

11511152
target_cpp = True
11521153
if runtimeFlavor.mono:
@@ -1156,7 +1157,7 @@ def main(argv):
11561157

11571158
inclusion_list = parseInclusionList(inclusion_filename)
11581159

1159-
generatePlatformIndependentFiles(sClrEtwAllMan, incdir, etmDummyFile, extern, write_xplatheader, target_cpp, runtimeFlavor, inclusion_list)
1160+
generatePlatformIndependentFiles(sClrEtwAllMan, incdir, etmDummyFile, extern, write_xplatheader, target_cpp, runtimeFlavor, inclusion_list, user_events)
11601161

11611162
if __name__ == '__main__':
11621163
return_code = main(sys.argv[1:])

src/coreclr/scripts/genUserEvents.py

+1-15
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ def generateUserEventHelperFile(etwmanifest, userevent_directory, target_cpp, ru
209209
#include <common.h>
210210
#include <configuration.h>
211211
212-
#ifdef TARGET_UNIX
213212
bool s_userEventsEnabled = false;
214213
215214
void InitUserEvents()
@@ -228,20 +227,7 @@ def generateUserEventHelperFile(etwmanifest, userevent_directory, target_cpp, ru
228227
{
229228
return s_userEventsEnabled;
230229
}
231-
232-
#else // TARGET_UNIX
233-
void InitUserEvents()
234-
{
235-
236-
}
237-
238-
bool IsUserEventsEnabled()
239-
{
240-
return false;
241-
}
242-
243-
#endif // TARGET_UNIX
244-
""")
230+
""")
245231

246232
def getCoreCLRUserEventImplFilePrefix():
247233
return """#include "common.h"

src/coreclr/vm/ceemain.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,9 @@
197197
#include "diagnosticserveradapter.h"
198198
#include "eventpipeadapter.h"
199199

200-
#ifdef FEATURE_PERFTRACING
200+
#if defined(FEATURE_PERFTRACING) && defined(TARGET_LINUX)
201201
#include "user_events.h"
202-
#endif // FEATURE_PERFTRACING
202+
#endif // defined(FEATURE_PERFTRACING) && defined(TARGET_LINUX)
203203

204204
#ifndef TARGET_UNIX
205205
// Included for referencing __security_cookie
@@ -665,9 +665,9 @@ void EEStartupHelper()
665665
#ifdef FEATURE_PERFTRACING
666666
// Initialize the event pipe.
667667
EventPipeAdapter::Initialize();
668-
#if defined(TARGET_UNIX)
668+
#if defined(TARGET_LINUX)
669669
InitUserEvents();
670-
#endif // TARGET_UNIX
670+
#endif // TARGET_LINUX
671671
#endif // FEATURE_PERFTRACING
672672

673673
#ifdef TARGET_UNIX

src/coreclr/vm/eventing/CMakeLists.txt

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ else()
88
set(NEED_XPLAT_HEADER ON)
99
endif()
1010

11+
if (CLR_CMAKE_TARGET_LINUX)
12+
set(USEREVENTS_ARG "--userevents")
13+
endif(CLR_CMAKE_TARGET_LINUX)
14+
1115
include(FindPython)
1216

1317
set (EventingHeaders
@@ -26,7 +30,7 @@ set(GENEVENTING_SCRIPT ${CLR_DIR}/scripts/genEventing.py)
2630

2731
add_custom_command(
2832
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/eventing_headers.timestamp
29-
COMMAND ${Python_EXECUTABLE} ${GENEVENTING_SCRIPT} --man ${EVENT_MANIFEST} --incdir ${GENERATED_INCLUDE_DIR} --dummy ${GENERATED_INCLUDE_DIR}/etmdummy.h ${NONEXTERN_ARG} ${NOXPLATHEADER_ARG}
33+
COMMAND ${Python_EXECUTABLE} ${GENEVENTING_SCRIPT} --man ${EVENT_MANIFEST} --incdir ${GENERATED_INCLUDE_DIR} --dummy ${GENERATED_INCLUDE_DIR}/etmdummy.h ${NONEXTERN_ARG} ${NOXPLATHEADER_ARG} ${USEREVENTS_ARG}
3034
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/eventing_headers.timestamp
3135
DEPENDS ${EVENT_MANIFEST} ${GENEVENTING_SCRIPT}
3236
VERBATIM

src/coreclr/vm/eventing/userevents/user_events.h

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#ifndef __USEREVENTS_H__
55
#define __USEREVENTS_H__
66

7+
78
extern void InitUserEvents();
89
extern bool IsUserEventsEnabled();
910

0 commit comments

Comments
 (0)