Skip to content

Commit fd26666

Browse files
GregoryComerfacebook-github-bot
authored andcommitted
Add static module extension target (#2904)
Summary: Add an module extension target always built as a static library. This is a hacky workaround to the fact that the llama runner currently relies on some fragile linking behavior and requires consuming the module extension as a static lib. However, the nanogpt_runner needs to consume it as a static lib to avoid duplicate primitive op registration. I'm not 100% clear on why llama runner doesn't hit this yet. Maybe something to do with the primitive op -> executorch -> llama_runner -> llama_main chain having a top level target that doesn't reference the core executorch dependency leading to it not being pulled in at the top level? Anyway, this new target will be removed once we refactor the CMake build post-alpha. Note that by adding a completely new target, this should cause no regressions and should be safe to land. Pull Request resolved: #2904 Test Plan: Internal + external CI. Built and ran nanogpt_runner on linux and mac linking against extension_module_static. Reviewed By: mikekgfb Differential Revision: D55834574 Pulled By: GregoryComer fbshipit-source-id: 4f340e133b9cdc8ef40f154342b396143d78e84f
1 parent 81a7e88 commit fd26666

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

extension/module/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ target_include_directories(extension_module PUBLIC ${EXECUTORCH_ROOT}/..)
2929
target_compile_options(extension_module PUBLIC -Wno-deprecated-declarations
3030
-fPIC)
3131

32+
# Module extension built as a static library.
33+
# TODO(gjcomer) Remove this target after cleaning up CMake targets.
34+
add_library(extension_module_static STATIC ${_extension_module__srcs})
35+
target_link_libraries(extension_module_static PRIVATE executorch extension_data_loader)
36+
target_include_directories(extension_module_static PUBLIC ${EXECUTORCH_ROOT}/..)
37+
target_compile_options(extension_module_static PUBLIC -Wno-deprecated-declarations
38+
-fPIC)
39+
3240
# Install libraries
3341
install(
3442
TARGETS extension_module

0 commit comments

Comments
 (0)