Skip to content

Commit d4ece4b

Browse files
committed
[benchmark] Correctly depend on stdlib targets
1 parent 8aa4dad commit d4ece4b

File tree

6 files changed

+61
-36
lines changed

6 files changed

+61
-36
lines changed

benchmark/CMakeLists.txt

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -194,18 +194,27 @@ endforeach()
194194

195195
set(executable_targets)
196196

197-
set(srcdir "${CMAKE_CURRENT_SOURCE_DIR}")
198-
set(bindir "${CMAKE_CURRENT_BINARY_DIR}/bin")
199-
set(libdir "${CMAKE_CURRENT_BINARY_DIR}/lib")
200-
set(libswiftdir "${CMAKE_CURRENT_BINARY_DIR}/lib/swift")
201-
file(MAKE_DIRECTORY "${bindir}")
202-
file(MAKE_DIRECTORY "${libdir}")
203-
file(MAKE_DIRECTORY "${libswiftdir}")
204-
205197
if(SWIFT_SDKS)
206198
set(IS_SWIFT_BUILD true)
207199
endif()
208200

201+
set(srcdir "${CMAKE_CURRENT_SOURCE_DIR}")
202+
203+
if(IS_SWIFT_BUILD)
204+
get_filename_component(swift-bin-dir "${SWIFT_EXEC}" DIRECTORY)
205+
else()
206+
set(swift-bin-dir "${CMAKE_BINARY_DIR}/bin")
207+
endif()
208+
209+
set(benchmark-bin-dir "${CMAKE_CURRENT_BINARY_DIR}/bin")
210+
set(benchmark-lib-dir "${CMAKE_CURRENT_BINARY_DIR}/lib")
211+
set(benchmark-lib-swift-dir "${CMAKE_CURRENT_BINARY_DIR}/lib/swift")
212+
213+
file(MAKE_DIRECTORY "${swift-bin-dir}")
214+
file(MAKE_DIRECTORY "${benchmark-bin-dir}")
215+
file(MAKE_DIRECTORY "${benchmark-lib-dir}")
216+
file(MAKE_DIRECTORY "${benchmark-lib-swift-dir}")
217+
209218
# Compile the perf test suite for each platform
210219
foreach(platform ${platforms})
211220
swift_benchmark_compile(PLATFORM ${platform})

benchmark/cmake/modules/AddSwiftBenchmarkSuite.cmake

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,9 @@ function (swift_benchmark_compile_archopts)
274274
list(APPEND SWIFT_BENCH_OBJFILES "${objdir}/${module_name}.o")
275275

276276
if("${BENCH_COMPILE_ARCHOPTS_PLATFORM}" STREQUAL "macosx")
277-
set(OUTPUT_EXEC "${bindir}/Benchmark_${BENCH_COMPILE_ARCHOPTS_OPT}")
277+
set(OUTPUT_EXEC "${benchmark-bin-dir}/Benchmark_${BENCH_COMPILE_ARCHOPTS_OPT}")
278278
else()
279-
set(OUTPUT_EXEC "${bindir}/Benchmark_${BENCH_COMPILE_ARCHOPTS_OPT}-${target}")
279+
set(OUTPUT_EXEC "${benchmark-bin-dir}/Benchmark_${BENCH_COMPILE_ARCHOPTS_OPT}-${target}")
280280
endif()
281281

282282
add_custom_command(
@@ -312,23 +312,29 @@ endfunction()
312312

313313
function(swift_benchmark_compile)
314314
cmake_parse_arguments(SWIFT_BENCHMARK_COMPILE "" "PLATFORM" "" ${ARGN})
315+
315316
if(IS_SWIFT_BUILD)
316-
set(stdlib_dependencies "swift"
317-
${UNIVERSAL_LIBRARY_NAMES_${SWIFT_BENCHMARK_COMPILE_PLATFORM}})
317+
set(stdlib_dependencies "swift")
318+
foreach(stdlib_dependency ${UNIVERSAL_LIBRARY_NAMES_${SWIFT_BENCHMARK_COMPILE_PLATFORM}})
319+
string(FIND "${stdlib_dependency}" "Unittest" find_output)
320+
if("${find_output}" STREQUAL "-1")
321+
list(APPEND stdlib_dependencies "${stdlib_dependency}")
322+
endif()
323+
endforeach()
318324
endif()
319325

320326
add_custom_target("copy-swift-stdlib-${SWIFT_BENCHMARK_COMPILE_PLATFORM}"
321327
DEPENDS ${stdlib_dependencies}
322328
COMMAND
323329
"${CMAKE_COMMAND}" "-E" "copy_directory"
324330
"${SWIFT_LIBRARY_PATH}/${SWIFT_BENCHMARK_COMPILE_PLATFORM}"
325-
"${libswiftdir}/${SWIFT_BENCHMARK_COMPILE_PLATFORM}")
331+
"${benchmark-lib-swift-dir}/${SWIFT_BENCHMARK_COMPILE_PLATFORM}")
326332

