Page MenuHomePhabricator

[lldb] - Fix compilation with MSVS 2015 update 3
AbandonedPublic

Authored by grimar on Fri, Dec 21, 4:02 AM.

Details

Reviewers
clayborg
zturner
Group Reviewers
Restricted Project
Summary

Currently, LLDB fails to build with the following errors when MSVS update 3 is used:

fatal error C1001: An internal error has occurred in the compiler.
(compiler file 'msc1.cpp', line 1468)
To work around this problem, try simplifying or changing the program near the locations listed above.

Seems it is relative to constexpr. This patch introduces macro CONSTEXPR that expands to const/constexpr
depending on the environment and this change allows LLDB to compile and run under windows for me.

Diff Detail

Event Timeline

grimar created this revision.Fri, Dec 21, 4:02 AM
grimar edited the summary of this revision. (Show Details)Fri, Dec 21, 4:06 AM
clayborg requested changes to this revision.Fri, Dec 21, 7:16 AM

The changes from "constexpr" to "const" might introduce global constructors in the shared library which is what we were trying to avoid. The less work that the LLDB shared library does on load the better. We might need to use a macro that expands to "constexpr" for non windows and to "const" for windows in a private LLDB header (PropertyDefinition.h?)

This revision now requires changes to proceed.Fri, Dec 21, 7:16 AM
grimar added a comment.EditedWed, Dec 26, 6:42 AM

The changes from "constexpr" to "const" might introduce global constructors in the shared library which is what we were trying to avoid. The less work that the LLDB shared library does on load the better. We might need to use a macro that expands to "constexpr" for non windows and to "const" for windows in a private LLDB header (PropertyDefinition.h?)

Thanks for looking, Greg. Initially, I thought only MSVS 2015 is affected, but looking at the comments in the wild (https://developercommunity.visualstudio.com/content/problem/18155/msvc-2017-c-fatal-error-c1001-constexpr-initializa.html),
seems it might be an issue for MSVS 2017 too. So I am going to implement your suggestion. Seems lldb/lldb-defines.h file we already have is a good place for a new macro definition.

grimar updated this revision to Diff 179535.Thu, Dec 27, 12:45 AM
grimar edited the summary of this revision. (Show Details)
  • Addressed review comment.
labath added a subscriber: labath.

BTW, I've been compiling lldb with VS2017 and haven't run into this issue. Also, with the imminent release of VS2019, I expect someone will soon start a thread proposing to drop VS2015, so you might be better of switching to a newer compiler. (But I don't have a problem with checking this in while we still officially support this compiler.)

BTW, I've been compiling lldb with VS2017 and haven't run into this issue. Also, with the imminent release of VS2019, I expect someone will soon start a thread proposing to drop VS2015, so you might be better of switching to a newer compiler. (But I don't have a problem with checking this in while we still officially support this compiler.)

I am OK with switching to VS2017 I think.

grimar planned changes to this revision.Thu, Jan 10, 7:35 AM

I'll try to switch to MSVS 2017 and recheck this.

grimar abandoned this revision.Mon, Jan 14, 7:23 AM

Yep, MSVS2017 works fine here for me too. Thanks, Pavel! I am abandoning it.