backtrace-labs / crashpad

A fork of Crashpad with file attachment support and other improvements.
Apache License 2.0
99 stars 33 forks source link

Incompatible with different versions of VS2017 and VS2019 #3

Closed adammarks closed 4 years ago

adammarks commented 4 years ago

We have version 15.7 of VS2017 and this pre-built lib of Crashpad is built with a different version of VS2017. VS2017 does offer binary compatibility with different versions, but that isn't the case if the /GL ( Whole program optimization ) flag is on.

When I try using the library with VS2017 I get an initial C1047 error which is the first indication that something is wrong https://docs.microsoft.com/en-us/cpp/error-messages/compiler-errors-1/fatal-error-c1047?view=vs-2019

I can then workaround that error with the following undocumented linker switch to get a little more information. /d2:-AllowCompatibleILVersions

Then I get the following errors which give more specifics

6>client.lib(client.crash_report_database_win.obj) : MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance
6>LINK : fatal error C1900: Il mismatch between 'P1' version '20180423' and 'P2' version '20180214'
6>LINK : fatal error LNK1257: code generation failed
adammarks commented 4 years ago

Looks like the way to do this is to edit the third_party\mini_chromium\mini_chromium\build\BUILD.gn file and do the following

adammarks commented 4 years ago

I tried the custom/crashpad-2020-03-02-release-x64-c273521cfad3221e8c8ba0035ebc58e820f5be37.zip build

and I still get this link error : 7>client.lib(client.crash_report_database_win.obj) : MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance 7>LINK : fatal error C1900: Il mismatch between 'P1' version '20180423' and 'P2' version '20180214' 7>LINK : fatal error LNK1257: code generation failed

sbahra commented 4 years ago

Hi Adam! Thanks for this. Our team is looking into this and looks like there is a corresponding ZenDesk ticket.

KrzaQ commented 4 years ago

Hi Adam. I have prepared a build in accordance with your instructions: [link].

It does "just work" with my VS 15.9.21. Could you verify if the problem has been solved?

adammarks commented 4 years ago

@KrzaQ I get a different error message this time when using your latest library with VS2017 15.7.5

7>client.lib(client.crash_report_database_win.obj) : MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance 7>LINK : fatal error C1007: unrecognized flag '-pdbrpc' in 'p2' 7>LINK : fatal error LNK1257: code generation failed 7>Done building project "TestBacktraceSend.vcxproj" -- FAILED.

Here's a stackoverflow that seems to point to this being related to whole program optimization also. I wonder if client.lib depends on something else that is built with /GL.

Let me do a bit more investigation into building crashpad on my side to see what else could be done.

KrzaQ commented 4 years ago

@adammarks Just to be certain, are you linking against libs from the lib_nogl folder? I am getting fatal error C1007: unrecognized flag '-pdbrpc' in 'p2' when linking against lib_mt in my last build.

adammarks commented 4 years ago

@adammarks Just to be certain, are you linking against libs from the lib_nogl folder? I am getting fatal error C1007: unrecognized flag '-pdbrpc' in 'p2' when linking against lib_mt in my last build.

No, I completely missed that there was a new folder! I will try the nogl libs.

adammarks commented 4 years ago

@KrzaQ Can you make the noGL libs /MD ( Dynamically linked to C++ ) rather than /MT ( Statically linked to C++ ) ?

I currently can't link to them because they are /MT I tried switching our test EXE over to /MD but since all of our dependencies are also /MD I didn't get far enough into the link to tell if it's working yet.

KrzaQ commented 4 years ago

Here you go (lib_nogl): [link]

adammarks commented 4 years ago

@KrzaQ I tried the latest lib and I am still seeing that it is build with /MT. I'm using the lib_nogl directory libs.

KrzaQ commented 4 years ago

I'm checking this out. I did a test build with it but maybe I misconfigured it.

KrzaQ commented 4 years ago

You are correct, I could confirm this problem. I'll get back to you with a working version.

KrzaQ commented 4 years ago

Please try this build: [link]

adammarks commented 4 years ago

@KrzaQ The latest lib works!

Now can you create x86 and debug versions of the lib also.

Do you plan on keeping the nogl libs separate? I would just replace the MD libs with the noGL libs because the whole program optimization setting really won't provide that much of a optimization benefit to your customers. There are other optimzation settings that are still set that provide the main benefit of optimization. There are very few situations where whole program optimization provides additional benefit.

KrzaQ commented 4 years ago

Here you go. I think we'll do what you suggest and have the nogl build replace current MD.

http://get.backtrace.io/crashpad/builds/custom/

KrzaQ commented 4 years ago

I'm closing the issue since your problem has been solved. Feel free to reach out to us.