Skip to content

Commit 8e2b8bd

Browse files
author
Yi Ren
committed
followup fixes for llama example in Windows; add missing /WHOLEARCHIVE for executorch in Windows
1 parent d46f329 commit 8e2b8bd

File tree

3 files changed

+12
-20
lines changed

3 files changed

+12
-20
lines changed

examples/models/llama/CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ find_package(gflags REQUIRED)
8080
# find `executorch` libraries Same as for gflags
8181
set(executorch_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../../lib/cmake/ExecuTorch)
8282
find_package(executorch CONFIG REQUIRED)
83-
if(CMAKE_TOOLCHAIN_IOS OR ANDROID)
83+
if(CMAKE_TOOLCHAIN_IOS OR ANDROID OR WIN32 OR APPLE)
8484
target_link_options_shared_lib(executorch)
8585
endif()
8686

@@ -231,9 +231,6 @@ target_include_directories(llama_main PUBLIC ${_common_include_directories})
231231
target_link_libraries(llama_main PUBLIC llama_runner ${link_libraries})
232232
target_compile_options(llama_main PUBLIC ${_common_compile_options})
233233

234-
if(APPLE)
235-
target_link_options_shared_lib(executorch)
236-
endif()
237234

238235
# Print all summary
239236
executorch_print_configuration_summary()

examples/models/llama/runner/CMakeLists.txt

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ include(${EXECUTORCH_SRCS_FILE})
3636

3737
# build llama_runner library
3838
list(TRANSFORM _llama_runner__srcs PREPEND "${EXECUTORCH_ROOT}/")
39+
if (WIN32)
40+
set_property(TARGET extension_module PROPERTY
41+
IMPORTED_IMPLIB "${EXECUTORCH_ROOT}/cmake-out/lib/extension_module.lib")
42+
43+
endif()
3944

4045
target_include_directories(
4146
extension_module INTERFACE ${_common_include_directories}
@@ -52,7 +57,7 @@ list(APPEND _llama_runner__srcs
5257
if(CMAKE_TOOLCHAIN_IOS
5358
OR ANDROID
5459
OR APPLE
55-
OR WIN32
60+
OR WIN32
5661
)
5762
# Building a share library on iOS requires code signing On Android we see
5863
# duplicated registration when using shared lib
@@ -76,24 +81,13 @@ add_subdirectory(
7681
)
7782
set(CMAKE_POSITION_INDEPENDENT_CODE ${_pic_flag})
7883

79-
if (WIN32)
80-
# in Windows, only extension_module_static works and has duplicated symbols with extension_tensor
81-
set(llama_runner_deps executorch extension_data_loader extension_module_static
82-
re2::re2
83-
)
84-
# in Windows, need PUBLIC or sources files in executorch/examples/models/llama/runner/ cannot be found
85-
target_include_directories(
86-
llama_runner PUBLIC ${_common_include_directories} ${EXECUTORCH_ROOT}
87-
)
88-
else()
8984
set(llama_runner_deps executorch extension_data_loader extension_module
9085
extension_tensor re2::re2
9186
)
92-
target_include_directories(
93-
llama_runner INTERFACE ${_common_include_directories} ${EXECUTORCH_ROOT}
94-
)
95-
endif()
9687

9788
target_link_libraries(llama_runner PUBLIC ${llama_runner_deps})
9889

99-
target_compile_options(llama_runner PUBLIC ${_preprocessor_flag})
90+
target_include_directories(
91+
llama_runner INTERFACE ${_common_include_directories} ${EXECUTORCH_ROOT}
92+
)
93+
target_compile_options(llama_runner PUBLIC ${_preprocessor_flag})

extension/module/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ list(TRANSFORM _extension_module__srcs PREPEND "${EXECUTORCH_ROOT}/")
2020
if(CMAKE_TOOLCHAIN_IOS
2121
OR CMAKE_TOOLCHAIN_ANDROID
2222
OR APPLE
23+
OR WIN32
2324
)
2425
# Building a share library on iOS requires code signing On Android we see
2526
# duplicated registration when using shared lib

0 commit comments

Comments
 (0)