[PATCH xserver 1/3] meson: Remove usage of pkg-config --variable=includedir

Thierry Reding thierry.reding at gmail.com
Thu Mar 29 11:07:54 UTC 2018


From: Thierry Reding <treding at nvidia.com>

Querying a pkg-config variable using the --variable option produces the
value of the given variable as stored in the pkg-config file and should
not be used to add directories to the include search path.

The reason for this is that it breaks cross-compilation, because header
files are installed relative to the host sysroot. pkg-config supports a
PKG_CONFIG_SYSROOT_DIR environment variable that points to this sysroot
and will prepend that to the path of directories in -I or -L options in
pkg-config's Cflags, Libs or Libs.private keywords. However, because no
context can be inferred from variable names, as opposed to the keywords
with fixed meaning, the sysroot path will not be prepended to them. The
build system is responsible for doing so if necessary since it is aware
of the context in which the variable is used.

Adding the include directory returned by pkg-config to the include path
leaks build system information into the cross-build and break with very
confusing errors such as this:

	In file included from include/misc.h:82:0,
			 from dix/atom.c:55:
	/usr/include/pthread.h:682:6: warning: '__regparm__' attribute directive ignored [-Wattributes]
	      __cleanup_fct_attribute;
	      ^~~~~~~~~~~~~~~~~~~~~~~

or this:

	In file included from include/misc.h:139:0,
			 from dix/atom.c:55:
	/usr/include/stdlib.h:133:8: error: '_Float128' is not supported on this target
	 extern _Float128 strtof128 (const char *__restrict __nptr,
		^~~~~~~~~

Fix this by replacing the include directory with the appropriate xproto
dependency required to add the correct include directory to the compile
command for subdirectories that are missing the dependency. As detailed
above, this gives pkg-config the opportunity to prepend the sysroot for
all paths in -I compiler options.

Signed-off-by: Thierry Reding <treding at nvidia.com>
---
 meson.build    | 1 -
 os/meson.build | 3 +++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/meson.build b/meson.build
index 6ad98d23e10b..0582d6f9ae6b 100644
--- a/meson.build
+++ b/meson.build
@@ -477,7 +477,6 @@ inc = include_directories(
     'randr',
     'render',
     'xfixes',
-    xproto_dep.get_pkgconfig_variable('includedir')
 )
 
 glx_inc = include_directories('glx')
diff --git a/os/meson.build b/os/meson.build
index ff3a4615b8f2..eb8fcf55dd24 100644
--- a/os/meson.build
+++ b/os/meson.build
@@ -67,6 +67,9 @@ if srcs_libc.length() > 0
     libxlibc = static_library('libxlibc',
         srcs_libc,
         include_directories: inc,
+        dependencies: [
+            xproto_dep,
+        ],
     )
 endif
 
-- 
2.16.3



More information about the xorg-devel mailing list