Setting `/OPT:NOREF` and `/OPT:NOICF` linker options in VS2019
I would like to set the following VS linker options in my premake project. They appear as References and Enable COMDAT Folding in VS2019 and default to /OPT:REF and /OPT:ICF, as shown below:

I couldn't find a specific option in the premake documentation for changing these values, so I tried to set them using:
linkoptions { "/OPT:NOREF", "/OPT:NOICF" }
This adds the link options to the project, but the original setting does not get changed (the options in the screenshot above are unchanged). VS seems to pick the first instance of the options, so mine are being ignored

It's probably also worth mentioning that I am not enabling link time optimizations in my premake files.
> premake5.exe --version
premake5 (Premake Build Script Generator) 5.0.0-dev
I ended up changing it with an override that set it when i had edit and continue on for the project
local m = premake.vstudio.vc2010
premake.override(premake.vstudio.vc2010, "optimizeReferences", function(base, cfg)
if cfg.editandcontinue == p.ON then
return
else
return base(cfg)
end
end)
``
Currently, there's no way to change those right now. This is pretty much a VS only piece of functionality, as afaik, COMDAT folding and optimization isn't supported by default with GCC and Clang (someone can feel free to correct me). Definitely a toggle worth looking into.
According to https://docs.microsoft.com/en-gb/cpp/build/reference/compiling-a-c-cpp-program?view=msvc-170
Compiler options are processed "left to right," and when a conflict is detected, the last (rightmost) option wins.
So "/OPT:NOREF" "/OPT:NOICF" should take precedence.
So only a "display issue". I still think that vs (premake action) should parse build/link options to set the knowns options at the "correct" place. (Code::Blocks and Codelite do it).
@nickclark2016 : As I understand, for gcc, it is related to link options -Wl,--gc-sections (and build option -fdata-sections -ffunction-sections) (from https://stackoverflow.com/questions/6687630/how-to-remove-unused-c-c-symbols-with-gcc-and-ld).
Both Gold and LLD also have a identical code folding option like MSVC --icf=safe\all