Commit 9ed48bae by Nicolas Capens

Prevent LTO from eliminating cross-library virtual methods.

libEGL has to call virtual methods on objects created withing libGLESv2, and vice-versa. Clang's aggressive link-time-optimization considers calls to these methods unreachable, because they're not defined within the same linkage unit. So when they do get called, we're hitting UD instructions. It can be fixed by marking these classes with [[clang::lto_visibility_public]] attributes: https://clang.llvm.org/docs/LTOVisibility.html Bug chromium:720933 Change-Id: I87f9b09921a1b2d443121efcdb5525ff4cb5797b Reviewed-on: https://swiftshader-review.googlesource.com/9688Tested-by: 's avatarNicolas Capens <capn@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent f34d1ace
......@@ -15,7 +15,10 @@
# Need a separate config to ensure the warnings are added to the end.
config("swiftshader_common_private_config") {
if (is_win) {
cflags = [ "/wd4201" ] # nameless struct/union
cflags = [
"/wd4201", # nameless struct/union
"/wd5030", # attribute is not recognized
]
} else {
cflags = [ "-msse2" ]
defines = [ "LOG_TAG=\"swiftshader_common\"" ]
......
......@@ -15,7 +15,10 @@
# Need a separate config to ensure the warnings are added to the end.
config("swiftshader_main_private_config") {
if (is_win) {
cflags = [ "/wd4201" ] # nameless struct/union
cflags = [
"/wd4201", # nameless struct/union
"/wd5030", # attribute is not recognized
]
if (is_clang) {
cflags += [
......
......@@ -34,7 +34,7 @@ namespace sw
int cursorHeight;
};
class FrameBuffer
class [[clang::lto_visibility_public]] FrameBuffer
{
virtual void typeinfo(); // Dummy key method (https://gcc.gnu.org/onlinedocs/gcc/Vague-Linkage.html)
......
......@@ -18,6 +18,7 @@ config("swiftshader_opengl_common_private_config") {
cflags = [
"/wd4201", # nameless struct/union
"/wd4324", # structure was padded due to alignment specifier
"/wd5030", # attribute is not recognized
]
} else {
defines = [ "LOG_TAG=\"swiftshader_opengl_common\"" ]
......
......@@ -46,7 +46,7 @@ GLsizei ComputePitch(GLsizei width, GLenum format, GLenum type, GLint alignment)
GLsizei ComputeCompressedSize(GLsizei width, GLsizei height, GLenum format);
size_t ComputePackingOffset(GLenum format, GLenum type, GLsizei width, GLsizei height, GLint alignment, GLint skipImages, GLint skipRows, GLint skipPixels);
class Image : public sw::Surface, public gl::Object
class [[clang::lto_visibility_public]] Image : public sw::Surface, public gl::Object
{
virtual void typeinfo(); // Dummy key method (https://gcc.gnu.org/onlinedocs/gcc/Vague-Linkage.html)
......
......@@ -28,7 +28,7 @@ typedef unsigned int GLuint;
namespace gl
{
class Object
class [[clang::lto_visibility_public]] Object
{
public:
Object();
......
......@@ -20,6 +20,7 @@ config("swiftshader_opengl_compiler_private_config") {
"/wd4201", # nameless struct/union
"/wd4267", # conversion from size_t to int/unsigned int
"/wd4702", # unreachable code (in autogenerated code)
"/wd5030", # attribute is not recognized
]
if (!is_debug) {
......
......@@ -124,7 +124,7 @@
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<BrowseInformation>true</BrowseInformation>
<TreatWarningAsError>true</TreatWarningAsError>
<DisableSpecificWarnings>4005;</DisableSpecificWarnings>
<DisableSpecificWarnings>5030;4005;</DisableSpecificWarnings>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
</ItemDefinitionGroup>
......@@ -141,7 +141,7 @@
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<BrowseInformation>true</BrowseInformation>
<TreatWarningAsError>true</TreatWarningAsError>
<DisableSpecificWarnings>4005;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<DisableSpecificWarnings>5030;4005;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
</ItemDefinitionGroup>
......@@ -157,7 +157,7 @@
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<TreatWarningAsError>true</TreatWarningAsError>
<DisableSpecificWarnings>4005;</DisableSpecificWarnings>
<DisableSpecificWarnings>5030;4005;</DisableSpecificWarnings>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
</ItemDefinitionGroup>
......@@ -173,7 +173,7 @@
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<TreatWarningAsError>true</TreatWarningAsError>
<DisableSpecificWarnings>4005;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<DisableSpecificWarnings>5030;4005;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
</ItemDefinitionGroup>
......@@ -190,7 +190,7 @@
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<OmitFramePointers>false</OmitFramePointers>
<TreatWarningAsError>true</TreatWarningAsError>
<DisableSpecificWarnings>4005;</DisableSpecificWarnings>
<DisableSpecificWarnings>5030;4005;</DisableSpecificWarnings>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Profile|x64'">
......@@ -206,7 +206,7 @@
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<OmitFramePointers>false</OmitFramePointers>
<TreatWarningAsError>true</TreatWarningAsError>
<DisableSpecificWarnings>4005;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<DisableSpecificWarnings>5030;4005;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
......
......@@ -22,6 +22,7 @@ config("swiftshader_libEGL_private_config") {
cflags = [
"/wd4201", # nameless struct/union
"/wd4065", # switch statement contains 'default' but no 'case' labels
"/wd5030", # attribute is not recognized
]
defines += [
......
......@@ -26,7 +26,7 @@ class Display;
class Surface;
class Image;
class Context : public gl::Object
class [[clang::lto_visibility_public]] Context : public gl::Object
{
public:
Context(egl::Display *display) : display(display) {}
......
......@@ -35,7 +35,7 @@ namespace egl
const EGLDisplay PRIMARY_DISPLAY = reinterpret_cast<EGLDisplay>((intptr_t)1);
const EGLDisplay HEADLESS_DISPLAY = reinterpret_cast<EGLDisplay>((intptr_t)0xFACE1E55);
class Display
class [[clang::lto_visibility_public]] Display
{
virtual void typeinfo(); // Dummy key method (https://gcc.gnu.org/onlinedocs/gcc/Vague-Linkage.html)
......
......@@ -31,7 +31,7 @@ class Config;
class Texture;
class Image;
class Surface : public gl::Object
class [[clang::lto_visibility_public]] Surface : public gl::Object
{
virtual void typeinfo(); // Dummy key method (https://gcc.gnu.org/onlinedocs/gcc/Vague-Linkage.html)
......
......@@ -130,6 +130,7 @@
<BrowseInformation>true</BrowseInformation>
<TreatWarningAsError>true</TreatWarningAsError>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<DisableSpecificWarnings>5030</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
......@@ -160,6 +161,7 @@ copy "$(OutDir)libEGL.dll" "$(SolutionDir)lib\$(Configuration)_$(Platform)\trans
<BrowseInformation>true</BrowseInformation>
<TreatWarningAsError>true</TreatWarningAsError>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<DisableSpecificWarnings>5030</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
......@@ -191,6 +193,7 @@ copy "$(OutDir)libEGL.dll" "$(SolutionDir)lib\$(Configuration)_$(Platform)\trans
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<TreatWarningAsError>true</TreatWarningAsError>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<DisableSpecificWarnings>5030</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
......@@ -222,6 +225,7 @@ copy "$(OutDir)libEGL.dll" "$(SolutionDir)lib\$(Configuration)_$(Platform)\trans
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<TreatWarningAsError>true</TreatWarningAsError>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<DisableSpecificWarnings>5030</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
......@@ -255,6 +259,7 @@ copy "$(OutDir)libEGL.dll" "$(SolutionDir)lib\$(Configuration)_$(Platform)\trans
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<OmitFramePointers>false</OmitFramePointers>
<TreatWarningAsError>true</TreatWarningAsError>
<DisableSpecificWarnings>5030</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
......@@ -286,6 +291,7 @@ copy "$(OutDir)libEGL.dll" "$(SolutionDir)lib\$(Configuration)_$(Platform)\trans
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<OmitFramePointers>false</OmitFramePointers>
<TreatWarningAsError>true</TreatWarningAsError>
<DisableSpecificWarnings>5030</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
......
......@@ -25,6 +25,7 @@ config("swiftshader_libGLESv2_private_config") {
cflags = [
"/wd4201", # nameless struct/union
"/wd4324", # structure was padded due to alignment specifier
"/wd5030", # attribute is not recognized
]
defines += [
......
......@@ -426,12 +426,12 @@ struct State
GLint packSkipImages;
};
class Context : public egl::Context
class [[clang::lto_visibility_public]] Context : public egl::Context
{
public:
Context(egl::Display *display, const Context *shareContext, EGLint clientVersion);
virtual void makeCurrent(egl::Surface *surface);
void makeCurrent(egl::Surface *surface) override;
virtual EGLint getClientVersion() const;
void markAllStateDirty();
......@@ -673,7 +673,7 @@ public:
void clearStencilBuffer(const GLint value);
void drawArrays(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount = 1);
void drawElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLsizei instanceCount = 1);
void finish();
void finish() override;
void flush();
void recordInvalidEnum();
......@@ -690,9 +690,9 @@ public:
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
GLbitfield mask, bool filter, bool allowPartialDepthStencilBlit);
virtual void bindTexImage(egl::Surface *surface);
virtual EGLenum validateSharedImage(EGLenum target, GLuint name, GLuint textureLevel);
virtual egl::Image *createSharedImage(EGLenum target, GLuint name, GLuint textureLevel);
void bindTexImage(egl::Surface *surface) override;
EGLenum validateSharedImage(EGLenum target, GLuint name, GLuint textureLevel) override;
egl::Image *createSharedImage(EGLenum target, GLuint name, GLuint textureLevel) override;
egl::Image *getSharedImage(GLeglImageOES image);
Device *getDevice();
......
......@@ -135,7 +135,7 @@
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<BrowseInformation>true</BrowseInformation>
<TreatWarningAsError>true</TreatWarningAsError>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
<DisableSpecificWarnings>5030;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
......@@ -165,7 +165,7 @@ copy "$(OutDir)libGLESv2.dll" "$(SolutionDir)lib\$(Configuration)_$(Platform)\tr
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<BrowseInformation>true</BrowseInformation>
<TreatWarningAsError>true</TreatWarningAsError>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
<DisableSpecificWarnings>5030;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
......@@ -202,7 +202,7 @@ copy "$(OutDir)libGLESv2.dll" "$(SolutionDir)lib\$(Configuration)_$(Platform)\tr
<WholeProgramOptimization>true</WholeProgramOptimization>
<IntrinsicFunctions>false</IntrinsicFunctions>
<TreatWarningAsError>true</TreatWarningAsError>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
<DisableSpecificWarnings>5030;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
......@@ -240,7 +240,7 @@ copy "$(OutDir)libGLESv2.dll" "$(SolutionDir)lib\$(Configuration)_$(Platform)\tr
<WholeProgramOptimization>true</WholeProgramOptimization>
<IntrinsicFunctions>false</IntrinsicFunctions>
<TreatWarningAsError>true</TreatWarningAsError>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
<DisableSpecificWarnings>5030;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
......@@ -279,7 +279,7 @@ copy "$(OutDir)libGLESv2.dll" "$(SolutionDir)lib\$(Configuration)_$(Platform)\tr
<WholeProgramOptimization>true</WholeProgramOptimization>
<IntrinsicFunctions>false</IntrinsicFunctions>
<TreatWarningAsError>true</TreatWarningAsError>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
<DisableSpecificWarnings>5030;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>dxguid.lib;WS2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
......@@ -315,7 +315,7 @@ copy "$(OutDir)libGLESv2.dll" "$(SolutionDir)lib\$(Configuration)_$(Platform)\tr
<WholeProgramOptimization>true</WholeProgramOptimization>
<IntrinsicFunctions>false</IntrinsicFunctions>
<TreatWarningAsError>true</TreatWarningAsError>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
<DisableSpecificWarnings>5030;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>dxguid.lib;WS2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
......
......@@ -18,6 +18,7 @@ config("swiftshader_renderer_private_config") {
cflags = [
"/wd4201", # nameless struct/union
"/wd4324", # structure was padded due to alignment specifier
"/wd5030", # attribute is not recognized
]
} else {
cflags = [
......
......@@ -217,7 +217,7 @@ namespace sw
LOCK_DISCARD
};
class Surface
class [[clang::lto_visibility_public]] Surface
{
private:
struct Buffer
......
......@@ -18,6 +18,7 @@ config("swiftshader_shader_private_config") {
cflags = [
"/wd4201", # nameless struct/union
"/wd4324", # structure was padded due to alignment specifier
"/wd5030", # attribute is not recognized
]
if (is_clang) {
......
......@@ -130,7 +130,7 @@
<BrowseInformation>true</BrowseInformation>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
<DisableSpecificWarnings>5030;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<TreatWarningAsError>true</TreatWarningAsError>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
......@@ -165,7 +165,7 @@
<BrowseInformation>true</BrowseInformation>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
<DisableSpecificWarnings>5030;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<TreatWarningAsError>true</TreatWarningAsError>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
......@@ -196,7 +196,7 @@
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>
</DebugInformationFormat>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
<DisableSpecificWarnings>5030;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<ForcedIncludeFiles>%(ForcedIncludeFiles)</ForcedIncludeFiles>
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
<StringPooling>true</StringPooling>
......@@ -230,7 +230,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
<DisableSpecificWarnings>5030;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<ForcedIncludeFiles>%(ForcedIncludeFiles)</ForcedIncludeFiles>
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
<StringPooling>true</StringPooling>
......@@ -267,7 +267,7 @@
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>
</DebugInformationFormat>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
<DisableSpecificWarnings>5030;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<ForcedIncludeFiles>%(ForcedIncludeFiles)</ForcedIncludeFiles>
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
<StringPooling>true</StringPooling>
......@@ -304,7 +304,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
<DisableSpecificWarnings>5030;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<ForcedIncludeFiles>%(ForcedIncludeFiles)</ForcedIncludeFiles>
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
<StringPooling>true</StringPooling>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment