Skip to content

Commit da092bf

Browse files
committed
build: improve static library generation
Modern `ar` implementations support constructing the index table on the construction. This means that we dont need to re-read the contents and run a second program after the initial library construction to get current behaviour. This is a simplification of the generated build rules which improves performance since the data is not re-read nor a second tool invoked.
1 parent cf3fdff commit da092bf

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,19 @@ option(SWIFT_BUILD_SOURCEKIT
303303
"Build SourceKit"
304304
${SWIFT_BUILD_SOURCEKIT_default})
305305

306+
#
307+
# Assume a new enough ar to generate the index at construction time. This avois
308+
# having to invoke ranlib as a secondary command.
309+
#
310+
311+
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> crs <TARGET> <LINK_FLAGS> <OBJECTS>")
312+
set(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> qs <TARGET> <LINK_FLAGS> <OBJECTS>")
313+
set(CMAKE_C_ARCHIVE_FINISH "")
314+
315+
set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> crs <TARGET> <LINK_FLAGS> <OBJECTS>")
316+
set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> qs <TARGET> <LINK_FLAGS> <OBJECTS>")
317+
set(CMAKE_CXX_ARCHIVE_FINISH "")
318+
306319
#
307320
# Include CMake modules
308321
#

0 commit comments

Comments
 (0)