blob: 8d614e571afa021a9022d02ab5eab43785335b6e [file] [log] [blame]
Andrew Geissler82c905d2020-04-13 13:39:40 -05001From 41cd8836d785c79381764e7de59319f87959a5cf Mon Sep 17 00:00:00 2001
Brad Bishop6dbb3162019-11-25 09:41:34 -05002From: Alistair Francis <alistair@alistair23.me>
3Date: Thu, 14 Nov 2019 09:06:02 -0800
4Subject: [PATCH] Revert "mesa: Enable asm unconditionally, now that
5 gen_matypes is gone."
6
7This reverts commit 20294dceebc23236e33b22578245f7e6f41b6997.
8
9Upstream-Status: Inappropriate [configuration]
10Signed-off-by: Alistair Francis <alistair@alistair23.me>
11
12---
13 meson.build | 94 ++++++++++++++++++++++++++++++-----------------
14 meson_options.txt | 6 +++
15 2 files changed, 67 insertions(+), 33 deletions(-)
16
17diff --git a/meson.build b/meson.build
Andrew Geissler82c905d2020-04-13 13:39:40 -050018index 62864c6..b53be8d 100644
Brad Bishop6dbb3162019-11-25 09:41:34 -050019--- a/meson.build
20+++ b/meson.build
21@@ -49,6 +49,7 @@ with_vulkan_icd_dir = get_option('vulkan-icd-dir')
22 with_tests = get_option('build-tests')
23 with_valgrind = get_option('valgrind')
24 with_libunwind = get_option('libunwind')
25+with_asm = get_option('asm')
26 with_glx_read_only_text = get_option('glx-read-only-text')
27 with_glx_direct = get_option('glx-direct')
28 with_osmesa = get_option('osmesa')
Andrew Geissler82c905d2020-04-13 13:39:40 -050029@@ -1093,41 +1094,68 @@ dep_ws2_32 = cc.find_library('ws2_32', required : with_platform_windows)
Brad Bishop6dbb3162019-11-25 09:41:34 -050030
31 # TODO: shared/static? Is this even worth doing?
32
33+# When cross compiling we generally need to turn off the use of assembly,
34+# because mesa's assembly relies on building an executable for the host system,
35+# and running it to get information about struct sizes. There is at least one
36+# case of cross compiling where we can use asm, and that's x86_64 -> x86 when
37+# host OS == build OS, since in that case the build machine can run the host's
38+# binaries.
39+if with_asm and meson.is_cross_build()
40+ if build_machine.system() != host_machine.system()
41+ # TODO: It may be possible to do this with an exe_wrapper (like wine).
42+ message('Cross compiling from one OS to another, disabling assembly.')
43+ with_asm = false
44+ elif not (build_machine.cpu_family().startswith('x86') and host_machine.cpu_family() == 'x86')
45+ # FIXME: Gentoo always sets -m32 for x86_64 -> x86 builds, resulting in an
46+ # x86 -> x86 cross compile. We use startswith rather than == to handle this
47+ # case.
48+ # TODO: There may be other cases where the 64 bit version of the
49+ # architecture can run 32 bit binaries (aarch64 and armv7 for example)
50+ message('''
51+ Cross compiling to different architectures, and the host cannot run
52+ the build machine's binaries. Disabling assembly.
53+ ''')
54+ with_asm = false
55+ endif
56+endif
57+
58 with_asm_arch = ''
59-if host_machine.cpu_family() == 'x86'
60- if system_has_kms_drm or host_machine.system() == 'gnu'
61- with_asm_arch = 'x86'
62- pre_args += ['-DUSE_X86_ASM', '-DUSE_MMX_ASM', '-DUSE_3DNOW_ASM',
63- '-DUSE_SSE_ASM']
64-
65- if with_glx_read_only_text
66- pre_args += ['-DGLX_X86_READONLY_TEXT']
67+if with_asm
68+ if host_machine.cpu_family() == 'x86'
69+ if system_has_kms_drm or host_machine.system() == 'gnu'
70+ with_asm_arch = 'x86'
71+ pre_args += ['-DUSE_X86_ASM', '-DUSE_MMX_ASM', '-DUSE_3DNOW_ASM',
72+ '-DUSE_SSE_ASM']
73+
74+ if with_glx_read_only_text
75+ pre_args += ['-DGLX_X86_READONLY_TEXT']
76+ endif
77+ endif
78+ elif host_machine.cpu_family() == 'x86_64'
79+ if system_has_kms_drm
80+ with_asm_arch = 'x86_64'
81+ pre_args += ['-DUSE_X86_64_ASM']
82+ endif
83+ elif host_machine.cpu_family() == 'arm'
84+ if system_has_kms_drm
85+ with_asm_arch = 'arm'
86+ pre_args += ['-DUSE_ARM_ASM']
87+ endif
88+ elif host_machine.cpu_family() == 'aarch64'
89+ if system_has_kms_drm
90+ with_asm_arch = 'aarch64'
91+ pre_args += ['-DUSE_AARCH64_ASM']
92+ endif
93+ elif host_machine.cpu_family() == 'sparc64'
94+ if system_has_kms_drm
95+ with_asm_arch = 'sparc'
96+ pre_args += ['-DUSE_SPARC_ASM']
97+ endif
98+ elif host_machine.cpu_family().startswith('ppc64') and host_machine.endian() == 'little'
99+ if system_has_kms_drm
100+ with_asm_arch = 'ppc64le'
101+ pre_args += ['-DUSE_PPC64LE_ASM']
102 endif
103- endif
104-elif host_machine.cpu_family() == 'x86_64'
105- if system_has_kms_drm
106- with_asm_arch = 'x86_64'
107- pre_args += ['-DUSE_X86_64_ASM']
108- endif
109-elif host_machine.cpu_family() == 'arm'
110- if system_has_kms_drm
111- with_asm_arch = 'arm'
112- pre_args += ['-DUSE_ARM_ASM']
113- endif
114-elif host_machine.cpu_family() == 'aarch64'
115- if system_has_kms_drm
116- with_asm_arch = 'aarch64'
117- pre_args += ['-DUSE_AARCH64_ASM']
118- endif
119-elif host_machine.cpu_family() == 'sparc64'
120- if system_has_kms_drm
121- with_asm_arch = 'sparc'
122- pre_args += ['-DUSE_SPARC_ASM']
123- endif
124-elif host_machine.cpu_family().startswith('ppc64') and host_machine.endian() == 'little'
125- if system_has_kms_drm
126- with_asm_arch = 'ppc64le'
127- pre_args += ['-DUSE_PPC64LE_ASM']
128 endif
129 endif
130
131diff --git a/meson_options.txt b/meson_options.txt
Andrew Geissler82c905d2020-04-13 13:39:40 -0500132index 700c34c..62e8472 100644
Brad Bishop6dbb3162019-11-25 09:41:34 -0500133--- a/meson_options.txt
134+++ b/meson_options.txt
Andrew Geissler82c905d2020-04-13 13:39:40 -0500135@@ -241,6 +241,12 @@ option(
Brad Bishop6dbb3162019-11-25 09:41:34 -0500136 value : false,
137 description : 'Enable GLVND support.'
138 )
139+option(
140+ 'asm',
141+ type : 'boolean',
142+ value : true,
143+ description : 'Build assembly code if possible'
144+)
145 option(
146 'glx-read-only-text',
147 type : 'boolean',