[Ecls-list] Patch: MSVC build reform
Muhammad Haggag
mhaggag at gmail.com
Fri Sep 12 05:28:25 UTC 2008
Hi,
Attached is a patch that makes a number of changes to the MSVC build.
The main motivation was to be able to debug and step into ECL itself
when embedding it into a C/C++ application--out of the box, this
doesn't work (tried with both windbg and VS) due to some mismatched
compilation/linking flags. I refactored a couple of things along the
way.
== Defaults changed ==
Enables win32 thread support by default.
Enables Unicode by default.
It makes sense to me to enable both of these by default, given that
Visual C++ enables them by default as well (Unicode, and MT CRT). Are
there any disadvantages to them that would push them into the "opt-in"
category?
== Compiler and Linker flags ==
This is the bulk of the change:
* Flags (Compiler/Linker) were moved from the "Programs" section into
a section of their own.
* Additional flag configuration (threading, unicode, debug) was moved
into the flags section
* CFLAGS_OPTIMIZE is a new flag that holds optimization-specific
options. For debug builds, optimization is disabled. The flag's also
used in src/cmp/cmpdefs.lisp (expanded by cut), so that files compiled
with a debug ECL also have optimization disabled, enabling them to be
debugged as well (although I haven't tested this yet--I verified that
the compilation flags look like they should make compiled code
debuggable).
* CFLAGS_CONFIG is a new flag that holds configuration-specific
(debug/release) compiler options.
For debug builds, this holds:
/Zi (program database)
/D_DEBUG
/MDd (Multi-threaded Debug DLL CRT code generation)
For release builds, this holds:
/DNDEBUG
/MD (Multi-threaded Release DLL CRT code generation)
CFLAGS_OPTIMIZE is appended to CFLAGS_CONFIG, since optimization is
configuration-specific.
MFLAGS was superceded by CFLAGS_CONFIG, which is passed to both GMP
and GC to guarantee we're compiling files uniformly for the current
configuration (so that one can debug GMP or GC if needed).
* LDFLAGS_CONFIG is a new flag that contains configuration-specific
linker options.
For debug builds, this passes /debug to the linker. It also excludes
the right DLL CRT (if doing a debug build, excludes the Release DLL
CRT and vice versa).
This flag is appended to LDFLAGS.
* SHARED_LDFLAGS is now /LDd for debug builds.
* Added /D_CRT_SECURE_NO_DEPRECATE to CFLAGS to stop the compiler from
whining about the standard insecure string functions.
* Fixed typo in old LFLAGS "libd.lib" -> "libcd.lib", and added the
/verbose:lib option which prints extended information on library paths
searched and libraries used by the linker (helpful for debugging build
breaks).
* Added a couple of informative messages echoing the final C++
compiler and linker flags.
* Modified the ECL modules/features messages to prepend "ECL Modules:
" and "ECL Features: " respectively.
== GC Makefile ==
I replaced both $(cdebug) and $(cvars) with $(CFLAGS_CONFIG) passed
from the main makefile. The build log for GC still shows a ton of what
appears to be useless stuff coming from $(cflags), e.g.:
cl -c -DCRTAPI1=_cdecl -DCRTAPI2=_cdecl -nologo -GS -D_X86_=1 -DWIN32
-D_WIN32 -W3 -D_WINNT -D_WIN32_WINNT=0x0500 -DNTDDI_VERSION=0x05000000
-D_WIN32_IE=0x0500 -DWINVER=0x0500 /Zi /D_DEBUG /MDd
/D_CRT_SECURE_NO_DEPRECATE -I..\..\src\gc\include -DSILENT
-DALL_INTERIOR_POINTERS -D__STDC__ -DGC_DLL -DGC_BUILD -DLARGE_CONFIG
-DGC_DLL -DGC_BUILD -DGC_WIN32_THREADS ..\..\src\gc\alloc.c
/Foalloc.obj
But I left it as is for now. "If it isn't broken, don't fix it" and all that :)
Regards
--
Muhammad Haggag
-------------- next part --------------
A non-text attachment was scrubbed...
Name: msvc.patch
Type: application/octet-stream
Size: 6892 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20080911/e88c0fc2/attachment.obj>
More information about the ecl-devel
mailing list