Skip to content

Commit eb0c47b

Browse files
mszabo-wikiaGitHub Enterprise
authored andcommitted
WIN-4497 | Link libunwind after folly (facebook#111)
Since facebook#97, we have been building folly with symbolizer enabled, which causes it to depend on libunwind. However, we're now getting linking errors when building with `ENABLE_HARDENING` introduced in facebook#107: ``` 2025-10-13T18:33:00.3310227Z [ 98%] Linking CXX executable hhvm 2025-10-13T18:33:00.3391658Z Generating Repo Schema ID and Compiler ID 2025-10-13T18:33:39.5696188Z Precompiling systemlib files 2025-10-13T18:33:39.5980808Z ./hhvm: symbol lookup error: ./hhvm: undefined symbol: unw_getcontext ``` My hunch is that this happens because we're linking against libunwind rather than LLVM libunwind in our internal build, libunwind is added to the link line before the folly staticlib, which doesn't work with `-z,relro,-z,now` set by the hardened build. I don't get this issue when building locally with LLVM libunwind, which doesn't cause libunwind to be explicitly added to the link line at all. So, link libunwind after folly.
1 parent 8955716 commit eb0c47b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

CMake/HPHPFindLibs.cmake

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,10 +347,6 @@ macro(hphp_link target)
347347
target_link_libraries(${target} ${VISIBILITY} ${CURL_LIBRARIES})
348348
target_link_libraries(${target} ${VISIBILITY} glog)
349349

350-
if (LINUX)
351-
target_link_libraries(${target} ${VISIBILITY} ${LIBUNWIND_LIBRARIES} ${BPF_LIBRARIES})
352-
endif()
353-
354350
if (LIBINOTIFY_LIBRARY)
355351
target_link_libraries(${target} ${VISIBILITY} ${LIBINOTIFY_LIBRARY})
356352
endif()
@@ -436,6 +432,10 @@ macro(hphp_link target)
436432
target_link_libraries(${target} ${VISIBILITY} afdt)
437433
target_link_libraries(${target} ${VISIBILITY} mbfl)
438434

435+
if (LINUX)
436+
target_link_libraries(${target} ${VISIBILITY} ${LIBUNWIND_LIBRARIES} ${BPF_LIBRARIES})
437+
endif()
438+
439439
if (EDITLINE_LIBRARIES)
440440
target_link_libraries(${target} ${VISIBILITY} ${EDITLINE_LIBRARIES})
441441
elseif (READLINE_LIBRARY)

0 commit comments

Comments
 (0)