Skip to content

Commit b21ca49

Browse files
committed
Fix failure to build pony tools with Homebrew
Self-hosted tools like pony-lint, pony-lsp, and pony-doc pull in `use "lib:z"` via pony_compiler. When zlib lives outside the default system linker search paths (e.g. Homebrew), embedded LLD cannot resolve `-lz` while building those tools. Pass the resolved zlib library directory through the self-hosted ponyc invocations so those builds can find libz.
1 parent ea3c6b2 commit b21ca49

5 files changed

Lines changed: 22 additions & 4 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## Fix failure to build pony tools with Homebrew
2+
3+
When building ponyc from source with Homebrew, the self-hosted tools (pony-lint, pony-lsp, pony-doc) failed to link because the embedded LLD linker couldn't find zlib. Homebrew installs zlib outside the default system linker search paths, and while CMake resolved the correct location for linking ponyc itself, that path wasn't forwarded to the ponyc invocations that compile the tools.

CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,21 @@ if(NOT PONY_CROSS_LIBPONYRT)
224224
# message("PONYC_LLVM_LIBS: ${PONYC_LLVM_LIBS}")
225225
226226
set(PONYC_LLD_LIBS lldELF lldMachO lldCOFF lldWasm lldMinGW lldCommon)
227+
set(PONYC_SELFHOSTED_TOOL_PATH_ARGS "")
227228
228229
if(NOT MSVC)
229230
find_package(ZLIB REQUIRED)
230231
set(PONYC_EXTRA_LIBS ZLIB::ZLIB)
232+
233+
# Self-hosted Pony tools use `use "lib:z"` via pony_compiler. Pass the
234+
# resolved zlib libdir so embedded LLD can find non-system installs.
235+
foreach(PONYC_ZLIB_LIBRARY IN LISTS ZLIB_LIBRARIES)
236+
if(IS_ABSOLUTE "${PONYC_ZLIB_LIBRARY}")
237+
get_filename_component(PONYC_ZLIB_LIBRARY_DIR "${PONYC_ZLIB_LIBRARY}" DIRECTORY)
238+
list(APPEND PONYC_SELFHOSTED_TOOL_PATH_ARGS "--path" "${PONYC_ZLIB_LIBRARY_DIR}")
239+
break()
240+
endif()
241+
endforeach()
231242
endif()
232243
endif()
233244

tools/pony-doc/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ add_dependencies(tools.pony-doc libponyc-standalone)
1616

1717
file(GLOB_RECURSE DOC_SOURCES CONFIGURE_DEPENDS "*.pony")
1818
add_custom_command(OUTPUT ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PONY_DOC_EXECUTABLE}
19+
COMMAND_EXPAND_LISTS
1920
COMMAND echo "Building pony-doc..."
20-
COMMAND $<TARGET_FILE:ponyc> ${PONY_CPU_FLAG} --path ${CMAKE_CURRENT_SOURCE_DIR} --path ${CMAKE_CURRENT_SOURCE_DIR}/../lib/ponylang/pony_compiler/ -o ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${CMAKE_CURRENT_SOURCE_DIR}
21+
COMMAND $<TARGET_FILE:ponyc> ${PONY_CPU_FLAG} --path ${CMAKE_CURRENT_SOURCE_DIR} --path ${CMAKE_CURRENT_SOURCE_DIR}/../lib/ponylang/pony_compiler/ ${PONYC_SELFHOSTED_TOOL_PATH_ARGS} -o ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${CMAKE_CURRENT_SOURCE_DIR}
2122
DEPENDS
2223
${DOC_SOURCES}
2324
$<TARGET_FILE:ponyc>
@@ -31,8 +32,9 @@ set(PONY_DOC_TEST_EXECUTABLE "pony-doc-tests${CMAKE_EXECUTABLE_SUFFIX}")
3132
add_custom_target(tools.pony-doc-tests DEPENDS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PONY_DOC_TEST_EXECUTABLE})
3233