327333
add_custom_target("adhoc-sign-swift-stdlib-${SWIFT_BENCHMARK_COMPILE_PLATFORM}"
328334
DEPENDS "copy-swift-stdlib-${SWIFT_BENCHMARK_COMPILE_PLATFORM}"
329335
COMMAND
330336
"codesign" "-f" "-s" "-"
331-
"${libswiftdir}/${SWIFT_BENCHMARK_COMPILE_PLATFORM}/*.dylib" "2>/dev/null")
337+
"${benchmark-lib-swift-dir}/${SWIFT_BENCHMARK_COMPILE_PLATFORM}/*.dylib" "2>/dev/null")
332338

333339
set(platform_executables)
334340
foreach(arch ${${SWIFT_BENCHMARK_COMPILE_PLATFORM}_arch})
@@ -351,18 +357,18 @@ function(swift_benchmark_compile)
351357
TARGET "${executable_target}"
352358
POST_BUILD
353359
COMMAND
354-
"mv" ${platform_executables} "${SWIFT_RUNTIME_OUTPUT_INTDIR}")
360+
"mv" ${platform_executables} "${swift-bin-dir}")
355361

356362
add_custom_target("check-${executable_target}"
357-
COMMAND "${SWIFT_RUNTIME_OUTPUT_INTDIR}/Benchmark_Driver" "run"
363+
COMMAND "${swift-bin-dir}/Benchmark_Driver" "run"
358364
"-o" "O" "--output-dir" "${CMAKE_CURRENT_BINARY_DIR}/logs"
359365
"--swift-repo" "${SWIFT_SOURCE_DIR}"
360366
"--iterations" "3"
361-
COMMAND "${SWIFT_RUNTIME_OUTPUT_INTDIR}/Benchmark_Driver" "run"
367+
COMMAND "${swift-bin-dir}/Benchmark_Driver" "run"
362368
"-o" "Onone" "--output-dir" "${CMAKE_CURRENT_BINARY_DIR}/logs"
363369
"--swift-repo" "${SWIFT_SOURCE_DIR}"
364370
"--iterations" "3"
365-
COMMAND "${SWIFT_RUNTIME_OUTPUT_INTDIR}/Benchmark_Driver" "compare"
371+
COMMAND "${swift-bin-dir}/Benchmark_Driver" "compare"
366372
"--log-dir" "${CMAKE_CURRENT_BINARY_DIR}/logs"
367373
"--swift-repo" "${SWIFT_SOURCE_DIR}"
368374
"--compare-script"

benchmark/scripts/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,21 @@ configure_file(
1515
set(PATH_TO_DRIVER_LIBRARY)
1616

1717
file(COPY ${CMAKE_CURRENT_BINARY_DIR}/Benchmark_GuardMalloc
18-
DESTINATION ${CMAKE_BINARY_DIR}/bin
18+
DESTINATION "${swift-bin-dir}"
1919
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ
2020
GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
2121

2222
file(COPY ${CMAKE_CURRENT_BINARY_DIR}/Benchmark_RuntimeLeaksRunner
23-
DESTINATION ${CMAKE_BINARY_DIR}/bin
23+
DESTINATION "${swift-bin-dir}"
2424
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ
2525
GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
2626

2727
file(COPY ${CMAKE_CURRENT_BINARY_DIR}/Benchmark_DTrace
28-
DESTINATION ${CMAKE_BINARY_DIR}/bin
28+
DESTINATION "${swift-bin-dir}"
2929
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ
3030
GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
3131

3232
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/Benchmark_Driver
33-
DESTINATION ${CMAKE_BINARY_DIR}/bin
33+
DESTINATION "${swift-bin-dir}"
3434
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ
3535
GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)

benchmark/scripts/generate_harness/CMakeLists.txt_template

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,18 +137,27 @@ endforeach()
137137

138138
set(executable_targets)
139139

140-
set(srcdir "${CMAKE_CURRENT_SOURCE_DIR}")
141-
set(bindir "${CMAKE_CURRENT_BINARY_DIR}/bin")
142-
set(libdir "${CMAKE_CURRENT_BINARY_DIR}/lib")
143-
set(libswiftdir "${CMAKE_CURRENT_BINARY_DIR}/lib/swift")
144-
file(MAKE_DIRECTORY "${bindir}")
145-
file(MAKE_DIRECTORY "${libdir}")
146-
file(MAKE_DIRECTORY "${libswiftdir}")
147-
148140
if(SWIFT_SDKS)
149141
set(IS_SWIFT_BUILD true)
150142
endif()
151143

144+
set(srcdir "${CMAKE_CURRENT_SOURCE_DIR}")
145+
146+
if(IS_SWIFT_BUILD)
147+
get_filename_component(swift-bin-dir "${SWIFT_EXEC}" DIRECTORY)
148+
else()
149+
set(swift-bin-dir "${CMAKE_BINARY_DIR}/bin")
150+
endif()
151+
152+
set(benchmark-bin-dir "${CMAKE_CURRENT_BINARY_DIR}/bin")
153+
set(benchmark-lib-dir "${CMAKE_CURRENT_BINARY_DIR}/lib")
154+
set(benchmark-lib-swift-dir "${CMAKE_CURRENT_BINARY_DIR}/lib/swift")
155+
156+
file(MAKE_DIRECTORY "${swift-bin-dir}")
157+
file(MAKE_DIRECTORY "${benchmark-bin-dir}")
158+
file(MAKE_DIRECTORY "${benchmark-lib-dir}")
159+
file(MAKE_DIRECTORY "${benchmark-lib-swift-dir}")
160+
152161
# Compile the perf test suite for each platform
153162
foreach(platform ${platforms})
154163
swift_benchmark_compile(PLATFORM ${platform})

cmake/modules/AddSwift.cmake

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,18 +1479,19 @@ function(add_swift_library name)
14791479
"${SWIFTLIB_DIR}/${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}${name}${CMAKE_STATIC_LIBRARY_SUFFIX}")
14801480
endif()
14811481

1482-
# Cache universal libraries for dependency purposes
1483-
set(UNIVERSAL_LIBRARY_NAMES_${SWIFT_SDK_${sdk}_LIB_SUBDIR}
1484-
${UNIVERSAL_LIBRARY_NAMES_${SWIFT_SDK_${sdk}_LIB_SUBDIR}}
1485-
${UNIVERSAL_LIBRARY_NAME}
1486-
CACHE INTERNAL "UNIVERSAL_LIBRARY_NAMES_${SWIFT_SDK_${sdk}_LIB_SUBDIR}")
14871482

14881483
set(lipo_target "${name}-${SWIFT_SDK_${sdk}_LIB_SUBDIR}")
14891484
_add_swift_lipo_target(
14901485
${lipo_target}
14911486
"${UNIVERSAL_LIBRARY_NAME}"
14921487
${THIN_INPUT_TARGETS})
14931488

1489+
# Cache universal libraries for dependency purposes
1490+
set(UNIVERSAL_LIBRARY_NAMES_${SWIFT_SDK_${sdk}_LIB_SUBDIR}
1491+
${UNIVERSAL_LIBRARY_NAMES_${SWIFT_SDK_${sdk}_LIB_SUBDIR}}
1492+
${lipo_target}
1493+
CACHE INTERNAL "UNIVERSAL_LIBRARY_NAMES_${SWIFT_SDK_${sdk}_LIB_SUBDIR}")
1494+
14941495
# Determine the subdirectory where this library will be installed.
14951496
set(resource_dir_sdk_subdir "${SWIFT_SDK_${sdk}_LIB_SUBDIR}")
14961497

utils/build-script-impl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1675,7 +1675,7 @@ for deployment_target in "${HOST_TARGET}" "${CROSS_TOOLS_DEPLOYMENT_TARGETS[@]}"
16751675

16761676
build_targets=(all "${SWIFT_STDLIB_TARGETS[@]}")
16771677
if [[ $(true_false "${build_perf_testsuite_this_time}") == "TRUE" ]]; then
1678-
native_swift_tools_path=$(build_directory macosx-x86_64 swift)/bin
1678+
native_swift_tools_path="$(build_directory_bin macosx-x86_64 swift)"
16791679
cmake_options=(
16801680
"${cmake_options[@]}"
16811681
-DSWIFT_EXEC:STRING="${native_swift_tools_path}/swiftc"

0 commit comments

Comments
 (0)