mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
benchmark: Build drivers with N_AST symtab entries (for debugging) (#30777)
On Darwin, we pass the *.swiftmodule paths transitively referenced by the driver executable to ld64. ld64 inserts N_AST references to these modules into the program, for later use by lldb. This change should let us exercise much more lldb functionality via `stepper` testing.
This commit is contained in:
@@ -166,7 +166,7 @@ macro(configure_sdks)
|
|||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
function (add_swift_benchmark_library objfile_out sibfile_out)
|
function (add_swift_benchmark_library objfile_out sibfile_out swiftmodule_out)
|
||||||
cmake_parse_arguments(BENCHLIB "" "MODULE_PATH;SOURCE_DIR;OBJECT_DIR" "SOURCES;LIBRARY_FLAGS;DEPENDS" ${ARGN})
|
cmake_parse_arguments(BENCHLIB "" "MODULE_PATH;SOURCE_DIR;OBJECT_DIR" "SOURCES;LIBRARY_FLAGS;DEPENDS" ${ARGN})
|
||||||
|
|
||||||
precondition(BENCHLIB_MODULE_PATH)
|
precondition(BENCHLIB_MODULE_PATH)
|
||||||
@@ -197,6 +197,7 @@ function (add_swift_benchmark_library objfile_out sibfile_out)
|
|||||||
"-o" "${objfile}"
|
"-o" "${objfile}"
|
||||||
${sources})
|
${sources})
|
||||||
set(${objfile_out} "${objfile}" PARENT_SCOPE)
|
set(${objfile_out} "${objfile}" PARENT_SCOPE)
|
||||||
|
set(${swiftmodule_out} "${swiftmodule}" PARENT_SCOPE)
|
||||||
|
|
||||||
if(SWIFT_BENCHMARK_EMIT_SIB)
|
if(SWIFT_BENCHMARK_EMIT_SIB)
|
||||||
precondition(sibfile_out)
|
precondition(sibfile_out)
|
||||||
@@ -401,12 +402,13 @@ function (swift_benchmark_compile_archopts)
|
|||||||
endif()
|
endif()
|
||||||
set(bench_library_objects)
|
set(bench_library_objects)
|
||||||
set(bench_library_sibfiles)
|
set(bench_library_sibfiles)
|
||||||
|
set(bench_library_swiftmodules)
|
||||||
set(opt_view_dirs)
|
set(opt_view_dirs)
|
||||||
# Build libraries used by the driver and benchmarks.
|
# Build libraries used by the driver and benchmarks.
|
||||||
foreach(module_name_path ${BENCH_LIBRARY_MODULES})
|
foreach(module_name_path ${BENCH_LIBRARY_MODULES})
|
||||||
set(sources "${srcdir}/${module_name_path}.swift")
|
set(sources "${srcdir}/${module_name_path}.swift")
|
||||||
|
|
||||||
add_swift_benchmark_library(objfile_out sibfile_out
|
add_swift_benchmark_library(objfile_out sibfile_out swiftmodule_out
|
||||||
MODULE_PATH "${module_name_path}"
|
MODULE_PATH "${module_name_path}"
|
||||||
SOURCE_DIR "${srcdir}"
|
SOURCE_DIR "${srcdir}"
|
||||||
OBJECT_DIR "${objdir}"
|
OBJECT_DIR "${objdir}"
|
||||||
@@ -414,6 +416,7 @@ function (swift_benchmark_compile_archopts)
|
|||||||
LIBRARY_FLAGS ${common_swift4_options})
|
LIBRARY_FLAGS ${common_swift4_options})
|
||||||
precondition(objfile_out)
|
precondition(objfile_out)
|
||||||
list(APPEND bench_library_objects "${objfile_out}")
|
list(APPEND bench_library_objects "${objfile_out}")
|
||||||
|
list(APPEND bench_library_swiftmodules "${swiftmodule_out}")
|
||||||
if (SWIFT_BENCHMARK_EMIT_SIB)
|
if (SWIFT_BENCHMARK_EMIT_SIB)
|
||||||
precondition(sibfile_out)
|
precondition(sibfile_out)
|
||||||
list(APPEND bench_library_sibfiles "${sibfile_out}")
|
list(APPEND bench_library_sibfiles "${sibfile_out}")
|
||||||
@@ -433,7 +436,7 @@ function (swift_benchmark_compile_archopts)
|
|||||||
|
|
||||||
set(objfile_out)
|
set(objfile_out)
|
||||||
set(sibfile_out)
|
set(sibfile_out)
|
||||||
add_swift_benchmark_library(objfile_out sibfile_out
|
add_swift_benchmark_library(objfile_out sibfile_out swiftmodule_out
|
||||||
MODULE_PATH "${module_name_path}"
|
MODULE_PATH "${module_name_path}"
|
||||||
SOURCE_DIR "${srcdir}"
|
SOURCE_DIR "${srcdir}"
|
||||||
OBJECT_DIR "${objdir}"
|
OBJECT_DIR "${objdir}"
|
||||||
@@ -442,6 +445,7 @@ function (swift_benchmark_compile_archopts)
|
|||||||
DEPENDS ${bench_library_objects})
|
DEPENDS ${bench_library_objects})
|
||||||
precondition(objfile_out)
|
precondition(objfile_out)
|
||||||
list(APPEND bench_driver_objects "${objfile_out}")
|
list(APPEND bench_driver_objects "${objfile_out}")
|
||||||
|
list(APPEND bench_library_swiftmodules "${swiftmodule_out}")
|
||||||
if (SWIFT_BENCHMARK_EMIT_SIB)
|
if (SWIFT_BENCHMARK_EMIT_SIB)
|
||||||
precondition(sibfile_out)
|
precondition(sibfile_out)
|
||||||
list(APPEND bench_driver_sibfiles "${sibfile_out}")
|
list(APPEND bench_driver_sibfiles "${sibfile_out}")
|
||||||
@@ -464,6 +468,7 @@ function (swift_benchmark_compile_archopts)
|
|||||||
set(swiftmodule "${objdir}/${module_name}.swiftmodule")
|
set(swiftmodule "${objdir}/${module_name}.swiftmodule")
|
||||||
set(source "${srcdir}/${module_name_path}.swift")
|
set(source "${srcdir}/${module_name_path}.swift")
|
||||||
list(APPEND SWIFT_BENCH_OBJFILES "${objfile}")
|
list(APPEND SWIFT_BENCH_OBJFILES "${objfile}")
|
||||||
|
list(APPEND bench_library_swiftmodules "${swiftmodule}")
|
||||||
|
|
||||||
if ("${bench_flags}" MATCHES "-whole-module.*")
|
if ("${bench_flags}" MATCHES "-whole-module.*")
|
||||||
set(output_option "-o" "${objfile}")
|
set(output_option "-o" "${objfile}")
|
||||||
@@ -622,6 +627,15 @@ function (swift_benchmark_compile_archopts)
|
|||||||
else()
|
else()
|
||||||
set(SWIFT_LINK_RPATH "${SWIFT_RPATH_BASE}/${BENCH_COMPILE_ARCHOPTS_PLATFORM}")
|
set(SWIFT_LINK_RPATH "${SWIFT_RPATH_BASE}/${BENCH_COMPILE_ARCHOPTS_PLATFORM}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# On Darwin, we pass the *.swiftmodule paths transitively referenced by the
|
||||||
|
# driver executable to ld64. ld64 inserts N_AST references to these modules
|
||||||
|
# into the program, for later use by lldb.
|
||||||
|
set(ld64_add_ast_path_opts)
|
||||||
|
foreach(ast_path ${bench_library_swiftmodules})
|
||||||
|
list(APPEND ld64_add_ast_path_opts "-Wl,-add_ast_path,${ast_path}")
|
||||||
|
endforeach()
|
||||||
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT "${OUTPUT_EXEC}"
|
OUTPUT "${OUTPUT_EXEC}"
|
||||||
DEPENDS
|
DEPENDS
|
||||||
@@ -647,6 +661,7 @@ function (swift_benchmark_compile_archopts)
|
|||||||
"-Xlinker" "${SWIFT_LINK_RPATH}"
|
"-Xlinker" "${SWIFT_LINK_RPATH}"
|
||||||
${bench_library_objects}
|
${bench_library_objects}
|
||||||
${bench_driver_objects}
|
${bench_driver_objects}
|
||||||
|
${ld64_add_ast_path_opts}
|
||||||
${SWIFT_BENCH_OBJFILES}
|
${SWIFT_BENCH_OBJFILES}
|
||||||
${objcfile}
|
${objcfile}
|
||||||
"-o" "${OUTPUT_EXEC}"
|
"-o" "${OUTPUT_EXEC}"
|
||||||
|
|||||||
Reference in New Issue
Block a user