[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-cvs
Subject:    [PHP-CVS] com php-src: fix link with deps pdb availability: win32/build/confutils.js
From:       Anatol Belski <ab () php ! net>
Date:       2016-10-30 19:55:38
Message-ID: php-mail-3acc3bd49ca07ebd206b98a7961632041829945094 () git ! php ! net
[Download RAW message or body]

Commit:    c5a4a6f1f227d8dae47a45a52c3cc1c004c23aa5
Author:    Anatol Belski <ab@php.net>         Sun, 30 Oct 2016 20:55:38 +0100
Parents:   cdea5eb9412af3cf8701334f7e7043c041872b27
Branches:  PHP-7.0 PHP-7.1 master

Link:       http://git.php.net/?p=php-src.git;a=commitdiff;h=c5a4a6f1f227d8dae47a45a52c3cc1c004c23aa5

Log:
fix link with deps pdb availability

Unlike debugger, linker is currently not able to read the pdb files,
even if they're put onto path. As result, a lot of LNK4099 warnings
and in some cases also missing debug information in the end binaries.
This is solved by copying the relevant pdb into the build dir, which
then can be picked up on link time. This also leads to the inclusion
of those pdb files into the debug package, so symbols won't be missed
in crash dumps. As otherwise the debug info for dependencies is only
contained in the dependency packages.

Changed paths:
  M  win32/build/confutils.js


Diff:
diff --git a/win32/build/confutils.js b/win32/build/confutils.js
index 432d0bc..022c8fb 100644
--- a/win32/build/confutils.js
+++ b/win32/build/confutils.js
@@ -645,6 +645,62 @@ function find_pattern_in_path(pattern, path)
 	return false;
 }
 
+function copy_dep_pdb_into_build_dir(libpath)
+{
+	var candidate;
+	var build_dir = get_define("BUILD_DIR");
+	var libdir = FSO.GetParentFolderName(libpath);
+	var bindir = FSO.GetAbsolutePathName(libdir + "\\..\\bin");
+
+	var names = [];
+
+	var libname = FSO.GetFileName(libpath);
+	names.push(libname.replace(new RegExp("\\.lib$"), ".pdb"));
+
+	/* Within same .lib, everything should be bound to the same .pdb. No check
+		for every single object in the static libs. */
+	var _tmp = execute("dumpbin /section:.debug$T /rawdata:1,256 " + libpath);
+	if (!_tmp.match("LNK4039")) {
+		if (_tmp.match(/\d{2,}:\s+([a-z0-9\s]+)/i)) {
+			var m = RegExp.$1;
+			var a = m.split(/ /);
+			var s = "";
+			for (var i in a) {
+				s = s + String.fromCharCode(parseInt("0x" + a[i]));
+			}
+
+			if (s.match(/([^\\]+\.pdb)/i)) {
+				if (RegExp.$1 != names[0]) {
+					names.push(RegExp.$1);
+				}
+			}
+		}
+	}
+
+	/*if ("libxml2_a_dll.lib" == libname || "libcrypt.lib" == libname || "libcrypt_a.lib" == libname) {
+		WARNING("dumpbin /section:.debug$T /rawdata " + libpath);
+		ERROR(names);
+	}*/
+
+	for (var k = 0; k < names.length; k++) {
+		var pdbname = names[k];
+
+		candidate = bindir + "\\" + pdbname;
+		if (FSO.FileExists(candidate)) {
+			FSO.CopyFile(candidate, build_dir + "\\" + pdbname, true);
+			return true;
+		}
+
+		candidate = libdir + "\\" + pdbname;
+		if (FSO.FileExists(candidate)) {
+			FSO.CopyFile(candidate, build_dir + "\\" + pdbname, true);
+			return true;
+		}
+	}
+
+	return false;
+}
+
 function CHECK_LIB(libnames, target, path_to_check, common_name)
 {
 	STDOUT.Write("Checking for library " + libnames + " ... ");
@@ -727,6 +783,8 @@ function CHECK_LIB(libnames, target, path_to_check, common_name)
 
 			STDOUT.WriteLine(location);
 
+			copy_dep_pdb_into_build_dir(location);
+
 			return location;
 		}
 
@@ -739,6 +797,7 @@ function CHECK_LIB(libnames, target, path_to_check, common_name)
 			ADD_FLAG("LIBS" + target, libname);
 
 			STDOUT.WriteLine("<in LIB path> " + libname);
+
 			return location;
 		}
 
@@ -749,6 +808,7 @@ function CHECK_LIB(libnames, target, path_to_check, common_name)
 			libname = FSO.GetFileName(location);
 			ADD_FLAG("LIBS" + target, libname);
 			STDOUT.WriteLine("<in extra libs path>");
+			copy_dep_pdb_into_build_dir(location);
 			return location;
 		}
 	}


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic