Skip to content

Commit db21063

Browse files
committed
Reverting benchmark cmake changes. They break out-of-tree benchmark builds, which is used by some bots
Revert "Refactor out the creation of the benchmark libraries into a helper routine swift_benchmark_library. Initially just use it for DriverUtils." This reverts commit ac53973. (+3 squashed commits) Squashed commits: [755f057] Revert "[benchmark][cmake] Refactor the swift benchmark helper libraries to use swift_benchmark_library." This reverts commit a82945e. [58e09c6] Revert "[benchmark][cmake] "swift_benchmark_library" => "add_swift_benchmark_library"." This reverts commit 0e4b7b6. [5f5f2c1] Revert "[benchmark][cmake] Fix typo. This is NFC since this option is usually disabled." This reverts commit 30f4b1b.
1 parent 918d0c6 commit db21063

File tree

1 file changed

+70
-79
lines changed

1 file changed

+70
-79
lines changed

benchmark/cmake/modules/AddSwiftBenchmarkSuite.cmake

Lines changed: 70 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
include(CMakeParseArguments)
33

4+
45
# Run a shell command and assign output to a variable or fail with an error.
56
# Example usage:
67
# runcmd(COMMAND "xcode-select" "-p"
@@ -19,57 +20,6 @@ function(runcmd)
1920
set(${RUNCMD_VARIABLE} ${${RUNCMD_VARIABLE}} PARENT_SCOPE)
2021
endfunction(runcmd)
2122

22-
function (add_swift_benchmark_library objfile_out sibfile_out)
23-
cmake_parse_arguments(BENCHLIB "" "MODULE_PATH;SOURCE_DIR;OBJECT_DIR" "SOURCES;LIBRARY_FLAGS" ${ARGN})
24-
25-
precondition(BENCHLIB_MODULE_PATH)
26-
precondition(BENCHLIB_SOURCE_DIR)
27-
precondition(BENCHLIB_OBJECT_DIR)
28-
precondition(BENCHLIB_SOURCES)
29-
30-
set(module_name_path "${BENCHLIB_MODULE_PATH}")
31-
get_filename_component(module_name "${module_name_path}" NAME)
32-
set(srcdir "${BENCHLIB_SOURCE_DIR}")
33-
set(objdir "${BENCHLIB_OBJECT_DIR}")
34-
set(sources "${BENCHLIB_SOURCES}")
35-
36-
set(objfile "${objdir}/${module_name}.o")
37-
set(swiftmodule "${objdir}/${module_name}.swiftmodule")
38-
39-
precondition(objfile_out)
40-
add_custom_command(
41-
OUTPUT "${objfile}"
42-
DEPENDS ${stdlib_dependencies} ${sources}
43-
COMMAND "${SWIFT_EXEC}"
44-
${BENCHLIB_LIBRARY_FLAGS}
45-
"-force-single-frontend-invocation"
46-
"-parse-as-library"
47-
"-module-name" "${module_name}"
48-
"-emit-module" "-emit-module-path" "${swiftmodule}"
49-
"-o" "${objfile}"
50-
${sources})
51-
set(${objfile_out} "${objfile}" PARENT_SCOPE)
52-
53-
if(SWIFT_BENCHMARK_EMIT_SIB)
54-
precondition(sibfile_out)
55-
set(sibfile "${objdir}/${module_name}.sib")
56-
57-
add_custom_command(
58-
OUTPUT "${sibfile}"
59-
DEPENDS
60-
${stdlib_dependencies} ${sources}
61-
COMMAND "${SWIFT_EXEC}"
62-
${BENCHLIB_LIBRARY_FLAGS}
63-
"-force-single-frontend-invocation"
64-
"-parse-as-library"
65-
"-module-name" "${module_name}"
66-
"-emit-sib"
67-
"-o" "${sibfile}"
68-
${sources})
69-
set(sibfile_out "${sibfile}" PARENT_SCOPE)
70-
endif()
71-
endfunction()
72-
7323
function (swift_benchmark_compile_archopts)
7424
cmake_parse_arguments(BENCH_COMPILE_ARCHOPTS "" "PLATFORM;ARCH;OPT" "" ${ARGN})
7525
set(sdk ${${BENCH_COMPILE_ARCHOPTS_PLATFORM}_sdk})
@@ -117,43 +67,84 @@ function (swift_benchmark_compile_archopts)
11767
set(bench_library_objects)
11868
set(bench_library_sibfiles)
11969
foreach(module_name_path ${BENCH_DRIVER_LIBRARY_MODULES})
120-
set(sources "${srcdir}/${module_name_path}.swift")
121-
12270
get_filename_component(module_name "${module_name_path}" NAME)
71+
12372
if("${module_name}" STREQUAL "DriverUtils")
124-
list(APPEND sources "${srcdir}/utils/ArgParse.swift")
73+
set(extra_sources "${srcdir}/utils/ArgParse.swift")
12574
endif()
12675

