Skip to content

Conversation

bmanga
Copy link
Contributor

@bmanga bmanga commented Feb 11, 2021

It turns out that on windows, a __declspec(selectany) variable is not the same as a C++17 inline variable.
I have therefore added a linker instruction to force the inclusion of the weak symbol.

@codecov
Copy link

codecov bot commented Feb 11, 2021

Codecov Report

Merging #3380 (1788138) into master (674e814) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3380   +/-   ##
=======================================
  Coverage   74.80%   74.80%           
=======================================
  Files         105      105           
  Lines        9716     9716           
  Branches     1561     1561           
=======================================
  Hits         7268     7268           
  Misses       1961     1961           
  Partials      487      487           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 674e814...1788138. Read the comment docs.

@ezyang
Copy link
Contributor

ezyang commented Feb 11, 2021

Ordinarily I'd have concerns about the portability of linker pragmas, but since this is MSVC only this probably is OK. @fmassa at the end of the day it's your call, but this also looks somewhat plausible.

@bmanga
Copy link
Contributor Author

bmanga commented Feb 11, 2021

Yes I tried multiple things before settling on the linker pragma, but none quite worked. On the plus side, this code can be removed if/when torchvision will require C++17.

@bmanga bmanga mentioned this pull request Feb 11, 2021
Copy link
Member

@fmassa fmassa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's give this a try. Thanks a lot @bmanga for the PR and @ezyang for the feedback!

@fmassa fmassa merged commit dcfd26e into pytorch:master Feb 11, 2021
facebook-github-bot pushed a commit that referenced this pull request Feb 12, 2021
Summary:
* On MSVC, instruct the linker not to drop the _register_ops symbol

* Remove workaround for ops registration on windows

Reviewed By: mthrok

Differential Revision: D26422438

fbshipit-source-id: 7560e2a00c395a44090327446c2616328823a8fc

Co-authored-by: Francisco Massa <[email protected]>
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.

4 participants