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

failed when build with vs2019 Microsoft Visual Studio Community 2019 16.9.2 #59

Closed
wongdu opened this issue Mar 31, 2021 · 11 comments
Closed

Comments

@wongdu
Copy link

wongdu commented Mar 31, 2021

“F:\quicNew\fizz\fizz/protocol/FizzBase.h(150,3): fatal error C1001: Internal compiler error.
(compiler file ‘msc1.cpp’, line 1588)”
To work around this problem, try simplifying or changing the program near the locations listed above.
If possible please provide a repro here: https://developercommunity.visualstudio.com
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information

@wongdu
Copy link
Author

wongdu commented Mar 31, 2021

1、follow the step described in README.md file on ubuntu platform, there's no error. the build procedure is successed。
2、successed when build fizz project,but failed when build the BogoShim and FizzTool project。

@reanimus
Copy link
Contributor

reanimus commented Apr 5, 2021

According to the documentation, this is a parser error (looks like it's choking on a macro). Given that the macro is valid, I figure it's a bug with the compiler itself. Is this error happening while building the BogoShim/FizzTool specifically? Are you also building tests?

@wongdu
Copy link
Author

wongdu commented Apr 6, 2021

thanks for you reply.
built the BogoShim and FizzTool project,but both were failed.didnot build the tests project.
it looks like the msvc's bug. will try build again later.

@RTCaylorASC
Copy link

RTCaylorASC commented May 13, 2021

I have been running into this same issue with VS Professional 2019 16.9.5. Per the documentation link reanimus provided it was suggested to turn off all optimizations. Optimizations were already turned off, so no luck there. However, the documentations suggested turning on /P to look at the preprocessor output. Just adding the /P option changed the behavior of the compiler enough to make the error go away.

EDIT: A little premature on the victory lap. Success in getting the preprocessor output, but not the actual compilation.

@RTCaylorASC
Copy link

Was able to get this to get this to compile and run by substituting the problematic macro with the output from the preprocessor.

@anqixu
Copy link

anqixu commented Jun 4, 2021

@RTCaylorASC can you please elaborate on what to replace FizzBase.h:148 with / show a PR? Many thanks :)

@reanimus
Copy link
Contributor

reanimus commented Jun 4, 2021

FWIW, I'm trying to build with the latest version of MSVC (16.10.0), but I'm currently blocked by an error when trying to build Boost...

@RTCaylorASC
Copy link

RTCaylorASC commented Jun 4, 2021

I found the problematic macro invocation in FizzBase.h starting at line 133...

#define FIZZ_PENDING_EVENT(F, ...) \
  F(AppWrite, __VA_ARGS__)         \
  F(EarlyAppWrite, __VA_ARGS__)    \
  F(AppClose, __VA_ARGS__)         \
  F(WriteNewSessionTicket, __VA_ARGS__)

FIZZ_DECLARE_VARIANT_TYPE(PendingEvent, FIZZ_PENDING_EVENT)

Then I turned on the preprocessor output in my CMakeLits.txt file...

add_compile_options(/P)    # Preprocessor Output.
add_compile_options(/C)    # Save comments in preprocessor output.

Then copied the macro equivalent from the preprocessor results in FizzClientCommand.i and then replaced the ugly macro in FizzBase.h...

