We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4233 - CMake MinSizeRel fails for MSCV
Summary: CMake MinSizeRel fails for MSCV
Status: NEW
Alias: None
Product: SDL
Classification: Unclassified
Component: *don't know* (show other bugs)
Version: 2.0.8
Hardware: x86_64 Windows (All)
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-08-18 21:08 UTC by Drew Pirrone-Brusse
Modified: 2018-10-10 22:33 UTC (History)
1 user (show)

See Also:


Attachments
Repro log (47.87 KB, text/plain)
2018-10-10 22:33 UTC, Joel Winarske
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Drew Pirrone-Brusse 2018-08-18 21:08:26 UTC
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
Comment 1 Joel Winarske 2018-10-10 22:09:12 UTC
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
Comment 2 Joel Winarske 2018-10-10 22:33:16 UTC
Created attachment 3362 [details]
Repro log