diff options
author | Jack Lloyd <[email protected]> | 2017-01-22 15:15:19 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-01-22 15:15:19 -0500 |
commit | 8775c0ad6887d39e620191a758a44d86b07449b2 (patch) | |
tree | 4be2d72b04301490d4c5fa7ab441584875e225fa | |
parent | c58b07498a1fbd3678ede3006dc55502e1d862aa (diff) |
Fix configure.py error when compiler doesn't support desired ISA flags
Seen with rarely tested compilers (Sun Studio, Intel, ...) that we are missing
info for. Previously this led to a hard error which is pointless. Instead just
disable the relevant module and warn the user that something was disabled, if
they want to go look into why.
Remove bogus clmul entry in x86_64 - actually we lump both AES and CLMUL flags
under the same ISA ("aesni") since all known CPUs support either both or
neither. Caught by new configure warning.
Add Sun Studio ISA flags from GH #846
-rwxr-xr-x | configure.py | 24 | ||||
-rw-r--r-- | src/build-data/arch/x86_64.txt | 1 | ||||
-rw-r--r-- | src/build-data/cc/sunstudio.txt | 15 |
3 files changed, 30 insertions, 10 deletions
diff --git a/configure.py b/configure.py index 3d4924ec5..7559f75ec 100755 --- a/configure.py +++ b/configure.py @@ -829,7 +829,7 @@ class ArchInfo(object): [k for k in self.submodel_aliases.items()], key=lambda k: len(k[0]), reverse=True) - def defines(self, options): + def defines(self, cc, options): """ Return CPU-specific defines for build.h """ @@ -837,8 +837,9 @@ class ArchInfo(object): def form_macro(cpu_name): return cpu_name.upper().replace('.', '').replace('-', '_') - macros = ['TARGET_ARCH_IS_%s' % - (form_macro(self.basename.upper()))] + macros = [] + + macros.append('TARGET_ARCH_IS_%s' % (form_macro(self.basename.upper()))) if self.basename != options.cpu: macros.append('TARGET_CPU_IS_%s' % (form_macro(options.cpu))) @@ -849,7 +850,10 @@ class ArchInfo(object): isa_extensions = sorted(enabled_isas - disabled_isas) for isa in isa_extensions: - macros.append('TARGET_SUPPORTS_%s' % (form_macro(isa))) + if cc.isa_flags_for(isa, self.basename) is not None: + macros.append('TARGET_SUPPORTS_%s' % (form_macro(isa))) + else: + logging.warning("Disabling support for %s intrinsics due to missing flag for compiler" % (isa)) endian = options.with_endian or self.endian @@ -1333,10 +1337,12 @@ def gen_makefile_lists(var, build_config, options, modules, cc, arch, osinfo): def isa_specific_flags(cc, src): def simd_dependencies(): - if 'sse2' in arch.isa_extensions: - return ['sse2'] - elif 'altivec' in arch.isa_extensions: - return ['altivec'] + + for simd32_impl in ['sse2', 'altivec']: + if simd32_impl in arch.isa_extensions and cc.isa_flags_for(simd32_impl, arch.basename) is not None: + return [simd32_impl] + + # default scalar return [] for mod in modules: @@ -1583,7 +1589,7 @@ def create_template_vars(build_config, options, modules, cc, arch, osinfo): 'target_compiler_defines': make_cpp_macros(cc.defines()), - 'target_cpu_defines': make_cpp_macros(arch.defines(options)), + 'target_cpu_defines': make_cpp_macros(arch.defines(cc, options)), 'botan_include_dir': build_config.botan_include_dir, diff --git a/src/build-data/arch/x86_64.txt b/src/build-data/arch/x86_64.txt index b5010867d..33d9f5bd5 100644 --- a/src/build-data/arch/x86_64.txt +++ b/src/build-data/arch/x86_64.txt @@ -43,7 +43,6 @@ sse4.1 sse4.2 avx2 aesni -clmul rdrand rdseed sha diff --git a/src/build-data/cc/sunstudio.txt b/src/build-data/cc/sunstudio.txt index 9ace5107c..2a392a442 100644 --- a/src/build-data/cc/sunstudio.txt +++ b/src/build-data/cc/sunstudio.txt @@ -54,3 +54,18 @@ linux -> "-library=stlport4" sparc64 -> "-xarch=v9" x86_64 -> "-m64" </mach_abi_linking> + +<isa_flags> +# Botan needs C++11, and that requires Sun Studio 12.4 or above. +# Sun Studio 12.4 supports upto -xarch=avx2, but the processor must support it +# AESNI requires -xarch=aes, and RDRAND requires -xarch=avx_i. +# https://docs.oracle.com/cd/E37069_01/html/E37074/bjapp.html#OSSCGbkazd +sse2 -> "-xarch=sse2" +ssse3 -> "-xarch=ssse3" +sse4.1 -> "-xarch=sse4_1" +sse4.2 -> "-xarch=sse4_2" +aesni -> "-xarch=aes" +avx -> "-xarch=avx" +rdrand -> "-xarch=avx_i" +avx2 -> "-xarch=avx2" +</isa_flags> |