3334
add_custom_command(OUTPUT ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PONY_DOC_TEST_EXECUTABLE}
35+
COMMAND_EXPAND_LISTS
3436
COMMAND echo "Building pony-doc-tests..."
35-
COMMAND $<TARGET_FILE:ponyc> --path ${CMAKE_CURRENT_SOURCE_DIR} --path ${CMAKE_CURRENT_SOURCE_DIR}/../lib/ponylang/pony_compiler/ -b ${PONY_DOC_TEST_EXECUTABLE} -o ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${CMAKE_CURRENT_SOURCE_DIR}/test
37+
COMMAND $<TARGET_FILE:ponyc> --path ${CMAKE_CURRENT_SOURCE_DIR} --path ${CMAKE_CURRENT_SOURCE_DIR}/../lib/ponylang/pony_compiler/ ${PONYC_SELFHOSTED_TOOL_PATH_ARGS} -b ${PONY_DOC_TEST_EXECUTABLE} -o ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${CMAKE_CURRENT_SOURCE_DIR}/test
3638
DEPENDS
3739
${DOC_SOURCES}
3840
$<TARGET_FILE:ponyc>

tools/pony-lint/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ add_dependencies(tools.pony-lint libponyc-standalone)
1616

1717
file(GLOB_RECURSE LINT_SOURCES CONFIGURE_DEPENDS "*.pony")
1818
add_custom_command(OUTPUT ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PONY_LINT_EXECUTABLE}
19+
COMMAND_EXPAND_LISTS
1920
COMMAND echo "Building pony-lint..."
20-
COMMAND $<TARGET_FILE:ponyc> ${PONY_CPU_FLAG} --path ${CMAKE_CURRENT_SOURCE_DIR} --path ${CMAKE_CURRENT_SOURCE_DIR}/../lib/ponylang/pony_compiler/ -o ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${CMAKE_CURRENT_SOURCE_DIR}
21+
COMMAND $<TARGET_FILE:ponyc> ${PONY_CPU_FLAG} --path ${CMAKE_CURRENT_SOURCE_DIR} --path ${CMAKE_CURRENT_SOURCE_DIR}/../lib/ponylang/pony_compiler/ ${PONYC_SELFHOSTED_TOOL_PATH_ARGS} -o ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${CMAKE_CURRENT_SOURCE_DIR}
2122
DEPENDS
2223
${LINT_SOURCES}
2324
$<TARGET_FILE:ponyc>

tools/pony-lsp/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ add_dependencies(tools.pony-lsp libponyc-standalone)
1717
# TODO STA: --path entries are temporary until a ponyc bug is fixed.
1818
file(GLOB_RECURSE LSP_SOURCES CONFIGURE_DEPENDS "*.pony")
1919
add_custom_command(OUTPUT ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PONY_LSP_EXECUTABLE}
20+
COMMAND_EXPAND_LISTS
2021
COMMAND echo "Building pony-lsp..."
21-
COMMAND $<TARGET_FILE:ponyc> ${PONY_CPU_FLAG} --path ${CMAKE_CURRENT_SOURCE_DIR} --path ${CMAKE_CURRENT_SOURCE_DIR}/../lib/ponylang/pony_compiler/ -o ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${CMAKE_CURRENT_SOURCE_DIR}
22+
COMMAND $<TARGET_FILE:ponyc> ${PONY_CPU_FLAG} --path ${CMAKE_CURRENT_SOURCE_DIR} --path ${CMAKE_CURRENT_SOURCE_DIR}/../lib/ponylang/pony_compiler/ ${PONYC_SELFHOSTED_TOOL_PATH_ARGS} -o ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${CMAKE_CURRENT_SOURCE_DIR}
2223
DEPENDS
2324
${LSP_SOURCES}
2425
$<TARGET_FILE:ponyc>

0 commit comments

Comments
 (0)