Skip to content

Commit 5d5c6c0

Browse files
authored
Attempt to fix finding libedit on macOS (#609)
First pass at trying to fix this...
1 parent 015c849 commit 5d5c6c0

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

cmake/wasi-sdk-toolchain.cmake

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ if(WASI_SDK_LLDB)
113113
include(ProcessorCount)
114114
ProcessorCount(nproc)
115115
find_program(MAKE_EXECUTABLE make REQUIRED)
116+
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
117+
set(libedit_ldflags -Wl,-install_name,@rpath/libedit.0.dylib)
118+
endif()
116119
ExternalProject_Add(libedit
117120
URL https://thrysoee.dk/editline/libedit-20251016-3.1.tar.gz
118121
URL_HASH SHA256=21362b00653bbfc1c71f71a7578da66b5b5203559d43134d2dd7719e313ce041
@@ -127,8 +130,7 @@ if(WASI_SDK_LLDB)
127130
--enable-pic
128131
--disable-examples
129132
CC=${CMAKE_C_COMPILER}
130-
CFLAGS=${libedit_cflags}
131-
LDFLAGS=${libedit_cflags}
133+
LDFLAGS=${libedit_ldflags}
132134
BUILD_COMMAND
133135
${MAKE_EXECUTABLE} -j${nproc} V=1
134136

@@ -169,6 +171,9 @@ ExternalProject_Add(llvm-build
169171
# Pass `-s` to strip symbols by default and shrink the size of the
170172
# distribution
171173
-DCMAKE_EXE_LINKER_FLAGS=-s
174+
# Looks to be required on macOS for, at build time, the dynamic linker to
175+
# find `libedit.dylib` when that's enabled.
176+
-DCMAKE_BUILD_RPATH=${wasi_tmp_install}/lib
172177
${llvm_cmake_flags_list}
173178
# See https://www.scivision.dev/cmake-externalproject-list-arguments/ for
174179
# why this is in `CMAKE_CACHE_ARGS` instead of above

0 commit comments

Comments
 (0)