mirror of
https://git.proxmox.com/git/libgit2
synced 2025-10-18 17:13:37 +00:00
Revised build configuration for MSVC.
Major changes and rationale: - /WX: absolutely vital when compiling in C-mode as the compiler is incredibly lenient on what is allowed to compile. It allows functions to be called without prototypes declared, treating them as functions returning int taking an unspecified (read: unrestricted) list of arguments, without any type checking! It will simply issue a warning, which is easily overlooked. A real example: it will allow you to call ceil(1.75) without first including <math.h> causing UB, returning bogus results like 1023 on the machine I tested on. - Release build separate from debug. Presently release builds don't exist. Consequently they are completely untested. Many bugs may only manifest themselves in release mode. The current configuration sets debug-only flags like /RTC1 which are incompatible with optimization (/O2). In addition, the Windows build of libgit2 has no optimized version. This change resolves this. - Added checksum generation in image headers. This is so debuggers don't complain about checksum mismatches and provides a small amount of consistency to binaries.
This commit is contained in:
parent
6f9024a72b
commit
9ace34c8de
19
wscript
19
wscript
@ -2,11 +2,18 @@ from waflib.Context import Context
|
||||
from waflib.Build import BuildContext, CleanContext, \
|
||||
InstallContext, UninstallContext
|
||||
|
||||
# Unix flags
|
||||
CFLAGS_UNIX = ["-O2", "-Wall", "-Wextra"]
|
||||
CFLAGS_WIN32 = ['/TC', '/W4', '/RTC1', '/nologo']
|
||||
|
||||
CFLAGS_UNIX_DBG = ['-g']
|
||||
CFLAGS_WIN32_DBG = ['/Zi', '/DEBUG']
|
||||
|
||||
# Windows MSVC flags
|
||||
CFLAGS_WIN32_COMMON = ['/TC', '/W4', '/WX', '/nologo', '/Zi']
|
||||
CFLAGS_WIN32_RELEASE = ['/O2', '/MD']
|
||||
|
||||
# Note: /RTC* cannot be used with optimization on.
|
||||
CFLAGS_WIN32_DBG = ['/Od', '/RTC1', '/RTCc', '/DEBUG', '/MDd']
|
||||
CFLAGS_WIN32_L = ['/RELEASE'] # used for /both/ debug and release builds.
|
||||
# sets the module's checksum in the header.
|
||||
CFLAGS_WIN32_L_DBG = ['/DEBUG']
|
||||
|
||||
ALL_LIBS = ['z', 'crypto', 'pthread']
|
||||
@ -43,8 +50,10 @@ def configure(conf):
|
||||
conf.env.PLATFORM = 'win32'
|
||||
|
||||
if conf.env.CC_NAME == 'msvc':
|
||||
conf.env.CFLAGS = CFLAGS_WIN32 + (CFLAGS_WIN32_DBG if dbg else [])
|
||||
conf.env.LINKFLAGS += CFLAGS_WIN32_L_DBG if dbg else []
|
||||
conf.env.CFLAGS = CFLAGS_WIN32_COMMON + \
|
||||
(CFLAGS_WIN32_DBG if dbg else CFLAGS_WIN32_RELEASE)
|
||||
conf.env.LINKFLAGS += CFLAGS_WIN32_L + \
|
||||
(CFLAGS_WIN32_L_DBG if dbg else [])
|
||||
conf.env.DEFINES += ['WIN32', '_DEBUG', '_LIB', 'ZLIB_WINAPI']
|
||||
zlib_name = 'zlibwapi'
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user