Skip to content

Enable EXPORT_ALL_SYMBOLS for CMAKE#3617

Merged
soumith merged 4 commits intopytorch:masterfrom
peterjc123:script_fix
Nov 10, 2017
Merged

Enable EXPORT_ALL_SYMBOLS for CMAKE#3617
soumith merged 4 commits intopytorch:masterfrom
peterjc123:script_fix

Conversation

@peterjc123
Copy link
Collaborator

If we turn on CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS flag, we don't need to add most decorators by hand.

If we turn on CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS flag, we don't need to add most decorators by hand.
@pytorchbot
Copy link
Collaborator

@peterjc123, thanks for your PR! We identified @zdevito to be a potential reviewer.

@aluo-x
Copy link

aluo-x commented Nov 10, 2017

We can attempt a Windows build w/ CUDA 9 once this issue gets merged.

@soumith soumith merged commit 0483304 into pytorch:master Nov 10, 2017
@soumith
Copy link
Collaborator

soumith commented Nov 10, 2017

merged!

@aluo-x
Copy link

aluo-x commented Nov 10, 2017

Thanks a ton @soumith, @peterjc123.

@peterjc123 peterjc123 deleted the script_fix branch November 11, 2017 02:44
VladyslavZavadskyi pushed a commit to VladyslavZavadskyi/pytorch that referenced this pull request Nov 11, 2017
* Enable EXPORT_ALL_SYMBOLS for CMAKE

If we turn on CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS flag, we don't need to add most decorators by hand.

* Add quotation marks to pass the string args

* added endif

* Update CMakeLists.txt
facebook-github-bot pushed a commit that referenced this pull request Nov 14, 2018
…ows : (#13672)

Summary:
Libtorch is missing some symbols when generated on windows, causing linker errors when using it.

It seems like there were some issues in the past with enabling   CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS to export all symbols during the build.
(See the link below :
    - Enabling CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS :  #3617
    - Disabling CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS :  #9092 and #9693 )

So enabling CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS is not an option. But some symbols are still missing for Libtorch to be working.
We added some functions to TORCH_API in this PR, but we might be missing some.
(We also tried adding the whole structure Method  (struct TORCH_API Method { ... }) instead of adding the functions separately, but the build fails with a "one or more multiply defined symbols found" error)

Do you have any recommendations on how to detect functions that should/shouldn't be in TORCH_API, so the build is successful and the generated Libtorch has all the required exported symbols?

I also attached toch_exports_missing.txt, which contains the symbols that are exported with the CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS flag enabled but not in the current Libtorch version.
( by generating the output for both torch.dll libraries with "dumpbin /EXPORTS torch.dll" and comparing both outputs and generating the difference)
So any symbol that could be missing from Libtorch should be in this list, but the list has more than 8000 symbols, and I am not sure which ones require to be exported and added to TORCH_API.

This PR currently exports the missing symbols for torch::jit::script::Method that appears in the attached list (in the exception of defaultSchemaFor, and emit_call_to that cause a "multiply defined symbols" error).

[torch_exports_missing.txt](https://github.com/pytorch/pytorch/files/2558466/torch_exports_missing.txt)
Pull Request resolved: #13672

Differential Revision: D12959348

Pulled By: soumith

fbshipit-source-id: ef7e85b047b3937dc6aa01ba67e4e01f8eae4eca
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants