facebookincubator/fizz

failed when build with vs2019 Microsoft Visual Studio Community 2019 16.9.2

wongdu opened this issue · 11 comments

“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

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。

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?

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.

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.

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

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

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...

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_; };

@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.

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

Thanks @RTCaylorASC for the detailed investigation!

This should be mitigated by 4db1d61