[PATCH xserver] Workaround a sdksyms problem with gcc5 on Cygwin

Jon Turney jon.turney at dronecode.org.uk
Mon Mar 6 17:44:19 UTC 2017


The linemarkers in the preprocessor output from gcc5 on Cygwin have
canonicalized paths to included files (e.g. xserver/build/../include/misc.h
is canonicalized to xserver/build/include/misc.h). (see gcc svn rev 210264,
which causes the transformation performed by -fcanonical-system-headers to
be applied to all include pathnames)

These canonicalized paths won't match $topdir, so sdksyms doesn't look at
the contents of those headers for sdk exported symbols.

Workaround this by canonicalizing all the paths we consider, using readlink.

v2:
Keep a cache of readlink results so it isn't quite so dreadfully slow.
---
 hw/xfree86/sdksyms.sh | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/hw/xfree86/sdksyms.sh b/hw/xfree86/sdksyms.sh
index 10909d0..767ce21 100755
--- a/hw/xfree86/sdksyms.sh
+++ b/hw/xfree86/sdksyms.sh
@@ -296,7 +296,7 @@ cat > sdksyms.c << EOF
 
 EOF
 
-topdir=$1
+topdir=$(readlink -f $1)
 shift
 LC_ALL=C
 export LC_ALL
@@ -314,11 +314,24 @@ BEGIN {
     printf("sdksyms.c:") > "sdksyms.dep";
 }
 /^# [0-9]+ "/ {
-    #   Process text after a include in a relative path or when the
-    # processed file has a basename matching $top_srcdir.
-    #   Note that indexing starts at 1; 0 means no match, and there
-    # is a starting ".
-    sdk = $3 !~ /^"\// || index($3, topdir) == 2;
+    # Match preprocessor linemarkers which have the form:
+    # # linenum "filename" flags
+    #
+    # Only process text for sdk exports where the linemarker filename has a
+    # relative path, or an absolute path matching $top_srcdir.
+    #
+
+    # canonicalize filename
+    if ($3 in canonicalized) {
+	c = canonicalized[$3]
+    } else {
+	cmd = "readlink -f " $3
+	cmd | getline c
+	close(cmd)
+        canonicalized[$3] = c
+    }
+    # note that index() starts at 1; 0 means no match.
+    sdk = $3 !~ /^"\// || index(c, topdir) == 1;
 
     if (sdk && $3 ~ /\.h"$/) {
 	# remove quotes
-- 
2.8.3



More information about the xorg-devel mailing list