Bug #31217 C1033 compilation error on Windows
Submitted: 26 Sep 2007 21:18 Modified: 21 Nov 2007 20:27
Reporter: Bill Mitchell Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S2 (Serious)
Version:5.1 OS:Windows
Assigned to: Iggy Galarza CPU Architecture:Any

[26 Sep 2007 21:18] Bill Mitchell
Description:
Building the 5.1.21 beta version on Windows XP using MS Visual Studio 2005 (MSVC v8), I encountered errors similar to the following:

Compiling...
cl : Command line warning D9025 : overriding '/FdC:/Liant/mysql-5.1.21-beta/sql/Release/mysqld.pdb' with '/Fd$(OutDir)/mysqld.pdb'
sql_builtin.cc
.\sql_builtin.cc : fatal error C1033: cannot open program database 'c:\liant\mysql-5.1.21-beta\sql\$(outdir)\mysqld.idb'
sql_yacc.cc

These errors appear only when compiling the modules in the \sql\ directory.  The modules in the \storage\ directory, for example, compiled without any error. The problem appears to be that the /Fd option is being provided twice to the compiler, generating the above warning D9025, and the compiler is choosing to use the wrong, i.e., unintended, one.  

How to repeat:
To get to this point, I downloaded the 5.1.21 beta version, installed the related tools that had to be used, i.e., CMake 2.4, Gnu Bison 2.1, then worked around the unterminated string configure.data problem by modifying the generated file.  Using Visual Studio 2005 to rebuild the entire project, I received the above errors.   

Suggested fix:
I was able to workaround the problem by modifying the ...\sql\mysqld.vcproj.cmake and ...\sql\mysqld.vcproj files.  

In the configurations defining the VCCLCompilerTool, I removed the option /Fd"$"(OutDir)/mysqld.pdb from the AdditionalOptions.  
In the configurations defining the VCLinkerTool, I removed the string /PDB:"$"(OutDir)/mysqld.pdb from the AdditionalOptions.  

I made the same modification in both of the files mysqld.vcproj.cmake and mysqld.vcproj in the \sql\ directory.  Not yet being an expert in CMake, I cannot guarantee this is the correct fix, but this change did work for me.
[26 Sep 2007 23:43] MySQL Verification Team
Thank you for the bug report. I wasn't able to repeat the issue reported:

C:\temp>dir *.tar.gz
 O volume na unidade C não tem nome.
 O Número de Série do Volume é 6418-7E81

 Pasta de C:\temp

26/09/2007  20:24        28.306.579 mysql-5.1.21-beta.tar.gz
               1 arquivo(s)     28.306.579 bytes
               0 pasta(s)   59.475.263.488 bytes disponíveis
Setting environment for using Microsoft Visual Studio 2005 x64 tools.

C:\Program Files (x86)\Microsoft Visual Studio 8\VC>cd\

C:\>cd temp\mysql-5.1.21-beta

C:\temp\mysql-5.1.21-beta>win\configure WITH_INNOBASE_STORAGE_ENGINE WITH_PARTITION_STORAGE_ENGINE WITH_ARCHIVE_STORAGE_
ENGINE WITH_BLACKHOLE_STORAGE_ENGINE WITH_EXAMPLE_STORAGE_ENGINE WITH_FEDERATED_STORAGE_ENGINE WITH_INNOBASE_STORAGE_ENG
INE __NT__ MYSQL_SERVER_SUFFIX=-nt

C:\temp\mysql-5.1.21-beta>win\build-vs8.bat
O sistema não pode encontrar o arquivo especificado.
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 8/VC/bin/amd64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 8/VC/bin/amd64/cl.exe -- works
-- Check size of void*
-- Check size of void* - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 8/VC/bin/amd64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 8/VC/bin/amd64/cl.exe -- works
CMake Error: Error in cmake code at
C:/temp/mysql-5.1.21-beta/win/configure.data:18:
Parse error.  Function missing ending ")".  Instead found unterminated string with text ")
".
-- Configuring done
        1 arquivo(s) copiado(s).

C:\temp\mysql-5.1.21-beta>gvim win\configure.data

C:\temp\mysql-5.1.21-beta>win\build-vs8.bat
        1 arquivo(s) copiado(s).
-- Configuring done
-- Generating done
-- Build files have been written to: C:/temp/mysql-5.1.21-beta
        1 arquivo(s) copiado(s).

C:\temp\mysql-5.1.21-beta>dir mysql*
 O volume na unidade C não tem nome.
 O Número de Série do Volume é 6418-7E81

 Pasta de C:\temp\mysql-5.1.21-beta

26/09/2007  20:26    <DIR>          mysql-test
26/09/2007  20:30            11.264 MySql.ncb
26/09/2007  20:28            63.109 MySql.sln
               2 arquivo(s)         74.373 bytes
               1 pasta(s)   59.484.606.464 bytes disponíveis

C:\temp\mysql-5.1.21-beta>

Compiled the Release server:

23>client.c
23>Generating Code...
23>Compiling resources...
23>Linking...
23>Embedding manifest...
23>Build log was saved at "file://c:\temp\mysql-5.1.21-beta\sql\mysqld.dir\Release\BuildLog.htm"
23>mysqld - 0 error(s), 9 warning(s)
========== Build: 23 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
[27 Sep 2007 1:21] Bill Mitchell
Modified file

Attachment: mysqld.vcproj.cmake (text/plain), 66.93 KiB.

[27 Sep 2007 1:21] Bill Mitchell
original file

Attachment: mysqld.vcproj.cmake.orig (text/plain), 39.89 KiB.

[27 Sep 2007 1:22] Bill Mitchell
modified file

Attachment: mysqld.vcproj (Application/xml, text), 66.93 KiB.

[27 Sep 2007 1:22] Bill Mitchell
original file

Attachment: mysqld.vcproj.orig (text/plain), 39.89 KiB.

[27 Sep 2007 1:32] Bill Mitchell
Curious.  I wonder if this is a problem with the installation or the configuration of Visual Studio 2005 such that the files are different.  I have attached the original and modified versions of the \sql\mysqld.vcproj.... files.  Are the original versions the same as yours?  Or is my configuration of Visual Studio modifying these?  

I wonder if this is a difference in the service pack/patches to Microsoft Visual Studio 2005.  I've kept up with the patches, so my version is 8.0.50727.762 (SP.050727-7600).  

Also, I notice from your trace that you appear to be using the compiler for the amd64 architecture.  It makes me wonder if that contributes to some difference in the behavior.
[27 Sep 2007 2:48] Bill Mitchell
Buildlog from failing build

Attachment: BuildLog.htm (text/html), 50.34 KiB.

[27 Sep 2007 2:51] Bill Mitchell
After restoring the original mysqld.vcproj.xxx files, I did a clean_build and rebuild of the entire project.  The build of the \sql\ directory failed in the same fashion.  I have attached the BuildLog.htm file to show all the messages received.
[28 Sep 2007 17:34] Patrick Crews
I was having the same problem.

I made the suggested changes and everything built without a problem.
[28 Sep 2007 17:50] MySQL Verification Team
Thank you for the bug report. What is your Compiler Default Warning Level?.
Thanks in advance.

1>------ Build started: Project: mysqld, Configuration: Release Win32 ------
1>Compiling...
1>cl : Command line warning D9025 : overriding '/Fdmysqld.dir\Release\vc80.pdb' with '/FdRelease/mysqld.pdb'
1>sql_builtin.cc
1>Build log was saved at "file://c:\temp\mysql-5.1.21-beta\sql\mysqld.dir\Release\BuildLog.htm"
1>mysqld - 0 error(s), 1 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
[28 Sep 2007 19:30] Bill Mitchell
In the properties page for the mysqld target, under the C/C++ properties I see that the warning level is set to Level 3 (/W3).  

Perhaps more interesting, under the C/C++ Command Line properties I see:
All options:
/O2 /Ob2 /I "C:\Liant\mysql-5.1.21-beta\include" /I "C:\Liant\mysql-5.1.21-beta\extra\yassl\include" /I "C:\Liant\mysql-5.1.21-beta\sql" /I "C:\Liant\mysql-5.1.21-beta\regex" /I "C:\Liant\mysql-5.1.21-beta\zlib" /D "WIN32" /D "_WINDOWS" /D "NDEBUG" /D "DBUG_OFF" /D "HAVE_YASSL" /D "WITH_HEAP_STORAGE_ENGINE" /D "WITH_MYISAM_STORAGE_ENGINE" /D "WITH_MYISAMMRG_STORAGE_ENGINE" /D "WITH_CSV_STORAGE_ENGINE" /D "WITH_EXAMPLE_STORAGE_ENGINE" /D "WITH_INNOBASE_STORAGE_ENGINE" /D "__WIN__" /D "_CRT_SECURE_NO_DEPRECATE" /D "MYSQL_SERVER" /D "_CONSOLE" /D "HAVE_DLOPEN" /D "CMAKE_INTDIR=\"Release\"" /D "_MBCS" /FD /EHsc /MT /Fo"mysqld.dir\Release\\" /Fd"C:/Liant/mysql-5.1.21-beta/sql/Release/mysqld.pdb" /W3 /nologo /c /TP /errorReport:prompt

Additional options:
 /Zm1000 /wd4996 /Fd"$"(OutDir)/mysqld.pdb

Assuming that these two options are concatenated to form the compiler command line, this would seem to confirm my first impression that the compiler is indeed being passed two conflicting /Fd options, is taking the second over the first, and is then not finding the second directory in the tree.
[10 Oct 2007 19:55] Bill Mitchell
I observe the same symptoms on the 5.1.22 release candidate build.  The compiler is passed a second /Fd option, /Fd$(Outdir)/mysql.pdb, when compiling each of the modules in the sql directory and the compilation then fails.  

Interestingly, the workaround I mention above is not as successful with 5.1.22.  When I hand-modify the mysqld.vcproj and mysqld.vcproj.cmake files to remove the directory from the additional options on the compiler and linker commands, Visual Studio 2005 diagnoses after rebuilding the project that the files have been modified outside VS.  When it reloads the files from disk, the files have been restored to their original state and the compilation failures re-appear.  

Further investigation reveals that these additional compiler and linker options are introduced in the sql/CMakeLists.txt file.  In particular, there is a comment that, to work around a 2.4.6 bug, the SET_TARGET_PROPERTIES command is used to fix the COMPILE_FLAGS and LINK_FLAGS.  When I comment out this CMake 2.4.6 workaround, the Visual Studio build of the project successfully compiles all the modules.  

As the current release of CMake is 2.4.7, it may be that this workaround is no longer necessary and the correct fix is to remove it.  I attach a copy of the modified sql/CMakeLists.txt file with the questionable line commented out.
[10 Oct 2007 19:57] Bill Mitchell
Modified sql/CMakeLists.txt file with offending SET_TARGET_PROPERTIES commented out

Attachment: CMakeLists.txt (text/plain), 7.92 KiB.

[2 Nov 2007 19:30] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/37017

ChangeSet@1.2602, 2007-11-02 15:30:39-04:00, iggy@alf.(none) +1 -0
  Bug#31217 C1033 compilation error on Windows
  - This workaround is no longer necessary with cmake 2.4.7.
[21 Nov 2007 18:53] Bugs System
Pushed into 5.1.23-rc
[21 Nov 2007 18:53] Bugs System
Pushed into 6.0.4-alpha
[21 Nov 2007 20:27] Paul DuBois
No changelog entry needed.