Index: clang/lib/Serialization/ASTWriterDecl.cpp =================================================================== --- clang/lib/Serialization/ASTWriterDecl.cpp +++ clang/lib/Serialization/ASTWriterDecl.cpp @@ -1011,16 +1011,15 @@ if (D->getStorageDuration() == SD_Static) { bool ModulesCodegen = false; - if (!D->getDescribedVarTemplate() && !D->getMemberSpecializationInfo() && + if (Writer.WritingModule && + !D->getDescribedVarTemplate() && !D->getMemberSpecializationInfo() && !isa(D)) { // When building a C++ Modules TS module interface unit, a strong // definition in the module interface is provided by the compilation of // that module interface unit, not by its users. (Inline variables are // still emitted in module users.) ModulesCodegen = - (((Writer.WritingModule && - Writer.WritingModule->Kind == Module::ModuleInterfaceUnit) || - Writer.Context->getLangOpts().BuildingPCHWithObjectFile) && + (Writer.WritingModule->Kind == Module::ModuleInterfaceUnit && Writer.Context->GetGVALinkageForVariable(D) == GVA_StrongExternal); } Record.push_back(ModulesCodegen); @@ -2451,9 +2450,8 @@ bool ModulesCodegen = false; if (!FD->isDependentContext()) { Optional Linkage; - if ((Writer->WritingModule && - Writer->WritingModule->Kind == Module::ModuleInterfaceUnit) || - Writer->Context->getLangOpts().BuildingPCHWithObjectFile) { + if (Writer->WritingModule && + Writer->WritingModule->Kind == Module::ModuleInterfaceUnit) { // When building a C++ Modules TS module interface unit, a strong // definition in the module interface is provided by the compilation of // that module interface unit, not by its users. (Inline functions are