Skip to content

Commit

Permalink
Add explicit symbol exports for Flashlight core (flashlight#1141)
Browse files Browse the repository at this point in the history
Summary:
Remove the need to export all symbols for MSVC-based builds, and explicitly export symbols throughout the Flashlight API. This removes the need to use `CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS` and makes Windows build sizes significantly smaller.

Subsequent exports for `pkg` and `app` will be added separately; this isn't being prioritized

Pull Request resolved: flashlight#1141

Test Plan:
local build + CI

----
:books: Documentation preview :books:: https://fl--1141.org.readthedocs.build/en/1141/

Reviewed By: bwasti

Differential Revision: D50092087

Pulled By: jacobkahn

fbshipit-source-id: 5b4f3aed8866353dc7c49172817b4e3e9e2321ff
  • Loading branch information
jacobkahn authored and facebook-github-bot committed Oct 10, 2023
1 parent 6653536 commit 385aafc
Show file tree
Hide file tree
Showing 109 changed files with 712 additions and 577 deletions.
3 changes: 1 addition & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,7 @@ commands:
-DFL_USE_ONEDNN=$([ "<< parameters.backend >>" == "onednn" ] || [ "<< parameters.autograd_backend >>" == "onednn" ] && echo "ON" || echo "OFF") \
-DFL_USE_NCCL=$(([ "<< parameters.platform >>" == "linux" ] || [ "<< parameters.platform >>" == "windows" ]) && [ "<< parameters.distributed_backend >>" == "nccl" ] && echo "ON" || echo "OFF") \
-DFL_USE_GLOO=OFF \
-DFL_USE_BACKWARD_CPP=ON \
-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON
-DFL_USE_BACKWARD_CPP=ON
cmake --build build --parallel << parameters.build_parallelism >>
test-flashlight:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ jobs:
-DFL_USE_TENSOR_STUB=${{ matrix.backend == 'Stub' && 'ON' || 'OFF' }} \
-DFL_USE_NCCL=OFF \
-DFL_USE_GLOO=${{ matrix.distributed_backend == 'Gloo' && 'ON' || 'OFF' }} \
-DFL_USE_BACKWARD_CPP=ON \
-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON
-DFL_USE_BACKWARD_CPP=ON
- name: "Build Flashlight"
run: |
cmake --build build --parallel 2
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ target_compile_definitions(flashlight
FL_BACKEND_CPU=$<BOOL:${FL_USE_CPU}>
FL_BACKEND_CUDA=$<BOOL:${FL_USE_CUDA}>
FL_BUILD_PROFILING=$<BOOL:${FL_BUILD_PROFILING}>
FL_COMPILE_LIBRARY=$<BOOL:${BUILD_SHARED_LIBS}>
PRIVATE
FL_DLL
)

if (FL_CODE_COVERAGE)
Expand Down
4 changes: 4 additions & 0 deletions flashlight/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ function(register_app)
)

if(${_option_name})
if (MSVC)
message(FATAL_ERROR "Building fl packages (pkg) with MSVC not yet supported")
endif()

message(STATUS "Building Flashlight ${_app_name_lower} package.")
include(${FL_APPS_DIR}/${_app_name_lower}/CMakeLists.txt)
endif()
Expand Down
Loading

0 comments on commit 385aafc

Please sign in to comment.