forked from enlightenment/efl
meson: cleanup the native-cpu optimization build code
you were not able to disable the header checks, so if the header was not there it indicated that you could turn it of. However, the option check was in the has_header if not outside of it. Further more, header checks are done in the subdirectory that is done for header checks, unneccessary cpu_**** flags are removed, global optimization options are added to the global_arguments instead of just the package_c_args, which leads to the fact that also all binaries etc. are build by default with those optimization flags. This also reduces the amount of options to a minimum of 1 option, to just control if there should be the optimization or not. This also changes from host_maschine to target_mschine, since we probebly want to enable the optimization for the target maschine, not the host. Differential Revision: https://phab.enlightenment.org/D7296
This commit is contained in:
parent
ae543adbd1
commit
46422187d8
|
@ -1,3 +1,19 @@
|
||||||
|
if get_option('native-arch-optimization')
|
||||||
|
if target_machine.cpu_family() == 'x86' or target_machine.cpu_family() == 'x86_64'
|
||||||
|
native_header = 'immintrin.h'
|
||||||
|
elif target_machine.cpu_family() == 'arm'
|
||||||
|
native_header = 'arm_neon.h'
|
||||||
|
elif target_machine.cpu_family() == 'aarch64'
|
||||||
|
native_header = 'arm_neon.h'
|
||||||
|
elif target_machine.cpu_family() == 'ppc' or target_machine.cpu_family() == 'ppc64'
|
||||||
|
native_header = 'altivec.h'
|
||||||
|
endif
|
||||||
|
|
||||||
|
if cc.has_header(native_header) == false
|
||||||
|
error('Error, header '+native_header+' is required')
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
header_checks = [
|
header_checks = [
|
||||||
'alloca.h',
|
'alloca.h',
|
||||||
'asm/hwcap.h',
|
'asm/hwcap.h',
|
||||||
|
|
83
meson.build
83
meson.build
|
@ -112,73 +112,37 @@ if compiler.compiles(code, args : '-lc', name : 'environ check') == true
|
||||||
endif
|
endif
|
||||||
|
|
||||||
## or should this be target_machine?
|
## or should this be target_machine?
|
||||||
cpu_mmx = false
|
|
||||||
cpu_sse3 = false
|
cpu_sse3 = false
|
||||||
cpu_neon = false
|
cpu_neon = false
|
||||||
cpu_neon_intrinsics = false
|
cpu_neon_intrinsics = false
|
||||||
cpu_altivec = false
|
native_arch_opt_c_args = [ '-msse3' ]
|
||||||
evas_opt_c_args = [ ]
|
|
||||||
draw_opt_c_args = [ ]
|
|
||||||
ector_opt_c_args = [ ]
|
|
||||||
machine_c_args = [ ]
|
|
||||||
compiler = meson.get_compiler('c')
|
|
||||||
|
|
||||||
if host_machine.endian() == 'big'
|
if host_machine.endian() == 'big'
|
||||||
config_h.set10('WORDS_BIGENDIAN', true)
|
config_h.set10('WORDS_BIGENDIAN', true)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if host_machine.cpu_family() == 'x86' or host_machine.cpu_family() == 'x86_64'
|
if get_option('native-arch-optimization')
|
||||||
if compiler.has_header('immintrin.h') == true
|
if target_machine.cpu_family() == 'x86' or target_machine.cpu_family() == 'x86_64'
|
||||||
if (get_option('cpu-mmx') == true)
|
config_h.set10('BUILD_MMX', true)
|
||||||
config_h.set10('BUILD_MMX', true)
|
message('x86 build - MMX enabled')
|
||||||
cpu_mmx = true
|
config_h.set10('BUILD_SSE3', true)
|
||||||
message('x86 build - MMX enabled')
|
cpu_sse3 = true
|
||||||
if (get_option('cpu-sse3') == true)
|
message('x86 build - SSE3 enabled')
|
||||||
config_h.set10('BUILD_SSE3', true)
|
elif target_machine.cpu_family() == 'arm'
|
||||||
evas_opt_c_args += [ '-msse3' ]
|
config_h.set10('BUILD_NEON', true)
|
||||||
draw_opt_c_args += [ '-msse3' ]
|
cpu_neon = true
|
||||||
ector_opt_c_args += [ '-msse3' ]
|
message('ARM build - NEON enabled')
|
||||||
cpu_sse3 = true
|
elif target_machine.cpu_family() == 'aarch64'
|
||||||
message('x86 build - SSE3 enabled')
|
config_h.set10('BUILD_NEON', true)
|
||||||
endif
|
config_h.set10('BUILD_NEON_INTRINSICS', true)
|
||||||
endif
|
add_global_arguments('-ftree-vectorize', language: 'c')
|
||||||
else
|
cpu_neon = true
|
||||||
error('Perhaps you wish to disble MMX with -Dcpu-mmx=false')
|
cpu_neon_intrinsics = true
|
||||||
endif
|
message('ARM64 build - NEON + intrinsics enabled')
|
||||||
elif host_machine.cpu_family() == 'arm'
|
elif target_machine.cpu_family() == 'ppc' or target_machine.cpu_family() == 'ppc64'
|
||||||
if compiler.has_header('arm_neon.h') == true
|
config_h.set10('BUILD_ALTIVEC', true)
|
||||||
if (get_option('cpu-neon') == true)
|
add_global_arguments('-maltivec-vectorize', language: 'c')
|
||||||
config_h.set10('BUILD_NEON', true)
|
message('PPC/POWER build - ALTIVEC enabled')
|
||||||
machine_c_args += ['-mfpu=neon', '-ftree-vectorize']
|
|
||||||
cpu_neon = true
|
|
||||||
message('ARM build - NEON enabled')
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
error('Perhaps you wish to disble NEON with -Dcpu-neon=false')
|
|
||||||
endif
|
|
||||||
elif host_machine.cpu_family() == 'aarch64'
|
|
||||||
if compiler.has_header('arm_neon.h') == true
|
|
||||||
if (get_option('cpu-neon') == true)
|
|
||||||
config_h.set10('BUILD_NEON', true)
|
|
||||||
config_h.set10('BUILD_NEON_INTRINSICS', true)
|
|
||||||
machine_c_args += ['-ftree-vectorize']
|
|
||||||
cpu_neon = true
|
|
||||||
cpu_neon_intrinsics = true
|
|
||||||
message('ARM64 build - NEON + intrinsics enabled')
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
error('Perhaps you wish to disble NEON with -Dcpu-neon=false')
|
|
||||||
endif
|
|
||||||
elif host_machine.cpu_family() == 'ppc' or host_machine.cpu_family() == 'ppc64'
|
|
||||||
if compiler.has_header('altivec.h') == true
|
|
||||||
if (get_option('cpu-akltivec') == true)
|
|
||||||
config_h.set10('BUILD_ALTIVEC', true)
|
|
||||||
machine_c_args += [ '-maltivec' ]
|
|
||||||
cpu_altivec = true
|
|
||||||
message('PPC/POWER build - ALTIVEC enabled')
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
error('Perhaps you wish to disble NEON with -Dcpu-altivec=false')
|
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -303,7 +267,6 @@ foreach package : subprojects
|
||||||
package_c_args = [
|
package_c_args = [
|
||||||
'-DPACKAGE_DATA_DIR="'+ join_paths(dir_data, package_name)+'"',
|
'-DPACKAGE_DATA_DIR="'+ join_paths(dir_data, package_name)+'"',
|
||||||
'-DNEED_RUN_IN_TREE=1',
|
'-DNEED_RUN_IN_TREE=1',
|
||||||
machine_c_args
|
|
||||||
]
|
]
|
||||||
automatic_pkgfile = true
|
automatic_pkgfile = true
|
||||||
if package[1].length() == 0 or get_option(package[1][0])
|
if package[1].length() == 0 or get_option(package[1][0])
|
||||||
|
|
|
@ -328,27 +328,8 @@ option('mono',
|
||||||
description: 'Flag for handling c# bindings'
|
description: 'Flag for handling c# bindings'
|
||||||
)
|
)
|
||||||
|
|
||||||
option('cpu-mmx',
|
option('native-arch-optimization',
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
value: true,
|
value: true,
|
||||||
description: 'Build MMX support when building for intel'
|
description: 'Flag for enabling architecture native optimizations'
|
||||||
)
|
)
|
||||||
|
|
||||||
option('cpu-sse3',
|
|
||||||
type: 'boolean',
|
|
||||||
value: true,
|
|
||||||
description: 'Build SSE3 support when building for intel'
|
|
||||||
)
|
|
||||||
|
|
||||||
option('cpu-neon',
|
|
||||||
type: 'boolean',
|
|
||||||
value: true,
|
|
||||||
description: 'Build NEON support when building for ARM'
|
|
||||||
)
|
|
||||||
|
|
||||||
option('cpu-altivec',
|
|
||||||
type: 'boolean',
|
|
||||||
value: true,
|
|
||||||
description: 'Build ALTIVEC support when building for PPC/POWER'
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ if cpu_sse3 == true
|
||||||
sources: pub_eo_file_target + [ 'ector_software_gradient_sse3.c' ],
|
sources: pub_eo_file_target + [ 'ector_software_gradient_sse3.c' ],
|
||||||
dependencies: ector_pub_deps + [triangulator, freetype, draw, m] + ector_deps,
|
dependencies: ector_pub_deps + [triangulator, freetype, draw, m] + ector_deps,
|
||||||
include_directories: config_dir + [ include_directories('..') ],
|
include_directories: config_dir + [ include_directories('..') ],
|
||||||
c_args: ector_opt_c_args,
|
c_args: native_arch_opt_c_args,
|
||||||
)
|
)
|
||||||
ector_opt_lib += [ ector_opt ]
|
ector_opt_lib += [ ector_opt ]
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -188,7 +188,7 @@ if cpu_sse3 == true or cpu_neon == true and cpu_neon_intrinsics == false
|
||||||
[ include_directories('../../..') ] +
|
[ include_directories('../../..') ] +
|
||||||
evas_include_directories +
|
evas_include_directories +
|
||||||
[vg_common_inc_dir],
|
[vg_common_inc_dir],
|
||||||
c_args: evas_opt_c_args,
|
c_args: native_arch_opt_c_args,
|
||||||
dependencies: [eina, eo, ector, emile, evas_deps, m],
|
dependencies: [eina, eo, ector, emile, evas_deps, m],
|
||||||
)
|
)
|
||||||
evas_link += [ evas_opt ]
|
evas_link += [ evas_opt ]
|
||||||
|
|
|
@ -13,7 +13,7 @@ if cpu_sse3 == true
|
||||||
draw_opt = static_library('draw_opt',
|
draw_opt = static_library('draw_opt',
|
||||||
sources: [ 'draw_main_sse2.c' ],
|
sources: [ 'draw_main_sse2.c' ],
|
||||||
include_directories: config_dir + [include_directories(join_paths('..', '..', 'lib'))],
|
include_directories: config_dir + [include_directories(join_paths('..', '..', 'lib'))],
|
||||||
c_args: draw_opt_c_args,
|
c_args: native_arch_opt_c_args,
|
||||||
dependencies : [eina, efl]
|
dependencies : [eina, efl]
|
||||||
)
|
)
|
||||||
draw_opt_lib += [ draw_opt ]
|
draw_opt_lib += [ draw_opt ]
|
||||||
|
|
Loading…
Reference in New Issue