Zstd: VS2010 project is incompatible with VS2015 because of enabled by default Whole Program Optimization(/GL) flag

Created on 14 Jul 2017  路  5Comments  路  Source: facebook/zstd

Zstd binaries (at least statically) built with VS2015 from available VS2010 solution file have portability issues if used as 3rd party dependencies on others machines.

This happens because VS2010 places Whole Program Optimization(/GL) flag options by default into VS2010 project files, but VS2015 doesn't place it by default anymore. Most of software built with VS2015 doesn't suppose to use Whole Program Optimization(/GL). "Whole program optimization is off by default and must be explicitly enabled." So this difference become a real portability issue, if to use VS2010 project files with VS2015.

Possible solution can be distribution of separate VS2015 projects files without setting Whole Program Optimization(/GL) flag.

As example, removing of <WholeProgramOptimization>true</WholeProgramOptimization> from libzstd.vcxproj generated by VS2010 also solves the compatibility issue with binaries built using VS2015 default settings.

help wanted

All 5 comments

"portability" feels a bit strong in this context,
it seems more like a build environment problem.

I prefer a solution which avoids duplicating multiple files, as it will burden maintenance.

My understanding is that removing <WholeProgramOptimization> achieves just that.
We won't benefit from Whole Program Optimization in VS2010, 2012 or 2013, but I expect these optimisations to have minimal impact anyway, since we already have to face this limitation when compiling with gcc, so the source code is structured for that.

@Cyan4973 , it looks like that WholeProgramOptimization should be presented for compilation with VS2010 (msvc2010 compiler) (because that's default settings for VS2010), but for later versions of VS it should be removed. Maybe, some parameter that turn on/off WholeProgramOptimization can be added into VS2010 projects files, so it will be possible to configure the value from msbuild command line.

To use something like:

msbuild %SLN_FILE% /p:WholeProgramOptimization=%VALUE%

cc @KrzysFR , who likely has the best background on this topic

Unfortunately, I only use VS for .NET projects, and I'm only using the zstd VS2010 project to build a dynamically loaded library that I use from .NET also. For this scenario, I don't think WholeProgramOptimization has any impact on the code quality.

I have no real experience with actual C++ vcproj and the myriads of compilation options, so I can't really give you any advice on that.

I guess we would need the opinion of someone who actually use the zstdlib csproj inside a C++ VS solution ? Though wouldn't it be simpler in that case to simply embed the .c and .h files, and not bother with an external vcproj?

We have no satisfying solution for this issue,
nor any use case we can easily reproduce here (we mostly develop on Linux / OS-X, our Visual projects are self-contained, so it's a different use case too).

We'll keep this issue on hold, waiting for more feedback or some patch for it.

Was this page helpful?
0 / 5 - 0 ratings