@@ -166,7 +166,7 @@ macro(configure_sdks)
166
166
endif ()
167
167
endmacro ()
168
168
169
- function (add_swift_benchmark_library objfile_out sibfile_out )
169
+ function (add_swift_benchmark_library objfile_out sibfile_out swiftmodule_out )
170
170
cmake_parse_arguments (BENCHLIB "" "MODULE_PATH;SOURCE_DIR;OBJECT_DIR" "SOURCES;LIBRARY_FLAGS;DEPENDS" ${ARGN} )
171
171
172
172
precondition (BENCHLIB_MODULE_PATH )
@@ -197,6 +197,7 @@ function (add_swift_benchmark_library objfile_out sibfile_out)
197
197
"-o" "${objfile} "
198
198
${sources} )
199
199
set (${objfile_out} "${objfile} " PARENT_SCOPE )
200
+ set (${swiftmodule_out} "${swiftmodule} " PARENT_SCOPE )
200
201
201
202
if (SWIFT_BENCHMARK_EMIT_SIB )
202
203
precondition (sibfile_out )
@@ -401,19 +402,21 @@ function (swift_benchmark_compile_archopts)
401
402
endif ()
402
403
set (bench_library_objects )
403
404
set (bench_library_sibfiles )
405
+ set (bench_library_swiftmodules )
404
406
set (opt_view_dirs )
405
407
# Build libraries used by the driver and benchmarks.
406
408
foreach (module_name_path ${BENCH_LIBRARY_MODULES} )
407
409
set (sources "${srcdir} /${module_name_path} .swift" )
408
410
409
- add_swift_benchmark_library (objfile_out sibfile_out
411
+ add_swift_benchmark_library (objfile_out sibfile_out swiftmodule_out
410
412
MODULE_PATH "${module_name_path} "
411
413
SOURCE_DIR "${srcdir} "
412
414
OBJECT_DIR "${objdir} "
413
415
SOURCES ${sources}
414
416
LIBRARY_FLAGS ${common_swift4_options} )
415
417
precondition (objfile_out )
416
418
list (APPEND bench_library_objects "${objfile_out} " )
419
+ list (APPEND bench_library_swiftmodules "${swiftmodule_out} " )
417
420
if (SWIFT_BENCHMARK_EMIT_SIB )
418
421
precondition (sibfile_out )
419
422
list (APPEND bench_library_sibfiles "${sibfile_out} " )
@@ -433,7 +436,7 @@ function (swift_benchmark_compile_archopts)
433
436
434
437
set (objfile_out )
435
438
set (sibfile_out )
436
- add_swift_benchmark_library (objfile_out sibfile_out
439
+ add_swift_benchmark_library (objfile_out sibfile_out swiftmodule_out
437
440
MODULE_PATH "${module_name_path} "
438
441
SOURCE_DIR "${srcdir} "
439
442
OBJECT_DIR "${objdir} "
@@ -442,6 +445,7 @@ function (swift_benchmark_compile_archopts)
442
445
DEPENDS ${bench_library_objects} )
443
446
precondition (objfile_out )
444
447
list (APPEND bench_driver_objects "${objfile_out} " )
448
+ list (APPEND bench_library_swiftmodules "${swiftmodule_out} " )
445
449
if (SWIFT_BENCHMARK_EMIT_SIB )
446
450
precondition (sibfile_out )
447
451
list (APPEND bench_driver_sibfiles "${sibfile_out} " )
@@ -464,6 +468,7 @@ function (swift_benchmark_compile_archopts)
464
468
set (swiftmodule "${objdir} /${module_name} .swiftmodule" )
465
469
set (source "${srcdir} /${module_name_path} .swift" )
466
470
list (APPEND SWIFT_BENCH_OBJFILES "${objfile} " )
471
+ list (APPEND bench_library_swiftmodules "${swiftmodule} " )
467
472
468
473
if ("${bench_flags} " MATCHES "-whole-module.*" )
469
474
set (output_option "-o" "${objfile} " )
@@ -622,6 +627,15 @@ function (swift_benchmark_compile_archopts)
622
627
else ()
623
628
set (SWIFT_LINK_RPATH "${SWIFT_RPATH_BASE} /${BENCH_COMPILE_ARCHOPTS_PLATFORM} " )
624
629
endif ()
630
+
631
+ # On Darwin, we pass the *.swiftmodule paths transitively referenced by the
632
+ # driver executable to ld64. ld64 inserts N_AST references to these modules
633
+ # into the program, for later use by lldb.
634
+ set (ld64_add_ast_path_opts )
635
+ foreach (ast_path ${bench_library_swiftmodules} )
636
+ list (APPEND ld64_add_ast_path_opts "-Wl,-add_ast_path,${ast_path} " )
637
+ endforeach ()
638
+
625
639
add_custom_command (
626
640
OUTPUT "${OUTPUT_EXEC} "
627
641
DEPENDS
@@ -647,6 +661,7 @@ function (swift_benchmark_compile_archopts)
647
661
"-Xlinker" "${SWIFT_LINK_RPATH} "
648
662
${bench_library_objects}
649
663
${bench_driver_objects}
664
+ ${ld64_add_ast_path_opts}
650
665
${SWIFT_BENCH_OBJFILES}
651
666
${objcfile}
652
667
"-o" "${OUTPUT_EXEC} "
0 commit comments