Skip to content

Commit 1a161c2

Browse files
committed
benchmarks: compile with the new -align-module-to-page-size option, if supported by the compiler
To stabilize the benchmark results.
1 parent aafb780 commit 1a161c2

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

benchmark/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ message("-- SWIFT_LIBRARY_PATH = ${SWIFT_LIBRARY_PATH}")
272272
message("-- CLANG_EXEC = ${CLANG_EXEC}")
273273
message("-- SWIFT_OPTIMIZATION_LEVELS = ${SWIFT_OPTIMIZATION_LEVELS}")
274274
message("-- ONLY_PLATFORMS = ${ONLY_PLATFORMS}")
275+
message("-- PAGE_ALIGNMENT_OPTION = ${PAGE_ALIGNMENT_OPTION}")
275276

276277
message("-- found platforms: ${platforms}")
277278
message("-- found sdks:")

benchmark/cmake/modules/AddSwiftBenchmarkSuite.cmake

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,19 @@ macro(configure_build)
4040
message(FATAL_ERROR "Unsupported platform?!")
4141
endif()
4242

43+
set(PAGE_ALIGNMENT_OPTION "-Xllvm" "-align-module-to-page-size")
44+
execute_process(
45+
COMMAND "touch" "empty.swift"
46+
RESULT_VARIABLE result
47+
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
48+
execute_process(
49+
COMMAND "${SWIFT_EXEC}" ${PAGE_ALIGNMENT_OPTION} "empty.swift"
50+
RESULT_VARIABLE result
51+
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
52+
if(NOT "${result}" MATCHES "0")
53+
set(PAGE_ALIGNMENT_OPTION "")
54+
endif()
55+
4356
# We always infer the SWIFT_LIBRARY_PATH from SWIFT_EXEC unless
4457
# SWIFT_LIBRARY_PATH is specified explicitly.
4558
if(NOT SWIFT_LIBRARY_PATH)
@@ -293,7 +306,7 @@ function (swift_benchmark_compile_archopts)
293306
set(common_options
294307
"-c"
295308
"-target" "${target}"
296-
"-${BENCH_COMPILE_ARCHOPTS_OPT}")
309+
"-${BENCH_COMPILE_ARCHOPTS_OPT}" ${PAGE_ALIGNMENT_OPTION})
297310

298311
if (is_darwin)
299312
list(APPEND common_options

0 commit comments

Comments
 (0)