diff mbox

[i-g-t,3/7] lib: Fix compilation on non-x86

Message ID 20171012132943.28316-3-thierry.reding@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Thierry Reding Oct. 12, 2017, 1:29 p.m. UTC
From: Thierry Reding <treding@nvidia.com>

The meson build avoids the failure by excluding the igt_x86.c file from
the compilation. autotools being what they are don't support that in an
easy way, so just use the preprocessor to avoid the duplicate function
definitions.

Since igt_x86.c will now be ignored for non-x86 builds, the meson work-
around can be removed.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 lib/igt_x86.c   | 2 ++
 lib/igt_x86.h   | 2 +-
 lib/meson.build | 5 +----
 3 files changed, 4 insertions(+), 5 deletions(-)

Comments

Ville Syrjälä Oct. 12, 2017, 1:44 p.m. UTC | #1
On Thu, Oct 12, 2017 at 03:29:39PM +0200, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
> 
> The meson build avoids the failure by excluding the igt_x86.c file from
> the compilation. autotools being what they are don't support that in an
> easy way,

There is some kind of build_x86 thing in autotools stuff.

But this looks OK to me as well so
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

> so just use the preprocessor to avoid the duplicate function
> definitions.
> 
> Since igt_x86.c will now be ignored for non-x86 builds, the meson work-
> around can be removed.
> 
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>  lib/igt_x86.c   | 2 ++
>  lib/igt_x86.h   | 2 +-
>  lib/meson.build | 5 +----
>  3 files changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/lib/igt_x86.c b/lib/igt_x86.c
> index 0f0963ced044..0ed3c6f1d356 100644
> --- a/lib/igt_x86.c
> +++ b/lib/igt_x86.c
> @@ -93,6 +93,7 @@
>  
>  #define has_YMM 0x1
>  
> +#if defined(__x86_64__) || defined(__i386__)
>  unsigned igt_x86_features(void)
>  {
>  	unsigned max = __get_cpuid_max(BASIC_CPUID, 0);
> @@ -172,3 +173,4 @@ char *igt_x86_features_to_string(unsigned features, char *line)
>  
>  	return ret;
>  }
> +#endif
> diff --git a/lib/igt_x86.h b/lib/igt_x86.h
> index d6dcfa108331..27b7f0fd5837 100644
> --- a/lib/igt_x86.h
> +++ b/lib/igt_x86.h
> @@ -40,7 +40,7 @@
>  #define AVX	0x80
>  #define AVX2	0x100
>  
> -#if defined(__x86_64__)
> +#if defined(__x86_64__) || defined(__i386__)
>  unsigned igt_x86_features(void);
>  char *igt_x86_features_to_string(unsigned features, char *line);
>  #else
> diff --git a/lib/meson.build b/lib/meson.build
> index 42919eef52a8..e89d4bdf8278 100644
> --- a/lib/meson.build
> +++ b/lib/meson.build
> @@ -56,6 +56,7 @@ lib_sources = [
>  	'igt_stats.c',
>  	'igt_sysfs.c',
>  	'igt_vgem.c',
> +	'igt_x86.c',
>  	'instdone.c',
>  	'intel_batchbuffer.c',
>  	'intel_chipset.c',
> @@ -88,10 +89,6 @@ lib_sources = [
>  	'igt_kmod.c',
>  ]
>  
> -if ['x86', 'x86_64'].contains(host_machine.cpu_family())
> -    lib_sources += 'igt_x86.c'
> -endif
> -
>  lib_deps = [
>  	cairo,
>  	glib,
> -- 
> 2.14.1
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Thierry Reding Oct. 12, 2017, 1:56 p.m. UTC | #2
On Thu, Oct 12, 2017 at 04:44:14PM +0300, Ville Syrjälä wrote:
> On Thu, Oct 12, 2017 at 03:29:39PM +0200, Thierry Reding wrote:
> > From: Thierry Reding <treding@nvidia.com>
> > 
> > The meson build avoids the failure by excluding the igt_x86.c file from
> > the compilation. autotools being what they are don't support that in an
> > easy way,
> 
> There is some kind of build_x86 thing in autotools stuff.

Indeed. I'm not sure it could be used, though, because the sources are
listed in Makefile.sources which is also used by the Android build. I
don't think it would understand the conditional.

Thierry
Chris Wilson Oct. 17, 2017, 10:05 p.m. UTC | #3
Quoting Thierry Reding (2017-10-12 14:29:39)
> diff --git a/lib/igt_x86.h b/lib/igt_x86.h
> index d6dcfa108331..27b7f0fd5837 100644
> --- a/lib/igt_x86.h
> +++ b/lib/igt_x86.h
> @@ -40,7 +40,7 @@
>  #define AVX    0x80
>  #define AVX2   0x100
>  
> -#if defined(__x86_64__)
> +#if defined(__x86_64__) || defined(__i386__)
>  unsigned igt_x86_features(void);
>  char *igt_x86_features_to_string(unsigned features, char *line);

This by itself is a build regression from 2a74ae550842. Would be nice to
get this fixed irrespective of the meson fixes.
-Chris
diff mbox

Patch

diff --git a/lib/igt_x86.c b/lib/igt_x86.c
index 0f0963ced044..0ed3c6f1d356 100644
--- a/lib/igt_x86.c
+++ b/lib/igt_x86.c
@@ -93,6 +93,7 @@ 
 
 #define has_YMM 0x1
 
+#if defined(__x86_64__) || defined(__i386__)
 unsigned igt_x86_features(void)
 {
 	unsigned max = __get_cpuid_max(BASIC_CPUID, 0);
@@ -172,3 +173,4 @@  char *igt_x86_features_to_string(unsigned features, char *line)
 
 	return ret;
 }
+#endif
diff --git a/lib/igt_x86.h b/lib/igt_x86.h
index d6dcfa108331..27b7f0fd5837 100644
--- a/lib/igt_x86.h
+++ b/lib/igt_x86.h
@@ -40,7 +40,7 @@ 
 #define AVX	0x80
 #define AVX2	0x100
 
-#if defined(__x86_64__)
+#if defined(__x86_64__) || defined(__i386__)
 unsigned igt_x86_features(void);
 char *igt_x86_features_to_string(unsigned features, char *line);
 #else
diff --git a/lib/meson.build b/lib/meson.build
index 42919eef52a8..e89d4bdf8278 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -56,6 +56,7 @@  lib_sources = [
 	'igt_stats.c',
 	'igt_sysfs.c',
 	'igt_vgem.c',
+	'igt_x86.c',
 	'instdone.c',
 	'intel_batchbuffer.c',
 	'intel_chipset.c',
@@ -88,10 +89,6 @@  lib_sources = [
 	'igt_kmod.c',
 ]
 
-if ['x86', 'x86_64'].contains(host_machine.cpu_family())
-    lib_sources += 'igt_x86.c'
-endif
-
 lib_deps = [
 	cairo,
 	glib,