Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: compilation of native modules on windows with older msvc versions #21950

Merged
merged 1 commit into from Jan 29, 2020

Conversation

deepak1556
Copy link
Member

@deepak1556 deepak1556 commented Jan 29, 2020

Description of Change

https://chromium-review.googlesource.com/c/v8/v8/+/1847361 started using C++ [[deprecated]] attribute which has issues when building with msvc from VS2015. Native modules compiling with this version will have error of the format error C2416: attribute 'deprecated("..")' cannot be applied in this context from v8 headers

This can be verified with the following test case:

class A {
  public:
    [[deprecated("test")]]
    A(int a);
};

int main() {
  return 0;
}

with 2015 toolchain there will be error:

>  & 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\cl.exe' /c /I"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include" test.cc

with 2017 toolchain it will compile:

> & 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64\cl.exe' /c /I"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include" test.cc

There is a msvc bug report out there which fixed this specific case, don't have the link. The PR just uses __declspec(deprecated) for those versions.

Checklist

Release Notes

Notes: fix compilation error for native modules building with VS 2015

@deepak1556 deepak1556 requested a review from a team as a code owner January 29, 2020 00:14
@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Jan 29, 2020
// A macro (V8_DEPRECATED) to mark classes or functions as deprecated.
#if defined(V8_DEPRECATION_WARNINGS)
-# define V8_DEPRECATED(message) [[deprecated(message)]]
+# if defined(_MSC_VER) && _MSC_VER <= 1900
Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

@nornagon nornagon left a comment

Choose a reason for hiding this comment

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

Presumably node will run into this too. should we be upstreaming this?

@deepak1556
Copy link
Member Author

Yeah its better to upstream this, will do it tomorrow.

@MarshallOfSound MarshallOfSound merged commit ca515ae into master Jan 29, 2020
@release-clerk
Copy link

release-clerk bot commented Jan 29, 2020

Release Notes Persisted

fix compilation error for native modules building with VS 2015

@MarshallOfSound MarshallOfSound deleted the robo/fix_deprecated_windows branch January 29, 2020 19:59
@MarshallOfSound
Copy link
Member

@deepak1556 Can you take this back to 8?

@trop
Copy link
Contributor

trop bot commented Jan 29, 2020

I was unable to backport this PR to "8-x-y" cleanly;
you will need to perform this backport manually.

@trop
Copy link
Contributor

trop bot commented Jan 29, 2020

@deepak1556 has manually backported this PR to "8-x-y", please check out #21960

@sofianguy sofianguy added this to Blocks Stable in 8.2.x Jan 29, 2020
@sofianguy sofianguy moved this from Blocks Stable to Fixed for Next Release in 8.2.x Jan 30, 2020
@trop trop bot removed the in-flight/8-x-y label Jan 30, 2020
@trop trop bot added the merged/8-x-y label Jan 30, 2020
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Jan 30, 2020
@sofianguy sofianguy moved this from Fixed for Next Release to Fixed in 8.0.0-beta.9 in 8.2.x Jan 30, 2020
@deepak1556
Copy link
Member Author

@deepak1556
Copy link
Member Author

Please see the above CL and the v8 team has responded with their supported release lines wrt msvc, so its better we remove this patch for Electron 9 and above. Let users fix this properly on their end using VS2017 build tools.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
8.2.x
Fixed in 8.0.0-beta.9
Development

Successfully merging this pull request may close these issues.

None yet

4 participants