| Summary: | CMake MinSizeRel fails for MSCV | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Drew Pirrone-Brusse <drew.pirrone.brusse> |
| Component: | *don't know* | Assignee: | Ryan C. Gordon <icculus> |
| Status: | NEW --- | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | joel.winarske |
| Version: | 2.0.8 | ||
| Hardware: | x86_64 | ||
| OS: | Windows (All) | ||
| Attachments: | Repro log | ||
I have a repro with amd64 build, as well as a different failure with amd64_x86. *** amd64 build *** EXTRA_LIBS: user32;gdi32;winmm;imm32;ole32;oleaut32;version;uuid;dinput8 [100%] Linking C shared library SDL2.dll LINK: command "C:\PROGRA~2\MI0E91~1.0\VC\bin\amd64\link.exe /nologo @CMakeFiles\SDL2.dir\objects1.rsp /out:SDL2.dll /implib:SDL2.lib /pdb:C:\projects\pdcurses\build\sdl2_ext-prefix\src\sdl2_ext-build\SDL2.pdb /dll /version:2.0 /machine:x64 /INCREMENTAL:NO user32.lib gdi32.lib winmm.lib imm32.lib ole32.lib oleaut32.lib version.lib uuid.lib dinput8.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:SDL2.dll.manifest" failed (exit code 1120) with the following output: uuid.lib(unknwn_i.obj) : MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance Creating library SDL2.lib and object SDL2.exp SDL_bmp.c.obj : error LNK2001: unresolved external symbol memset SDL2.dll : fatal error LNK1120: 1 unresolved externals NMAKE : fatal error U1077: '"C:\Program Files (x86)\CMake\bin\cmake.exe"' : return code '0xffffffff' Stop. *** amd64_x86 build *** EXTRA_LIBS: user32;gdi32;winmm;imm32;ole32;oleaut32;version;uuid;dinput8 [100%] Linking C shared library SDL2.dll LINK: command "C:\PROGRA~2\MI0E91~1.0\VC\bin\AMD64_~2\link.exe /nologo @CMakeFiles\SDL2.dir\objects1.rsp /out:SDL2.dll /implib:SDL2.lib /pdb:C:\projects\pdcurses\build\sdl2_ext-prefix\src\sdl2_ext-build\SDL2.pdb /dll /version:2.0 /machine:X86 /INCREMENTAL:NO user32.lib gdi32.lib winmm.lib imm32.lib ole32.lib oleaut32.lib version.lib uuid.lib dinput8.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:SDL2.dll.manifest" failed (exit code 1169) with the following output: uuid.lib(unknwn_i.obj) : MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance MSVCRT.lib(_ftol2_.obj) : error LNK2005: __ftol2_sse already defined in SDL_stdlib.c.obj Creating library SDL2.lib and object SDL2.exp SDL2.dll : fatal error LNK1169: one or more multiply defined symbols found NMAKE : fatal error U1077: '"C:\Program Files (x86)\CMake\bin\cmake.exe"' : return code '0xffffffff' Stop. Build logs: https://ci.appveyor.com/project/jwinarske/pdcurses/builds/19415795 Created attachment 3362 [details]
Repro log
|
Building SDL.lib from CMake with `-DCMAKE_BUILD_TYPE=MinSizeRel` fails to link with the below error. SDL_bmp.c.obj : error LNK2019: unresolved external symbol memset referenced in function SDL_SaveBMP_RW_REAL I typically use Ninja to build -- and use it as the generator for the below repro steps -- but this error manifests when building with Visual Studio as well. An interesting note; I managed to track this error down to the application of the `\O1` (Optimize for Minimum Size) compiler flag. Adding `set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /O2")` as the last line in CMakeLists.txt (to override Minimum Size with Maximum Speed) "fixes" the problem. I'm... not sure what to do with that information, but thought it might be useful. ## Steps to Reproduce (from a clean SDL clone) mkdir build cd build cmake .. -G Ninja -DCMAKE_BUILD_TYPE=MinSizeRel cmake --build . ## System Information Windows 10 Pro 1803 Microsoft (R) C/C++ Optimizing Compiler Version 19.14.26433 for x64 Microsoft (R) Incremental Linker Version 14.14.26433.0