From 6c7b3fc30ede3f78cc91868e496ff9b4476423a6 Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Mon, 11 Dec 2017 16:25:06 -0500 Subject: Clean up macro generation --- configure.py | 24 ++++++++---------------- src/build-data/buildh.in | 30 +++++++++++++++++++++++------- src/scripts/install.py | 2 +- 3 files changed, 32 insertions(+), 24 deletions(-) diff --git a/configure.py b/configure.py index bfd1a0102..f9092108a 100755 --- a/configure.py +++ b/configure.py @@ -1029,8 +1029,6 @@ class ArchInfo(InfoObject): if self.family is not None: macros.append('TARGET_CPU_IS_%s_FAMILY' % (self.family.upper())) - macros.append('TARGET_CPU_NATIVE_WORD_SIZE %d' % (self.wordsize)) - if self.wordsize == 64: macros.append('TARGET_CPU_HAS_NATIVE_64BIT') @@ -1729,9 +1727,6 @@ def create_template_vars(source_paths, build_config, options, modules, cc, arch, Create the template variables needed to process the makefile, build.h, etc """ - def make_cpp_macros(macros): - return '\n'.join(['#define BOTAN_' + macro for macro in macros]) - def external_link_cmd(): return (' ' + cc.add_lib_dir_option + options.with_external_libdir) if options.with_external_libdir else '' @@ -1910,22 +1905,19 @@ def create_template_vars(source_paths, build_config, options, modules, cc, arch, 'libs_used': [lib.replace('.lib', '') for lib in link_to('libs')], 'include_paths': build_config.format_include_paths(cc, options.with_external_includedir), - 'module_defines': make_cpp_macros(sorted(flatten([m.defines() for m in modules]))), - - 'target_os_defines': make_cpp_macros(osinfo.defines(options)), + 'module_defines': sorted(flatten([m.defines() for m in modules])), - 'target_compiler_defines': make_cpp_macros(cc.defines()), - - 'target_cpu_defines': make_cpp_macros(arch.defines(cc, options)), + 'os_defines': osinfo.defines(options), + 'cc_defines': cc.defines(), + 'cpu_defines': arch.defines(cc, options), + 'house_ecc_curve_defines': house_ecc_curve_macros(options.house_curve), 'botan_include_dir': build_config.botan_include_dir, - 'unsafe_fuzzer_mode_define': '#define BOTAN_UNSAFE_FUZZER_MODE' if options.unsafe_fuzzer_mode else '', - 'fuzzer_type': '#define BOTAN_FUZZER_IS_%s' % (options.build_fuzzers.upper()) if options.build_fuzzers else '', - - 'mod_list': '\n'.join(sorted([m.basename for m in modules])), + 'fuzzer_mode': options.unsafe_fuzzer_mode, + 'fuzzer_type': options.build_fuzzers.upper() if options.build_fuzzers else '', - 'house_ecc_curve_defines': make_cpp_macros(house_ecc_curve_macros(options.house_curve)) + 'mod_list': sorted([m.basename for m in modules]) } if options.os != 'windows': diff --git a/src/build-data/buildh.in b/src/build-data/buildh.in index 822a73c44..aeae12cec 100644 --- a/src/build-data/buildh.in +++ b/src/build-data/buildh.in @@ -24,8 +24,13 @@ /* How many bits per limb in a BigInt */ #define BOTAN_MP_WORD_BITS %{mp_bits} -%{unsafe_fuzzer_mode_define} -%{fuzzer_type} + +%{if fuzzer_mode} +#define BOTAN_UNSAFE_FUZZER_MODE +%{endif} +%{if fuzzer_type} +#define BOTAN_FUZZER_IS_%{fuzzer_type} +%{endif} #define BOTAN_INSTALL_PREFIX R"(%{prefix})" #define BOTAN_INSTALL_HEADER_DIR "%{includedir}/botan-%{version_major}" @@ -38,22 +43,33 @@ #endif /* Target identification and feature test macros */ -%{target_os_defines} +%{for os_defines} +#define BOTAN_%{i} +%{endfor} -%{target_cpu_defines} +%{for cc_defines} +#define BOTAN_%{i} +%{endfor} -%{target_compiler_defines} +%{for cpu_defines} +#define BOTAN_%{i} +%{endfor} /* * Module availability definitions */ -%{module_defines} +%{for module_defines} +#define BOTAN_%{i} +%{endfor} /* * Local/misc configuration options (if any) follow */ %{local_config} -%{house_ecc_curve_defines} + +%{for house_ecc_curve_defines} +%{i} +%{endfor} /* * Things you can edit (but probably shouldn't) diff --git a/src/scripts/install.py b/src/scripts/install.py index c6e4ec2cd..d30493ebe 100755 --- a/src/scripts/install.py +++ b/src/scripts/install.py @@ -229,7 +229,7 @@ def main(args): copy_file(cfg['botan_pkgconfig'], prepend_destdir(os.path.join(pkgconfig_dir, os.path.basename(cfg['botan_pkgconfig'])))) - if 'ffi' in cfg['mod_list'].split('\n'): + if 'ffi' in cfg['mod_list']: for ver in cfg['python_version'].split(','): py_lib_path = os.path.join(lib_dir, 'python%s' % (ver), 'site-packages') logging.debug('Installing python module to %s' % (py_lib_path)) -- cgit v1.2.3 From d01025961ffe8b928be751d5adc3000dd34739a4 Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Mon, 11 Dec 2017 16:38:31 -0500 Subject: More simplifications --- configure.py | 18 +++++++++--------- src/build-data/buildh.in | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/configure.py b/configure.py index f9092108a..c116c5f08 100755 --- a/configure.py +++ b/configure.py @@ -863,7 +863,7 @@ class ModuleInfo(InfoObject): return self.header_external def defines(self): - return ['HAS_%s %s' % (key, value) for key, value in self._defines.items()] + return [(key + ' ' + value) for key, value in self._defines.items()] def compatible_cpu(self, archinfo, options): arch_name = archinfo.basename @@ -1370,18 +1370,18 @@ class OsInfo(InfoObject): # pylint: disable=too-many-instance-attributes def defines(self, options): r = [] - r += ['TARGET_OS_IS_%s' % (self.basename.upper())] + r += ['IS_%s' % (self.basename.upper())] if self.os_type != None: - r += ['TARGET_OS_TYPE_IS_%s' % (self.os_type.upper())] + r += ['TYPE_IS_%s' % (self.os_type.upper())] def feat_macros(): for feat in self.target_features: if feat not in options.without_os_features: - yield 'TARGET_OS_HAS_' + feat.upper() + yield 'HAS_' + feat.upper() for feat in options.with_os_features: if feat not in self.target_features: - yield 'TARGET_OS_HAS_' + feat.upper() + yield 'HAS_' + feat.upper() r += sorted(feat_macros()) return r @@ -1715,10 +1715,10 @@ def house_ecc_curve_macros(house_curve): if curve_id < 0xfe00 or curve_id > 0xfeff: raise UserError('TLS curve ID not in reserved range (see RFC 4492)') - return ['HOUSE_ECC_CURVE_NAME \"' + p[1] + '\"', - 'HOUSE_ECC_CURVE_OID \"' + p[2] + '\"', - 'HOUSE_ECC_CURVE_PEM ' + _read_pem(filepath=p[0]), - 'HOUSE_ECC_CURVE_TLS_ID ' + hex(curve_id)] + return ['NAME \"' + p[1] + '\"', + 'OID \"' + p[2] + '\"', + 'PEM ' + _read_pem(filepath=p[0]), + 'TLS_ID ' + hex(curve_id)] def create_template_vars(source_paths, build_config, options, modules, cc, arch, osinfo): #pylint: disable=too-many-locals,too-many-branches,too-many-statements diff --git a/src/build-data/buildh.in b/src/build-data/buildh.in index aeae12cec..6d814398c 100644 --- a/src/build-data/buildh.in +++ b/src/build-data/buildh.in @@ -44,7 +44,7 @@ /* Target identification and feature test macros */ %{for os_defines} -#define BOTAN_%{i} +#define BOTAN_TARGET_OS_%{i} %{endfor} %{for cc_defines} @@ -59,7 +59,7 @@ * Module availability definitions */ %{for module_defines} -#define BOTAN_%{i} +#define BOTAN_HAS_%{i} %{endfor} /* @@ -68,7 +68,7 @@ %{local_config} %{for house_ecc_curve_defines} -%{i} +#define BOTAN_HOUSE_ECC_CURVE_%{i} %{endfor} /* -- cgit v1.2.3 From 3a527421fef669690b610286f35aec0d8498939d Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Mon, 11 Dec 2017 19:52:13 -0500 Subject: Further cleanup of macro generation in build.h --- configure.py | 114 +++++++++++++++++------------------------------ src/build-data/buildh.in | 33 +++++++++++--- 2 files changed, 70 insertions(+), 77 deletions(-) diff --git a/configure.py b/configure.py index c116c5f08..794eb2ecc 100755 --- a/configure.py +++ b/configure.py @@ -574,10 +574,9 @@ def process_command_line(args): # pylint: disable=too-many-locals if args != []: raise UserError('Unhandled option(s): ' + ' '.join(args)) - if options.with_endian != None and \ - options.with_endian not in ['little', 'big']: - raise UserError('Bad value to --with-endian "%s"' % ( - options.with_endian)) + + if options.with_endian not in [None, 'little', 'big']: + raise UserError('Bad value to --with-endian "%s"' % (options.with_endian)) if options.debug_mode: options.no_optimizations = True @@ -798,6 +797,8 @@ class ModuleInfo(InfoObject): if filename.count(':') == 0: return os.path.join(self.lives_in, filename) + # TODO is this used anymore??? Probably can be removed. + # modules can request to add files of the form # MODULE_NAME:FILE_NAME to add a file from another module # For these, assume other module is always in a @@ -994,6 +995,16 @@ class ArchInfo(InfoObject): [k for k in self.submodel_aliases.items()], key=lambda k: len(k[0]), reverse=True) + def supported_isa_extensions(self, cc, options): + isas = [] + + for isa in self.isa_extensions: + if isa not in options.disable_intrinsics: + if cc.isa_flags_for(isa, self.basename) is not None: + isas.append(isa) + + return sorted(isas) + def defines(self, cc, options): """ Return CPU-specific defines for build.h @@ -1002,43 +1013,7 @@ class ArchInfo(InfoObject): def form_macro(cpu_name): return cpu_name.upper().replace('.', '').replace('-', '_') - 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))) - - enabled_isas = set(self.isa_extensions) - disabled_isas = set(options.disable_intrinsics) - - isa_extensions = sorted(enabled_isas - disabled_isas) - - for isa in isa_extensions: - 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 - - if endian != None: - macros.append('TARGET_CPU_IS_%s_ENDIAN' % (endian.upper())) - logging.info('Assuming CPU is %s endian' % (endian)) - - if self.family is not None: - macros.append('TARGET_CPU_IS_%s_FAMILY' % (self.family.upper())) - - if self.wordsize == 64: - macros.append('TARGET_CPU_HAS_NATIVE_64BIT') - - if options.with_valgrind: - macros.append('HAS_VALGRIND') - - if options.with_openmp: - macros.append('TARGET_HAS_OPENMP') - - return macros + return ['TARGET_SUPPORTS_' + form_macro(isa) for isa in self.supported_isa_extensions(cc, options)] MachOptFlags = collections.namedtuple('MachOptFlags', ['flags', 'submodel_prefix']) @@ -1285,14 +1260,6 @@ class CompilerInfo(InfoObject): # pylint: disable=too-many-instance-attributes return '$(LINKER)' - def defines(self): - """ - Return defines for build.h - """ - - return ['BUILD_COMPILER_IS_' + self.macro_name] - - class OsInfo(InfoObject): # pylint: disable=too-many-instance-attributes def __init__(self, infofile): super(OsInfo, self).__init__(infofile) @@ -1368,24 +1335,16 @@ class OsInfo(InfoObject): # pylint: disable=too-many-instance-attributes self.static_suffix = lex.static_suffix self.target_features = lex.target_features - def defines(self, options): - r = [] - r += ['IS_%s' % (self.basename.upper())] - - if self.os_type != None: - r += ['TYPE_IS_%s' % (self.os_type.upper())] - - def feat_macros(): - for feat in self.target_features: - if feat not in options.without_os_features: - yield 'HAS_' + feat.upper() - for feat in options.with_os_features: - if feat not in self.target_features: - yield 'HAS_' + feat.upper() - - r += sorted(feat_macros()) - return r + def enabled_features(self, options): + feats = [] + for feat in self.target_features: + if feat not in options.without_os_features: + feats.append(feat) + for feat in options.with_os_features: + if feat not in self.target_features: + feats.append(feat) + return sorted(feats) def fixup_proc_name(proc): proc = proc.lower().replace(' ', '') @@ -1481,7 +1440,7 @@ def process_template(template_file, variables): def __init__(self, vals): self.vals = vals - self.value_pattern = re.compile(r'%{([a-z][a-z_0-9]+)}') + self.value_pattern = re.compile(r'%{([a-z][a-z_0-9\|]+)}') self.cond_pattern = re.compile('%{(if|unless) ([a-z][a-z_0-9]+)}') self.for_pattern = re.compile('(.*)%{for ([a-z][a-z_0-9]+)}') self.join_pattern = re.compile('(.*)%{join ([a-z][a-z_0-9]+)}') @@ -1492,6 +1451,11 @@ def process_template(template_file, variables): v = match.group(1) if v in self.vals: return str(self.vals.get(v)) + if v.endswith('|upper'): + v = v.replace('|upper', '') + if v in self.vals: + return str(self.vals.get(v)).upper() + raise KeyError(v) lines = template.splitlines() @@ -1554,7 +1518,7 @@ def process_template(template_file, variables): for_val = for_val.replace('%{' + ik + '}', iv) output += for_val + "\n" else: - output += for_body.replace('%{i}', v) + output += for_body.replace('%{i}', v).replace('%{i|upper}', v.upper()) output += "\n" else: output += lines[idx] + "\n" @@ -1849,7 +1813,10 @@ def create_template_vars(source_paths, build_config, options, modules, cc, arch, 'os': options.os, 'arch': options.arch, + 'cpu_family': arch.family, 'submodel': options.cpu, + 'endian': options.with_endian or arch.endian, + 'cpu_is_64bit': arch.wordsize == 64, 'bakefile_arch': 'x86' if options.arch == 'x86_32' else 'x86_64', @@ -1878,6 +1845,7 @@ def create_template_vars(source_paths, build_config, options, modules, cc, arch, 'ldflags': options.ldflags or '', 'cc_warning_flags': cc.cc_warning_flags(options), 'output_to_exe': cc.output_to_exe, + 'cc_macro': cc.macro_name, 'shared_flags': cc.gen_shared_flags(options), 'cmake_shared_flags': cmake_escape(cc.gen_shared_flags(options)), @@ -1907,16 +1875,18 @@ def create_template_vars(source_paths, build_config, options, modules, cc, arch, 'include_paths': build_config.format_include_paths(cc, options.with_external_includedir), 'module_defines': sorted(flatten([m.defines() for m in modules])), - 'os_defines': osinfo.defines(options), - 'cc_defines': cc.defines(), + 'os_features': osinfo.enabled_features(options), + 'os_name': osinfo.basename, + 'os_type': osinfo.os_type, 'cpu_defines': arch.defines(cc, options), 'house_ecc_curve_defines': house_ecc_curve_macros(options.house_curve), - 'botan_include_dir': build_config.botan_include_dir, - 'fuzzer_mode': options.unsafe_fuzzer_mode, 'fuzzer_type': options.build_fuzzers.upper() if options.build_fuzzers else '', + 'with_valgrind': options.with_valgrind, + 'with_openmp': options.with_openmp, + 'mod_list': sorted([m.basename for m in modules]) } diff --git a/src/build-data/buildh.in b/src/build-data/buildh.in index 6d814398c..1e32532db 100644 --- a/src/build-data/buildh.in +++ b/src/build-data/buildh.in @@ -43,18 +43,41 @@ #endif /* Target identification and feature test macros */ -%{for os_defines} -#define BOTAN_TARGET_OS_%{i} -%{endfor} -%{for cc_defines} -#define BOTAN_%{i} +#define BOTAN_TARGET_OS_IS_%{os_name|upper} +%{if os_type} +#define BOTAN_TARGET_OS_TYPE_IS_%{os_type|upper} +%{endif} + +%{for os_features} +#define BOTAN_TARGET_OS_HAS_%{i|upper} %{endfor} +#define BOTAN_BUILD_COMPILER_IS_%{cc_macro} + +#define BOTAN_TARGET_ARCH_IS_%{arch|upper} +%{if endian} +#define BOTAN_TARGET_CPU_IS_%{endian|upper}_ENDIAN +%{endif} +%{if cpu_family} +#define BOTAN_TARGET_CPU_IS_%{cpu_family|upper}_FAMILY +%{endif} +%{if cpu_is_64bit} +#define BOTAN_TARGET_CPU_HAS_NATIVE_64BIT +%{endif} + %{for cpu_defines} #define BOTAN_%{i} %{endfor} +%{if with_valgrind} +#define BOTAN_HAS_VALGRIND +%{endif} + +%{if with_openmp} +#define BOTAN_TARGET_HAS_OPENMP +%{endif} + /* * Module availability definitions */ -- cgit v1.2.3 From f2a663bbb74b18026aee07fe58e5ae29fc10d97c Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Mon, 11 Dec 2017 19:53:37 -0500 Subject: Rename the SSE4 ISA extensions Simplifies macro generation --- src/build-data/arch/x86_32.txt | 4 ++-- src/build-data/arch/x86_64.txt | 4 ++-- src/build-data/cc/clang.txt | 4 ++-- src/build-data/cc/gcc.txt | 4 ++-- src/build-data/cc/msvc.txt | 4 ++-- src/build-data/cc/sunstudio.txt | 4 ++-- src/lib/hash/sha1/sha1_x86/info.txt | 2 +- src/lib/hash/sha2_32/sha2_32_x86/info.txt | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/build-data/arch/x86_32.txt b/src/build-data/arch/x86_32.txt index 20401e034..b523d9ce4 100644 --- a/src/build-data/arch/x86_32.txt +++ b/src/build-data/arch/x86_32.txt @@ -68,7 +68,7 @@ rdrand rdseed sha sse2 -sse4.1 -sse4.2 +sse4_1 +sse4_2 ssse3 diff --git a/src/build-data/arch/x86_64.txt b/src/build-data/arch/x86_64.txt index 49f8a6a55..9e3e74b9b 100644 --- a/src/build-data/arch/x86_64.txt +++ b/src/build-data/arch/x86_64.txt @@ -47,7 +47,7 @@ rdrand rdseed sha sse2 -sse4.1 -sse4.2 +sse4_1 +sse4_2 ssse3 diff --git a/src/build-data/cc/clang.txt b/src/build-data/cc/clang.txt index 44dd654f3..6fc3db6a1 100644 --- a/src/build-data/cc/clang.txt +++ b/src/build-data/cc/clang.txt @@ -37,8 +37,8 @@ llvm -> "llvm-link" sse2 -> "-msse2" ssse3 -> "-mssse3" -sse4.1 -> "-msse4.1" -sse4.2 -> "-msse4.2" +sse4_1 -> "-msse4.1" +sse4_2 -> "-msse4.2" avx2 -> "-mavx2" bmi2 -> "-mbmi2" aesni -> "-maes -mpclmul -mssse3" diff --git a/src/build-data/cc/gcc.txt b/src/build-data/cc/gcc.txt index 64c52f076..b89432ea5 100644 --- a/src/build-data/cc/gcc.txt +++ b/src/build-data/cc/gcc.txt @@ -47,8 +47,8 @@ default -> "$(LINKER)" sse2 -> "-msse2" ssse3 -> "-mssse3" -sse4.1 -> "-msse4.1" -sse4.2 -> "-msse4.2" +sse4_1 -> "-msse4.1" +sse4_2 -> "-msse4.2" avx2 -> "-mavx2" bmi2 -> "-mbmi2" aesni -> "-maes -mpclmul -mssse3" diff --git a/src/build-data/cc/msvc.txt b/src/build-data/cc/msvc.txt index 6df218a4f..2d6cb1a57 100644 --- a/src/build-data/cc/msvc.txt +++ b/src/build-data/cc/msvc.txt @@ -34,8 +34,8 @@ ar_output_to "/OUT:" sse2 -> "" ssse3 -> "" -sse4.1 -> "" -sse4.2 -> "" +sse4_1 -> "" +sse4_2 -> "" x86_64:avx2 -> "" bmi2 -> "" aesni -> "" diff --git a/src/build-data/cc/sunstudio.txt b/src/build-data/cc/sunstudio.txt index 38f9d828c..4b15a8d63 100644 --- a/src/build-data/cc/sunstudio.txt +++ b/src/build-data/cc/sunstudio.txt @@ -54,8 +54,8 @@ x86_64 -> "-m64" # 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" +sse4_1 -> "-xarch=sse4.1" +sse4_2 -> "-xarch=sse4.2" aesni -> "-xarch=aes" avx -> "-xarch=avx" rdrand -> "-xarch=avx_i" diff --git a/src/lib/hash/sha1/sha1_x86/info.txt b/src/lib/hash/sha1/sha1_x86/info.txt index 9cddd40a2..2f48f7627 100644 --- a/src/lib/hash/sha1/sha1_x86/info.txt +++ b/src/lib/hash/sha1/sha1_x86/info.txt @@ -2,7 +2,7 @@ SHA1_X86_SHA_NI -> 20170518 -need_isa sha,ssse3,sse4.1 +need_isa sha,ssse3,sse4_1 clang:3.9 diff --git a/src/lib/hash/sha2_32/sha2_32_x86/info.txt b/src/lib/hash/sha2_32/sha2_32_x86/info.txt index bf34e73a3..f3964e441 100644 --- a/src/lib/hash/sha2_32/sha2_32_x86/info.txt +++ b/src/lib/hash/sha2_32/sha2_32_x86/info.txt @@ -2,7 +2,7 @@ SHA2_32_X86 -> 20170518 -need_isa sha,sse4.1 +need_isa sha,sse4_1 gcc:5.0 -- cgit v1.2.3 From b6f51a9be08df03d54411c65f9271b9a62ab5554 Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Mon, 11 Dec 2017 20:07:05 -0500 Subject: Finish with the CPU feature macros --- configure.py | 14 ++------------ src/build-data/buildh.in | 4 ++-- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/configure.py b/configure.py index 794eb2ecc..1cde6d267 100755 --- a/configure.py +++ b/configure.py @@ -335,7 +335,7 @@ def process_command_line(args): # pylint: disable=too-many-locals target_group.add_option('--disable-%s' % (isa_extn), help='disable %s intrinsics' % (isa_extn_name), action='append_const', - const=isa_extn.replace('-', ''), + const=isa_extn.replace('-', '').replace('.', '_'), dest='disable_intrinsics') build_group = optparse.OptionGroup(parser, 'Build options') @@ -1005,16 +1005,6 @@ class ArchInfo(InfoObject): return sorted(isas) - def defines(self, cc, options): - """ - Return CPU-specific defines for build.h - """ - - def form_macro(cpu_name): - return cpu_name.upper().replace('.', '').replace('-', '_') - - return ['TARGET_SUPPORTS_' + form_macro(isa) for isa in self.supported_isa_extensions(cc, options)] - MachOptFlags = collections.namedtuple('MachOptFlags', ['flags', 'submodel_prefix']) @@ -1878,7 +1868,7 @@ def create_template_vars(source_paths, build_config, options, modules, cc, arch, 'os_features': osinfo.enabled_features(options), 'os_name': osinfo.basename, 'os_type': osinfo.os_type, - 'cpu_defines': arch.defines(cc, options), + 'cpu_features': arch.supported_isa_extensions(cc, options), 'house_ecc_curve_defines': house_ecc_curve_macros(options.house_curve), 'fuzzer_mode': options.unsafe_fuzzer_mode, diff --git a/src/build-data/buildh.in b/src/build-data/buildh.in index 1e32532db..cacc01ed0 100644 --- a/src/build-data/buildh.in +++ b/src/build-data/buildh.in @@ -66,8 +66,8 @@ #define BOTAN_TARGET_CPU_HAS_NATIVE_64BIT %{endif} -%{for cpu_defines} -#define BOTAN_%{i} +%{for cpu_features} +#define BOTAN_TARGET_SUPPORTS_%{i|upper} %{endfor} %{if with_valgrind} -- cgit v1.2.3 From 8517b97cbeec0ca5ff2aa12ff16d04473679aee2 Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Mon, 11 Dec 2017 20:08:13 -0500 Subject: Remove an unused feature allowing one module to pull in a file from another The last use of this was removed in #549 --- configure.py | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/configure.py b/configure.py index 1cde6d267..0a9596168 100755 --- a/configure.py +++ b/configure.py @@ -793,24 +793,11 @@ class ModuleInfo(InfoObject): self.requires = lex.requires self.warning = ' '.join(lex.warning) if lex.warning else None - def add_dir_name(filename): - if filename.count(':') == 0: - return os.path.join(self.lives_in, filename) - - # TODO is this used anymore??? Probably can be removed. - - # modules can request to add files of the form - # MODULE_NAME:FILE_NAME to add a file from another module - # For these, assume other module is always in a - # neighboring directory; this is true for all current uses - return os.path.join(os.path.split(self.lives_in)[0], - *filename.split(':')) - # Modify members - self.source = [normalize_source_path(add_dir_name(s)) for s in self.source] - self.header_internal = [add_dir_name(s) for s in self.header_internal] - self.header_public = [add_dir_name(s) for s in self.header_public] - self.header_external = [add_dir_name(s) for s in self.header_external] + self.source = [normalize_source_path(os.path.join(self.lives_in, s)) for s in self.source] + self.header_internal = [os.path.join(self.lives_in, s) for s in self.header_internal] + self.header_public = [os.path.join(self.lives_in, s) for s in self.header_public] + self.header_external = [os.path.join(self.lives_in, s) for s in self.header_external] # Filesystem read access check for src in self.source + self.header_internal + self.header_public + self.header_external: -- cgit v1.2.3 From 4cc5e2fe991d4233f053abedf73a5dc22594330b Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Mon, 11 Dec 2017 20:49:45 -0500 Subject: Rename SSE4.x names to avoid underscores This breaks how we determine the ISA flags for amalgamation files. The code for doing that is kind of a hack but I don't want to mess with it right now, easier to just rename the ISA internally. --- configure.py | 7 ++++++- src/build-data/arch/x86_32.txt | 4 ++-- src/build-data/arch/x86_64.txt | 4 ++-- src/build-data/cc/clang.txt | 4 ++-- src/build-data/cc/gcc.txt | 4 ++-- src/build-data/cc/msvc.txt | 4 ++-- src/build-data/cc/sunstudio.txt | 4 ++-- src/lib/hash/sha1/sha1_x86/info.txt | 2 +- src/lib/hash/sha2_32/sha2_32_x86/info.txt | 2 +- 9 files changed, 20 insertions(+), 15 deletions(-) diff --git a/configure.py b/configure.py index 0a9596168..d7b03f8c1 100755 --- a/configure.py +++ b/configure.py @@ -335,7 +335,7 @@ def process_command_line(args): # pylint: disable=too-many-locals target_group.add_option('--disable-%s' % (isa_extn), help='disable %s intrinsics' % (isa_extn_name), action='append_const', - const=isa_extn.replace('-', '').replace('.', '_'), + const=isa_extn.replace('-', '').replace('.', ''), dest='disable_intrinsics') build_group = optparse.OptionGroup(parser, 'Build options') @@ -972,6 +972,11 @@ class ArchInfo(InfoObject): self.submodel_aliases = parse_lex_dict(lex.submodel_aliases) self.wordsize = int(lex.wordsize) + alphanumeric = re.compile('^[a-z0-9]+$') + for isa in self.isa_extensions: + if alphanumeric.match(isa) is None: + logging.error('Invalid name for ISA extension "%s"', isa) + def all_submodels(self): """ Return a list of all submodels for this arch, ordered longest diff --git a/src/build-data/arch/x86_32.txt b/src/build-data/arch/x86_32.txt index b523d9ce4..0aa9b6683 100644 --- a/src/build-data/arch/x86_32.txt +++ b/src/build-data/arch/x86_32.txt @@ -68,7 +68,7 @@ rdrand rdseed sha sse2 -sse4_1 -sse4_2 +sse41 +sse42 ssse3 diff --git a/src/build-data/arch/x86_64.txt b/src/build-data/arch/x86_64.txt index 9e3e74b9b..1757e4f42 100644 --- a/src/build-data/arch/x86_64.txt +++ b/src/build-data/arch/x86_64.txt @@ -47,7 +47,7 @@ rdrand rdseed sha sse2 -sse4_1 -sse4_2 +sse41 +sse42 ssse3 diff --git a/src/build-data/cc/clang.txt b/src/build-data/cc/clang.txt index 6fc3db6a1..aaef4357a 100644 --- a/src/build-data/cc/clang.txt +++ b/src/build-data/cc/clang.txt @@ -37,8 +37,8 @@ llvm -> "llvm-link" sse2 -> "-msse2" ssse3 -> "-mssse3" -sse4_1 -> "-msse4.1" -sse4_2 -> "-msse4.2" +sse41 -> "-msse4.1" +sse42 -> "-msse4.2" avx2 -> "-mavx2" bmi2 -> "-mbmi2" aesni -> "-maes -mpclmul -mssse3" diff --git a/src/build-data/cc/gcc.txt b/src/build-data/cc/gcc.txt index b89432ea5..ce1f47ae0 100644 --- a/src/build-data/cc/gcc.txt +++ b/src/build-data/cc/gcc.txt @@ -47,8 +47,8 @@ default -> "$(LINKER)" sse2 -> "-msse2" ssse3 -> "-mssse3" -sse4_1 -> "-msse4.1" -sse4_2 -> "-msse4.2" +sse41 -> "-msse4.1" +sse42 -> "-msse4.2" avx2 -> "-mavx2" bmi2 -> "-mbmi2" aesni -> "-maes -mpclmul -mssse3" diff --git a/src/build-data/cc/msvc.txt b/src/build-data/cc/msvc.txt index 2d6cb1a57..b816d33f8 100644 --- a/src/build-data/cc/msvc.txt +++ b/src/build-data/cc/msvc.txt @@ -34,8 +34,8 @@ ar_output_to "/OUT:" sse2 -> "" ssse3 -> "" -sse4_1 -> "" -sse4_2 -> "" +sse41 -> "" +sse42 -> "" x86_64:avx2 -> "" bmi2 -> "" aesni -> "" diff --git a/src/build-data/cc/sunstudio.txt b/src/build-data/cc/sunstudio.txt index 4b15a8d63..e983bf701 100644 --- a/src/build-data/cc/sunstudio.txt +++ b/src/build-data/cc/sunstudio.txt @@ -54,8 +54,8 @@ x86_64 -> "-m64" # 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" +sse41 -> "-xarch=sse4.1" +sse42 -> "-xarch=sse4.2" aesni -> "-xarch=aes" avx -> "-xarch=avx" rdrand -> "-xarch=avx_i" diff --git a/src/lib/hash/sha1/sha1_x86/info.txt b/src/lib/hash/sha1/sha1_x86/info.txt index 2f48f7627..cfa1750c2 100644 --- a/src/lib/hash/sha1/sha1_x86/info.txt +++ b/src/lib/hash/sha1/sha1_x86/info.txt @@ -2,7 +2,7 @@ SHA1_X86_SHA_NI -> 20170518 -need_isa sha,ssse3,sse4_1 +need_isa sha,ssse3,sse41 clang:3.9 diff --git a/src/lib/hash/sha2_32/sha2_32_x86/info.txt b/src/lib/hash/sha2_32/sha2_32_x86/info.txt index f3964e441..838d2a4a8 100644 --- a/src/lib/hash/sha2_32/sha2_32_x86/info.txt +++ b/src/lib/hash/sha2_32/sha2_32_x86/info.txt @@ -2,7 +2,7 @@ SHA2_32_X86 -> 20170518 -need_isa sha,sse4_1 +need_isa sha,sse41 gcc:5.0 -- cgit v1.2.3