aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-10-18 12:14:15 -0400
committerJack Lloyd <[email protected]>2018-10-18 12:16:12 -0400
commitbb6e40f16fabada3e7db64d52544974aa3599d16 (patch)
tree005f3d54b9d9de4b35ec7fa69fe696763f20a110
parentd99b58135277af3b8c028314bef9156f1a41b576 (diff)
Set default compiler in the info files instead of in configure source
-rwxr-xr-xconfigure.py41
-rw-r--r--src/build-data/os/darwin.txt2
-rw-r--r--src/build-data/os/freebsd.txt2
-rw-r--r--src/build-data/os/ios.txt2
-rw-r--r--src/build-data/os/openbsd.txt2
-rw-r--r--src/build-data/os/windows.txt2
6 files changed, 29 insertions, 22 deletions
diff --git a/configure.py b/configure.py
index 554195d41..3e6bcb42a 100755
--- a/configure.py
+++ b/configure.py
@@ -1369,6 +1369,7 @@ class OsInfo(InfoObject): # pylint: disable=too-many-instance-attributes
'lib_prefix': 'lib',
'library_name': 'botan{suffix}-{major}',
'shared_lib_symlinks': 'yes',
+ 'default_compiler': 'gcc',
})
if lex.ar_command == 'ar' and lex.ar_options == '':
@@ -1416,6 +1417,7 @@ class OsInfo(InfoObject): # pylint: disable=too-many-instance-attributes
self.target_features = lex.target_features
self.use_stack_protector = (lex.use_stack_protector == "true")
self.shared_lib_uses_symlinks = (lex.shared_lib_symlinks == 'yes')
+ self.default_compiler = lex.default_compiler
def matches_name(self, nm):
if nm in self._aliases:
@@ -2731,7 +2733,7 @@ def robust_makedirs(directory, max_retries=5):
# This is for otions that have --with-XYZ and --without-XYZ. If user does not
# set any of those, we choose a default here.
# Mutates `options`
-def set_defaults_for_unset_options(options, info_arch, info_cc): # pylint: disable=too-many-branches
+def set_defaults_for_unset_options(options, info_arch, info_cc, info_os): # pylint: disable=too-many-branches
if options.os is None:
system_from_python = platform.system().lower()
if re.match('^cygwin_.*', system_from_python):
@@ -2751,28 +2753,19 @@ def set_defaults_for_unset_options(options, info_arch, info_cc): # pylint: disab
if options.compiler is None and options.compiler_binary is not None:
options.compiler = deduce_compiler_type_from_cc_bin(options.compiler_binary)
+ if options.compiler is None:
+ logging.error("Could not figure out what compiler type '%s' is, use --cc to set" % (
+ options.compiler_binary))
+
if options.compiler is None:
- if options.os == 'windows':
- if have_program('g++') and not have_program('cl'):
- options.compiler = 'gcc'
- else:
- options.compiler = 'msvc'
- elif options.os in ['darwin', 'freebsd', 'openbsd', 'ios']:
- # Prefer Clang on these systems
- if have_program('clang++'):
- options.compiler = 'clang'
- else:
- options.compiler = 'gcc'
- if options.os == 'openbsd':
- # The assembler shipping with OpenBSD 5.9 does not support avx2
- del info_cc['gcc'].isa_flags['avx2']
- else:
- options.compiler = 'gcc'
- if options.compiler is None:
- logging.error('Could not guess which compiler to use, use --cc or CXX to set')
- else:
- logging.info('Guessing to use compiler %s (use --cc or CXX to set)' % (options.compiler))
+ options.compiler = info_os[options.os].default_compiler
+
+ if not have_program(info_cc[options.compiler].binary_name):
+ logging.error("Default compiler for system is %s but could not find binary '%s'; use --cc to set" % (
+ options.compiler, info_cc[options.compiler].binary_name))
+
+ logging.info('Guessing to use compiler %s (use --cc or CXX to set)' % (options.compiler))
if options.cpu is None:
(arch, cpu) = guess_processor(info_arch)
@@ -2780,6 +2773,10 @@ def set_defaults_for_unset_options(options, info_arch, info_cc): # pylint: disab
options.cpu = cpu
logging.info('Guessing target processor is a %s (use --cpu to set)' % (options.arch))
+ # OpenBSD uses an old binutils that does not support AVX2
+ if options.os == 'openbsd':
+ del info_cc['gcc'].isa_flags['avx2']
+
if options.with_documentation is True:
if options.with_sphinx is None and have_program('sphinx-build'):
logging.info('Found sphinx-build (use --without-sphinx to disable)')
@@ -3159,7 +3156,7 @@ def main(argv):
logging.debug('Known CPU names: ' + ' '.join(
sorted(flatten([[ainfo.basename] + ainfo.aliases for ainfo in info_arch.values()]))))
- set_defaults_for_unset_options(options, info_arch, info_cc)
+ set_defaults_for_unset_options(options, info_arch, info_cc, info_os)
canonicalize_options(options, info_os, info_arch)
validate_options(options, info_os, info_cc, info_module_policies)
diff --git a/src/build-data/os/darwin.txt b/src/build-data/os/darwin.txt
index 1a2f80690..3b0147c22 100644
--- a/src/build-data/os/darwin.txt
+++ b/src/build-data/os/darwin.txt
@@ -1,4 +1,6 @@
+default_compiler clang
+
soname_pattern_base "lib{libname}.dylib"
soname_pattern_abi "lib{libname}.{abi_rev}.dylib"
soname_pattern_patch "lib{libname}.{abi_rev}.{version_minor}.{version_patch}.dylib"
diff --git a/src/build-data/os/freebsd.txt b/src/build-data/os/freebsd.txt
index 2ff60844a..57a3b7546 100644
--- a/src/build-data/os/freebsd.txt
+++ b/src/build-data/os/freebsd.txt
@@ -1,6 +1,8 @@
soname_suffix "so"
+default_compiler clang
+
<target_features>
posix1
posix_mlock
diff --git a/src/build-data/os/ios.txt b/src/build-data/os/ios.txt
index 286e10fd1..34f019fd4 100644
--- a/src/build-data/os/ios.txt
+++ b/src/build-data/os/ios.txt
@@ -3,6 +3,8 @@ soname_pattern_base "lib{libname}.{version_minor}.dylib"
soname_pattern_abi "lib{libname}.{version_minor}.{abi_rev}.dylib"
soname_pattern_patch "lib{libname}.{version_minor}.{abi_rev}.{version_patch}.dylib"
+default_compiler clang
+
doc_dir doc
<target_features>
diff --git a/src/build-data/os/openbsd.txt b/src/build-data/os/openbsd.txt
index a0458988e..5ee81206e 100644
--- a/src/build-data/os/openbsd.txt
+++ b/src/build-data/os/openbsd.txt
@@ -5,6 +5,8 @@ soname_pattern_patch "lib{libname}.so.{abi_rev}.{version_minor}"
shared_lib_symlinks no
+default_compiler clang
+
<target_features>
posix1
posix_mlock
diff --git a/src/build-data/os/windows.txt b/src/build-data/os/windows.txt
index 57781d7c8..5ebbcb2d1 100644
--- a/src/build-data/os/windows.txt
+++ b/src/build-data/os/windows.txt
@@ -8,6 +8,8 @@ lib_prefix ''
shared_lib_symlinks no
+default_compiler msvc
+
# For historical reasons? the library does not have the major number on Windows
# This should probably be fixed in a future major release.
library_name 'botan{suffix}'