Skip to content

Commit c41538d

Browse files
committed
Add a section-ordering script
I think this lets us specify that certain functions should be put together at the end of the text segment. This is inspired by a similar feature of HHVM's build, though the goal for us for now is just to improve performance consistency rather than overall performance. Hopefully soon/eventually we can do profile-guided sorting like they do. Some of the performance changes here are very dramatic and I can't explain them. No wonder performance debugging is hard when link ordering could easily produce +-20% changes.
1 parent c4c58d0 commit c41538d

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,11 @@ if(ENABLE_GOLD)
4545
message(STATUS "found the gold linker ${GOLD_LINKER}")
4646
set(CMAKE_LINKER "${GOLD_LINKER}")
4747
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -B${CMAKE_SOURCE_DIR}/tools/build_system")
48+
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -Wl,--section-ordering-file,${CMAKE_CURRENT_SOURCE_DIR}/section_ordering.txt")
4849
endif()
4950
endif()
5051

52+
5153
# pyston self host mode
5254
if(ENABLE_SELF_HOST)
5355
set(PYTHON_EXE "pyston")
@@ -215,7 +217,11 @@ add_subdirectory(test/test_extension)
215217
add_subdirectory(test/unittests)
216218
add_subdirectory(tools)
217219

218-
add_executable(pyston $<TARGET_OBJECTS:PYSTON_MAIN_OBJECT> $<TARGET_OBJECTS:PYSTON_OBJECTS> $<TARGET_OBJECTS:FROM_CPYTHON>)
220+
# There are supposed to be better ways [1] to add link dependencies, but none of them worked for me.
221+
# [1] http://www.cmake.org/pipermail/cmake/2010-May/037206.html
222+
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/linkdeps_dummy.c COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_BINARY_DIR}/linkdeps_dummy.c DEPENDS ${CMAKE_SOURCE_DIR}/section_ordering.txt)
223+
224+
add_executable(pyston $<TARGET_OBJECTS:PYSTON_MAIN_OBJECT> $<TARGET_OBJECTS:PYSTON_OBJECTS> $<TARGET_OBJECTS:FROM_CPYTHON> linkdeps_dummy.c)
219225
# Wrap the stdlib in --whole-archive to force all the symbols to be included and eventually exported
220226
target_link_libraries(pyston -Wl,--whole-archive stdlib -Wl,--no-whole-archive pthread m readline sqlite3 gmp ssl crypto unwind pypa liblz4 double-conversion ${LLVM_LIBS} ${LIBLZMA_LIBRARIES} ${OPTIONAL_LIBRARIES})
221227

section_ordering.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.text.intLtInt
2+
.text.div_i64_i64
3+
.text.boxInt
4+
.text._ZN6pyston2gc10SmallArena6_allocEmi
5+
.text._ZNSt17_Function_handlerIFvPN6pyston2gc10SmallArena16ThreadBlockCacheEEZNS2_12freeUnmarkedERSt6vectorIPNS0_3BoxESaIS8_EEE3$_0E9_M_invokeERKSt9_Any_dataS4_

0 commit comments

Comments
 (0)