127-
set(objfile_out)
128-
set(sibfile_out)
129-
add_swift_benchmark_library(objfile_out sibfile_out
130-
MODULE_PATH "${module_name_path}"
131-
SOURCE_DIR "${srcdir}"
132-
OBJECT_DIR "${objdir}"
133-
SOURCES ${sources}
134-
LIBRARY_FLAGS ${common_options_driver} ${BENCH_DRIVER_LIBRARY_FLAGS})
135-
precondition(objfile_out)
136-
list(APPEND bench_library_objects "${objfile_out}")
137-
if (SWIFT_BENCHMARK_EMIT_SIB)
138-
precondition(sibfile_out)
139-
list(APPEND bench_library_sibfiles "${sibfile_out}")
76+
set(objfile "${objdir}/${module_name}.o")
77+
set(swiftmodule "${objdir}/${module_name}.swiftmodule")
78+
list(APPEND bench_library_objects "${objfile}")
79+
set(source "${srcdir}/${module_name_path}.swift")
80+
add_custom_command(
81+
OUTPUT "${objfile}"
82+
DEPENDS ${stdlib_dependencies} "${source}" ${extra_sources}
83+
COMMAND "${SWIFT_EXEC}"
84+
${common_options_driver}
85+
${BENCH_DRIVER_LIBRARY_FLAGS}
86+
"-force-single-frontend-invocation"
87+
"-parse-as-library"
88+
"-module-name" "${module_name}"
89+
"-emit-module" "-emit-module-path" "${swiftmodule}"
90+
"-o" "${objfile}"
91+
"${source}" ${extra_sources})
92+
if(SWIFT_BENCHMARK_EMIT_SIB)
93+
set(sibfile "${objdir}/${module_name}.sib")
94+
list(APPEND bench_library_sibfiles "${sibfile}")
95+
add_custom_command(
96+
OUTPUT "${sibfile}"
97+
DEPENDS
98+
${stdlib_dependencies} "${srcdir}/${module_name_path}.swift"
99+
${extra_sources}
100+
COMMAND "${SWIFT_EXEC}"
101+
${common_options_driver}
102+
${BENCH_DRIVER_LIBRARY_FLAGS}
103+
"-force-single-frontend-invocation"
104+
"-parse-as-library"
105+
"-module-name" "${module_name}"
106+
"-emit-sib"
107+
"-o" "${sibfile}"
108+
"${source}" ${extra_sources})
140109
endif()
141110
endforeach()
142111

143112
foreach(module_name_path ${BENCH_LIBRARY_MODULES})
144-
set(sources "${srcdir}/${module_name_path}.swift")
145-
146-
add_swift_benchmark_library(objfile_out sibfile_out
147-
MODULE_PATH "${module_name_path}"
148-
SOURCE_DIR "${srcdir}"
149-
OBJECT_DIR "${objdir}"
150-
SOURCES ${sources}
151-
LIBRARY_FLAGS ${common_options})
152-
precondition(objfile_out)
153-
list(APPEND bench_library_objects "${objfile_out}")
113+
get_filename_component(module_name "${module_name_path}" NAME)
114+
115+
set(objfile "${objdir}/${module_name}.o")
116+
set(swiftmodule "${objdir}/${module_name}.swiftmodule")
117+
set(source "${srcdir}/${module_name_path}.swift")
118+
list(APPEND bench_library_objects "${objfile}")
119+
add_custom_command(
120+
OUTPUT "${objfile}"
121+
DEPENDS
122+
${stdlib_dependencies} "${srcdir}/${module_name_path}.swift"
123+
${extra_sources}
124+
COMMAND "${SWIFT_EXEC}"
125+
${common_options}
126+
"-force-single-frontend-invocation"
127+
"-parse-as-library"
128+
"-module-name" "${module_name}"
129+
"-emit-module" "-emit-module-path" "${swiftmodule}"
130+
"-o" "${objfile}"
131+
"${source}" ${extra_sources})
154132
if (SWIFT_BENCHMARK_EMIT_SIB)
155-
precondition(sibfile_out)
156-
list(APPEND bench_library_sibfiles "${sibfile_out}")
133+
set(sibfile "${objdir}/${module_name}.sib")
134+
list(APPEND bench_library_sibfiles "${sibfile}")
135+
add_custom_command(
136+
OUTPUT "${sibfile}"
137+
DEPENDS
138+
${stdlib_dependencies} "${srcdir}/${module_name_path}.swift"
139+
${extra_sources}
140+
COMMAND "${SWIFT_EXEC}"
141+
${common_options}
142+
"-force-single-frontend-invocation"
143+
"-parse-as-library"
144+
"-module-name" "${module_name}"
145+
"-emit-sib"
146+
"-o" "${sibfile}"
147+
"${source}" ${extra_sources})
157148
endif()
158149
endforeach()
159150

0 commit comments

Comments
 (0)