diff --git a/SCons/Config/gnu b/SCons/Config/gnu index a5295d36..347132df 100644 --- a/SCons/Config/gnu +++ b/SCons/Config/gnu @@ -35,6 +35,25 @@ defenv['ALIGN_FLAG'] = '-Wl,--file-alignment,512' defenv['CPP_REQUIRES_STDLIB'] = 1 defenv['SUBSYS_CON'] = '-Wl,--subsystem,console' +### helper functions + +# on Mac OS X, programs built with g++ 4.0, stl and -s error out: +# dyld: lazy symbol binding failed: lazy pointer not found +# dyld: lazy pointer not found +# +# to avoid this, this function checks if -s works + +def TestStrip(ctx): + c = """ + #include + + int main() { + std::vector v; + return 0; + } + """ + ctx.CheckLinkFlag('-s', run = 1, extension = '.cpp', code = c) + ### debug if defenv['DEBUG']: @@ -66,11 +85,10 @@ if not defenv['DEBUG']: makensis_env.Append(CCFLAGS = '-O2') # optimize makensis_env.Append(CCFLAGS = '-Wall') # all warnings -if not defenv['DEBUG']: - makensis_env.Append(LINKFLAGS = '-s') # strip - conf = FlagsConfigure(makensis_env) conf.CheckLinkFlag('$MAP_FLAG') # generate map file +if not defenv['DEBUG']: + TestStrip(conf) # strip conf.Finish() ### plugin environment @@ -93,14 +111,13 @@ plugin_env.Append(LINKFLAGS = '$MAP_FLAG') # generate map file cp_util_env = defenv.Copy() if not defenv['DEBUG']: - cp_util_env.Append(CCFLAGS = '-O2') # optimize -cp_util_env.Append(CCFLAGS = '-Wall') # all warnings - -if not defenv['DEBUG']: - cp_util_env.Append(LINKFLAGS = '-s') # strip + cp_util_env.Append(CCFLAGS = '-O2') # optimize +cp_util_env.Append(CCFLAGS = '-Wall') # all warnings conf = FlagsConfigure(cp_util_env) conf.CheckLinkFlag('$MAP_FLAG') # generate map file +if not defenv['DEBUG']: + TestStrip(conf) # strip conf.Finish() ### util environment diff --git a/SCons/utils.py b/SCons/utils.py index 3ad802df..feee7ec1 100644 --- a/SCons/utils.py +++ b/SCons/utils.py @@ -36,19 +36,26 @@ def check_compile_flag(ctx, flag): """ Checks if a linker flag is valid. """ -def check_link_flag(ctx, flag): +def check_link_flag(ctx, flag, run = 0, extension = '.c', code = None): ctx.Message('Checking for linker flag %s... ' % flag) old_flags = ctx.env['LINKFLAGS'] ctx.env.Append(LINKFLAGS = flag) - test = """ - int main() { - return 0; - } - """ + if code: + test = code + else: + test = """ + int main() { + return 0; + } + """ + + result = ctx.TryLink(test, extension) + + if run: + result = result and ctx.TryRun(test, extension)[0] - result = ctx.TryLink(test, '.c') ctx.Result(result) if not result: diff --git a/Source/ResourceEditor.h b/Source/ResourceEditor.h index 55902cfc..2f85d8f3 100644 --- a/Source/ResourceEditor.h +++ b/Source/ResourceEditor.h @@ -61,6 +61,7 @@ typedef struct _IMAGE_RESOURCE_DIR_STRING_U { WORD Length; WCHAR NameString[1]; } IMAGE_RESOURCE_DIR_STRING_U,*PIMAGE_RESOURCE_DIR_STRING_U; +# pragma pack() #endif #pragma pack(4) diff --git a/Source/util.cpp b/Source/util.cpp index bb645e95..3a982917 100644 --- a/Source/util.cpp +++ b/Source/util.cpp @@ -14,6 +14,13 @@ # include #endif +#ifdef __APPLE__ +namespace Apple { // defines struct section +# include // for _NSGetExecutablePath +}; +# include // for MAXPATHLEN +#endif + #include // for assert #include #include @@ -636,8 +643,8 @@ string get_executable_path(const char* argv0) { return string(temp_buf); #elif __APPLE__ char temp_buf[MAXPATHLEN+1]; - unsigned long buf_len = MAXPATHLEN; - int rc = _NSGetExecutablePath(temp_buf, &buf_len); + unsigned int buf_len = MAXPATHLEN; + int rc = Apple::_NSGetExecutablePath(temp_buf, &buf_len); assert(rc == 0); return string(temp_buf); #else /* Linux/BSD/POSIX/etc */