struct PendingEvent { enum class Type { AppWrite_E, EarlyAppWrite_E, AppClose_E, WriteNewSessionTicket_E, }; PendingEvent(AppWrite&& x) : type_(Type::AppWrite_E) { new (&AppWrite_) AppWrite(std::move(x)); } PendingEvent(EarlyAppWrite&& x) : type_(Type::EarlyAppWrite_E) { new (&EarlyAppWrite_) EarlyAppWrite(std::move(x)); } PendingEvent(AppClose&& x) : type_(Type::AppClose_E) { new (&AppClose_) AppClose(std::move(x)); } PendingEvent(WriteNewSessionTicket&& x) : type_(Type::WriteNewSessionTicket_E) { new (&WriteNewSessionTicket_) WriteNewSessionTicket(std::move(x)); } PendingEvent(PendingEvent&& other) { switch (other.type_) { case Type::AppWrite_E: new (&AppWrite_) AppWrite(std::move(other.AppWrite_)); break; case Type::EarlyAppWrite_E: new (&EarlyAppWrite_) EarlyAppWrite(std::move(other.EarlyAppWrite_)); break; case Type::AppClose_E: new (&AppClose_) AppClose(std::move(other.AppClose_)); break; case Type::WriteNewSessionTicket_E: new (&WriteNewSessionTicket_) WriteNewSessionTicket(std::move(other.WriteNewSessionTicket_)); break; } type_ = other.type_; } PendingEvent& operator=(PendingEvent&& other) { destroyVariant(); switch (other.type_) { case Type::AppWrite_E: new (&AppWrite_) AppWrite(std::move(other.AppWrite_)); break; case Type::EarlyAppWrite_E: new (&EarlyAppWrite_) EarlyAppWrite(std::move(other.EarlyAppWrite_)); break; case Type::AppClose_E: new (&AppClose_) AppClose(std::move(other.AppClose_)); break; case Type::WriteNewSessionTicket_E: new (&WriteNewSessionTicket_) WriteNewSessionTicket(std::move(other.WriteNewSessionTicket_)); break; } type_ = other.type_; return *this; } ~PendingEvent() { destroyVariant(); } Type type() const { return type_; } AppWrite* asAppWrite() { if (type_ == Type::AppWrite_E) { return &AppWrite_; } return nullptr; } AppWrite& tryAsAppWrite() { auto ptr = asAppWrite(); if (!ptr) { throw std::runtime_error("Mismatched access type"); } return *ptr; } EarlyAppWrite* asEarlyAppWrite() { if (type_ == Type::EarlyAppWrite_E) { return &EarlyAppWrite_; } return nullptr; } EarlyAppWrite& tryAsEarlyAppWrite() { auto ptr = asEarlyAppWrite(); if (!ptr) { throw std::runtime_error("Mismatched access type"); } return *ptr; } AppClose* asAppClose() { if (type_ == Type::AppClose_E) { return &AppClose_; } return nullptr; } AppClose& tryAsAppClose() { auto ptr = asAppClose(); if (!ptr) { throw std::runtime_error("Mismatched access type"); } return *ptr; } WriteNewSessionTicket* asWriteNewSessionTicket() { if (type_ == Type::WriteNewSessionTicket_E) { return &WriteNewSessionTicket_; } return nullptr; } WriteNewSessionTicket& tryAsWriteNewSessionTicket() { auto ptr = asWriteNewSessionTicket(); if (!ptr) { throw std::runtime_error("Mismatched access type"); } return *ptr; } const AppWrite* asAppWrite() const { if (type_ == Type::AppWrite_E) { return &AppWrite_; } return nullptr; } const AppWrite& tryAsAppWrite() const { auto ptr = asAppWrite(); if (!ptr) { throw std::runtime_error("Mismatched access type"); } return *ptr; } const EarlyAppWrite* asEarlyAppWrite() const { if (type_ == Type::EarlyAppWrite_E) { return &EarlyAppWrite_; } return nullptr; } const EarlyAppWrite& tryAsEarlyAppWrite() const { auto ptr = asEarlyAppWrite(); if (!ptr) { throw std::runtime_error("Mismatched access type"); } return *ptr; } const AppClose* asAppClose() const { if (type_ == Type::AppClose_E) { return &AppClose_; } return nullptr; } const AppClose& tryAsAppClose() const { auto ptr = asAppClose(); if (!ptr) { throw std::runtime_error("Mismatched access type"); } return *ptr; } const WriteNewSessionTicket* asWriteNewSessionTicket() const { if (type_ == Type::WriteNewSessionTicket_E) { return &WriteNewSessionTicket_; } return nullptr; } const WriteNewSessionTicket& tryAsWriteNewSessionTicket() const { auto ptr = asWriteNewSessionTicket(); if (!ptr) { throw std::runtime_error("Mismatched access type"); } return *ptr; } template <class T, class E> struct TypedGet {}; template <class Extra> struct TypedGet<AppWrite, Extra> { template <class Type> static AppWrite* get(Type& t) { return t.asAppWrite(); } template <class Type> static const AppWrite* getConst(const Type& t) { return t.asAppWrite(); } }; template <class Extra> struct TypedGet<EarlyAppWrite, Extra> { template <class Type> static EarlyAppWrite* get(Type& t) { return t.asEarlyAppWrite(); } template <class Type> static const EarlyAppWrite* getConst(const Type& t) { return t.asEarlyAppWrite(); } }; template <class Extra> struct TypedGet<AppClose, Extra> { template <class Type> static AppClose* get(Type& t) { return t.asAppClose(); } template <class Type> static const AppClose* getConst(const Type& t) { return t.asAppClose(); } }; template <class Extra> struct TypedGet<WriteNewSessionTicket, Extra> { template <class Type> static WriteNewSessionTicket* get(Type& t) { return t.asWriteNewSessionTicket(); } template <class Type> static const WriteNewSessionTicket* getConst(const Type& t) { return t.asWriteNewSessionTicket(); } }; template <class T> T* getType() { return TypedGet<T, int>::get(*this); } template <class T> const T* getType() const { return TypedGet<T, int>::getConst(*this); } private: union { AppWrite AppWrite_; EarlyAppWrite EarlyAppWrite_; AppClose AppClose_; WriteNewSessionTicket WriteNewSessionTicket_; }; void destroyVariant() { switch (type_) { case Type::AppWrite_E: AppWrite_.~AppWrite(); break; case Type::EarlyAppWrite_E: EarlyAppWrite_.~EarlyAppWrite(); break; case Type::AppClose_E: AppClose_.~AppClose(); break; case Type::WriteNewSessionTicket_E: WriteNewSessionTicket_.~WriteNewSessionTicket(); break; } } Type type_; };

@anqixu
Copy link

anqixu commented Jun 5, 2021

@RTCaylorASC thank you very much!
@reanimus Using our internal FB build system, I didn't encounter any build errors with MSVC (16.10.0) vs boost. But this fizz macro is still choking.

@wongdu
Copy link
Author

wongdu commented Jun 7, 2021

@reanimus i use the boost 1.75, and it is working well, means there is no error about boost

facebook-github-bot pushed a commit that referenced this issue Oct 26, 2021
Summary:
MSVC does not like our FIZZ_DECLARE_VARIANT invocation within a class.

#59

Reviewed By: anqixu, knekritz

Differential Revision: D31866986

fbshipit-source-id: dd910b0dd52fcb342f1a0678e467c8beae3a99ac
@mingtaoy
Copy link
Contributor

Thanks @RTCaylorASC for the detailed investigation!

This should be mitigated by 4db1d61

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants