globjects icon indicating copy to clipboard operation
globjects copied to clipboard

Why globjects uses /GL flag on MSVC?

Open NukeBird opened this issue 7 years ago • 4 comments

When I'm trying to compile a project in Visual Studio 2017 I getting an warning "founded .netmodule MSIL or module, compiled with parameter /GL, restarting a linkage with parameter /LTCG"

Compilation time and output file size are big...

NukeBird avatar May 11 '18 14:05 NukeBird

I recall having multiple long sessions fine-tuning the compilation and linker flags on MSVC. Back then, we majorly tested MSVC 2013 and 2015, probably we have to reconsider the flags for 2017. Thanks for reporting.

Update: What I wrote holds for glbinding (I misread the project name). For globjects there may be an actual mismatch of compiler options. We'll investigate.

scheibel avatar May 14 '18 08:05 scheibel

Thank you for reply, hope this behavior of MSVC will be fixed soon ^^

NukeBird avatar May 17 '18 20:05 NukeBird

As for the /GL option, see here: https://docs.microsoft.com/en-us/cpp/build/reference/gl-whole-program-optimization. It enables compiler optimizations across compilation units and implies /LTCG, which is not currently supplied, hence the warning.

IMHO, this is a cmake-init issue, that probably stems from the fact that adding a linker flag is a bit cumbersome in cmake, as there is no target_link_options. To fix this, append the following to CompileOptions.cmake:

# MSVC linker options
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC")
    set(DEFAULT_LINKER_OPTIONS ${DEFAULT_LINKER_OPTIONS}
        "$<$<CONFIG:Release>:-LTCG>"
    )
endif()

This might reduce compile time (as per warning message), but won't affect output file size.

j-o avatar Jun 08 '18 09:06 j-o

Thanks for investigating.

scheibel avatar Jun 14 '18 16:06 scheibel