Skip to content

Commit 3715464

Browse files
committed
Add a cmake flag to the benchmarks: SWIFT_BENCHMARK_EXTRA_FLAGS.
We used to have this cmake flag but it seems to have disappeared. Building the benchmarks with different swiftc flags is central to performance analysis, so I'm not sure how people were getting this done.
1 parent e66fd1a commit 3715464

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

benchmark/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,9 @@ if(NOT SWIFT_OPTIMIZATION_LEVELS)
225225
${SWIFT_EXTRA_BENCH_CONFIGS})
226226
endif()
227227

228+
set(SWIFT_BENCHMARK_EXTRA_FLAGS "" CACHE STRING
229+
"Extra options to pass to swiftc when building the benchmarks")
230+
228231
set(SWIFT_BENCHMARK_NUM_O_ITERATIONS "" CACHE STRING
229232
"Number of iterations to perform when running -O benchmarks via cmake")
230233
set(SWIFT_BENCHMARK_NUM_ONONE_ITERATIONS "" CACHE STRING
@@ -289,6 +292,7 @@ message("--")
289292
message("-- Swift Benchmark Suite:")
290293
message("-- SWIFT_BENCHMARK_BUILT_STANDALONE = ${SWIFT_BENCHMARK_BUILT_STANDALONE}")
291294
message("-- SWIFT_EXEC = ${SWIFT_EXEC}")
295+
message("-- SWIFT_BENCHMARK_EXTRA_FLAGS = ${SWIFT_BENCHMARK_EXTRA_FLAGS}")
292296
message("-- SWIFT_LIBRARY_PATH = ${SWIFT_LIBRARY_PATH}")
293297
message("-- CLANG_EXEC = ${CLANG_EXEC}")
294298
message("-- SWIFT_OPTIMIZATION_LEVELS = ${SWIFT_OPTIMIZATION_LEVELS}")

benchmark/cmake/modules/AddSwiftBenchmarkSuite.cmake

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ function (swift_benchmark_compile_archopts)
319319
${extra_options}
320320
"-parse-as-library"
321321
${bench_flags}
322+
${SWIFT_BENCHMARK_EXTRA_FLAGS}
322323
"-module-name" "${module_name}"
323324
"-emit-module-path" "${swiftmodule}"
324325
"-I" "${objdir}"
@@ -336,6 +337,7 @@ function (swift_benchmark_compile_archopts)
336337
${common_swift4_options}
337338
"-parse-as-library"
338339
${bench_flags}
340+
${SWIFT_BENCHMARK_EXTRA_FLAGS}
339341
"-module-name" "${module_name}"
340342
"-I" "${objdir}"
341343
"-emit-sib"
@@ -363,7 +365,7 @@ function (swift_benchmark_compile_archopts)
363365
SOURCE_DIR "${srcdir}"
364366
OBJECT_DIR "${objdir}"
365367
SOURCES ${${module_name}_sources}
366-
LIBRARY_FLAGS ${common_swift4_options} ${bench_flags}
368+
LIBRARY_FLAGS ${common_swift4_options} ${bench_flags} ${SWIFT_BENCHMARK_EXTRA_FLAGS}
367369
DEPENDS ${bench_library_objects} ${stdlib_dependencies})
368370
precondition(objfile_out)
369371
list(APPEND SWIFT_BENCH_OBJFILES "${objfile_out}")
@@ -381,7 +383,7 @@ function (swift_benchmark_compile_archopts)
381383
SOURCE_DIR "${srcdir}"
382384
OBJECT_DIR "${objdir}"
383385
SOURCES ${${module_name}_sources}
384-
LIBRARY_FLAGS ${common_swift4_options} ${bench_flags}
386+
LIBRARY_FLAGS ${common_swift4_options} ${bench_flags} ${SWIFT_BENCHMARK_EXTRA_FLAGS}
385387
DEPENDS ${bench_library_objects} ${stdlib_dependencies})
386388
precondition(objfiles_out)
387389
list(APPEND SWIFT_BENCH_OBJFILES ${objfiles_out})
@@ -399,7 +401,7 @@ function (swift_benchmark_compile_archopts)
399401
SOURCE_DIR "${srcdir}"
400402
OBJECT_DIR "${objdir}"
401403
SOURCES ${${module_name}_sources}
402-
LIBRARY_FLAGS ${common_swift4_options} ${bench_flags}
404+
LIBRARY_FLAGS ${common_swift4_options} ${bench_flags} ${SWIFT_BENCHMARK_EXTRA_FLAGS}
403405
DEPENDS ${bench_library_objects} ${stdlib_dependencies})
404406
precondition(objfile_out)
405407
list(APPEND SWIFT_BENCH_OBJFILES "${objfile_out}")
@@ -417,7 +419,7 @@ function (swift_benchmark_compile_archopts)
417419
SOURCE_DIR "${srcdir}"
418420
OBJECT_DIR "${objdir}"
419421
SOURCES ${${module_name}_sources}
420-
LIBRARY_FLAGS ${common_swift4_options} ${bench_flags}
422+
LIBRARY_FLAGS ${common_swift4_options} ${bench_flags} ${SWIFT_BENCHMARK_EXTRA_FLAGS}
421423
DEPENDS ${bench_library_objects} ${stdlib_dependencies})
422424
precondition(objfiles_out)
423425
list(APPEND SWIFT_BENCH_OBJFILES ${objfiles_out})

0 commit comments

Comments
 (0)