From a9e4eede3942748234d705cc616ecc106e3767a6 Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Wed, 29 Nov 2017 11:52:53 -0500 Subject: [PATCH] Allow overriding ar command Splits up the ar command and ar options to make this possible. Removes support for calling `ranlib` after `ar`: testing in #1317 confirms that all platforms we support no longer need it. See #1237. Also fixes #455 --- configure.py | 32 ++++++++++++++++------- src/build-data/cc/clang.txt | 8 ------ src/build-data/cc/ekopath.txt | 10 ++----- src/build-data/cc/gcc.txt | 7 ----- src/build-data/cc/hpcc.txt | 8 ------ src/build-data/cc/icc.txt | 7 ----- src/build-data/cc/pgi.txt | 7 ----- src/build-data/cc/sunstudio.txt | 10 ++----- src/build-data/cc/xlc.txt | 7 ----- src/build-data/makefile/gmake.in | 3 +-- src/build-data/makefile/gmake_commands.in | 1 - src/build-data/makefile/nmake.in | 2 +- src/build-data/os/darwin.txt | 4 --- src/build-data/os/ios.txt | 4 --- src/build-data/os/llvm.txt | 3 ++- src/build-data/os/mingw.txt | 3 --- src/scripts/ci_build.py | 2 +- 17 files changed, 31 insertions(+), 87 deletions(-) diff --git a/configure.py b/configure.py index 2d831b44784..23cc1f14b68 100755 --- a/configure.py +++ b/configure.py @@ -331,6 +331,9 @@ def process_command_line(args): # pylint: disable=too-many-locals help='set compiler ABI flags', default='') + target_group.add_option('--ar-command', dest='ar_command', metavar='AR', default=None, + help='set path to static archive creator') + target_group.add_option('--with-endian', metavar='ORDER', default=None, help='override byte order guess') @@ -615,6 +618,13 @@ def parse_multiple_enable(modules): options.disable_intrinsics = parse_multiple_enable(options.disable_intrinsics) + # Take some values from environment, if not set on command line + + if options.ar_command is None: + options.ar_command = os.getenv('AR') + if options.compiler_binary is None: + options.compiler_binary = os.getenv('CXX') + return options @@ -1088,8 +1098,8 @@ def __init__(self, infofile): 'add_lib_dir_option': '-L', 'add_lib_option': '-l', 'add_framework_option': '-framework ', - 'compile_flags': '', - 'debug_info_flags': '', + 'compile_flags': '-c', + 'debug_info_flags': '-g', 'optimization_flags': '', 'size_optimization_flags': '', 'coverage_flags': '', @@ -1102,6 +1112,7 @@ def __init__(self, infofile): 'visibility_build_flags': '', 'visibility_attribute': '', 'ar_command': None, + 'ar_options': None, 'makefile_style': '' }) @@ -1110,6 +1121,7 @@ def __init__(self, infofile): self.add_lib_option = lex.add_lib_option self.add_lib_dir_option = lex.add_lib_dir_option self.ar_command = lex.ar_command + self.ar_options = lex.ar_options self.binary_link_commands = force_to_dict(lex.binary_link_commands) self.binary_name = lex.binary_name self.compile_flags = lex.compile_flags @@ -1306,8 +1318,8 @@ def __init__(self, infofile): 'soname_pattern_abi': '', 'soname_pattern_base': '', 'static_suffix': 'a', - 'ar_command': 'ar crs', - 'ar_needs_ranlib': False, + 'ar_command': 'ar', + 'ar_options': '', 'install_root': '/usr/local', 'header_dir': 'include', 'bin_dir': 'bin', @@ -1318,6 +1330,9 @@ def __init__(self, infofile): 'install_cmd_exec': 'install -m 755' }) + if lex.ar_command == 'ar' and lex.ar_options == '': + lex.ar_options = 'crs' + if lex.soname_pattern_base: self.soname_pattern_base = lex.soname_pattern_base if lex.soname_pattern_patch == '' and lex.soname_pattern_abi == '': @@ -1343,7 +1358,7 @@ def __init__(self, infofile): self.aliases = lex.aliases self.ar_command = lex.ar_command - self.ar_needs_ranlib = bool(lex.ar_needs_ranlib) + self.ar_options = lex.ar_options self.bin_dir = lex.bin_dir self.building_shared_supported = (True if lex.building_shared_supported == 'yes' else False) self.doc_dir = lex.doc_dir @@ -1358,9 +1373,6 @@ def __init__(self, infofile): self.static_suffix = lex.static_suffix self.target_features = lex.target_features - def ranlib_command(self): - return 'ranlib' if self.ar_needs_ranlib else 'true' - def defines(self, options): r = [] r += ['TARGET_OS_IS_%s' % (self.basename.upper())] @@ -2067,8 +2079,8 @@ def configure_command_line(): 'fuzzer_libs': '' if options.fuzzer_lib is None else '%s%s' % (cc.add_lib_option, options.fuzzer_lib), 'python_exe': sys.executable, - 'ar_command': cc.ar_command or osinfo.ar_command, - 'ranlib_command': osinfo.ranlib_command(), + 'ar_command': options.ar_command or cc.ar_command or osinfo.ar_command, + 'ar_options': cc.ar_options or osinfo.ar_options, 'install_cmd_exec': osinfo.install_cmd_exec, 'install_cmd_data': osinfo.install_cmd_data, diff --git a/src/build-data/cc/clang.txt b/src/build-data/cc/clang.txt index 992748de741..cfff2e2eb33 100644 --- a/src/build-data/cc/clang.txt +++ b/src/build-data/cc/clang.txt @@ -2,19 +2,11 @@ macro_name CLANG binary_name clang++ -output_to_option "-o " -add_include_dir_option -I -add_lib_dir_option -L -add_lib_option -l -add_framework_option "-framework " - lang_flags "-std=c++11 -D_REENTRANT" warning_flags "-Wall -Wextra -Wpedantic -Wshadow -Wstrict-aliasing -Wstrict-overflow=5 -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual" maintainer_warning_flags "-Wunreachable-code -Wdocumentation -Qunused-arguments -Werror -Wno-error=unused-parameter -Wno-error=unreachable-code -Wno-error=deprecated-declarations" -compile_flags "-c" -debug_info_flags "-g" optimization_flags "-O3" size_optimization_flags "-Os" #sanitizer_flags "-fsanitize=address,undefined -fsanitize-coverage=edge,indirect-calls,8bit-counters -fno-sanitize-recover=undefined" diff --git a/src/build-data/cc/ekopath.txt b/src/build-data/cc/ekopath.txt index 549c21a23d9..c127b78f814 100644 --- a/src/build-data/cc/ekopath.txt +++ b/src/build-data/cc/ekopath.txt @@ -2,19 +2,13 @@ macro_name PATHSCALE binary_name pathCC -output_to_option "-o " -add_include_dir_option -I -add_lib_dir_option -L -add_lib_option -l - -compile_flags "-c" -debug_info_flags "-g" optimization_flags "-O3" lang_flags "-D_REENTRANT -ansi -Wno-long-long" warning_flags "-W -Wall" -ar_command "pathCC -ar -o" +ar_command pathCC +ar_options "-ar -o" shared_flags "-fPIC" diff --git a/src/build-data/cc/gcc.txt b/src/build-data/cc/gcc.txt index 7249fae8e59..88e7089ce33 100644 --- a/src/build-data/cc/gcc.txt +++ b/src/build-data/cc/gcc.txt @@ -2,11 +2,6 @@ macro_name GCC binary_name g++ -output_to_option "-o " -add_include_dir_option -I -add_lib_dir_option -L -add_lib_option -l - lang_flags "-std=c++11 -D_REENTRANT" # This should only contain flags which are included in GCC 4.8 @@ -14,8 +9,6 @@ warning_flags "-Wall -Wextra -Wpedantic -Wstrict-aliasing -Wstrict-overflow=5 -W maintainer_warning_flags "-Wold-style-cast -Wsuggest-override -Wshadow -Werror -Wno-error=strict-overflow -Wno-error=deprecated-declarations" -compile_flags "-c" -debug_info_flags "-g" optimization_flags "-O3" size_optimization_flags "-Os" diff --git a/src/build-data/cc/hpcc.txt b/src/build-data/cc/hpcc.txt index 2f2686d101c..aa305bf82a5 100644 --- a/src/build-data/cc/hpcc.txt +++ b/src/build-data/cc/hpcc.txt @@ -2,15 +2,7 @@ macro_name HP_ACC binary_name aCC -output_to_option "-o " -add_include_dir_option -I -add_lib_dir_option -L -add_lib_option -l - lang_flags "-AA -ext +eh -z" - -compile_flags "-c" -debug_info_flags "-g" optimization_flags "+O2" warning_flags "+w" shared_flags "+Z" diff --git a/src/build-data/cc/icc.txt b/src/build-data/cc/icc.txt index f1b7e5a1590..cdc250187c8 100644 --- a/src/build-data/cc/icc.txt +++ b/src/build-data/cc/icc.txt @@ -2,13 +2,6 @@ macro_name INTEL binary_name icpc -output_to_option "-o " -add_include_dir_option -I -add_lib_dir_option -L -add_lib_option -l - -compile_flags "-c" -debug_info_flags "-g" optimization_flags "-O2" size_optimization_flags "-Os" diff --git a/src/build-data/cc/pgi.txt b/src/build-data/cc/pgi.txt index 06b2f84005a..e8c65ea3a89 100644 --- a/src/build-data/cc/pgi.txt +++ b/src/build-data/cc/pgi.txt @@ -2,13 +2,6 @@ macro_name PORTLAND_GROUP binary_name pgCC -output_to_option "-o " -add_include_dir_option -I -add_lib_dir_option -L -add_lib_option -l - -compile_flags "-c" -debug_info_flags "-g" optimization_flags "-fast -Minline" shared_flags "-fPIC" diff --git a/src/build-data/cc/sunstudio.txt b/src/build-data/cc/sunstudio.txt index c2fc97a01b6..fd87533a5d7 100644 --- a/src/build-data/cc/sunstudio.txt +++ b/src/build-data/cc/sunstudio.txt @@ -2,20 +2,14 @@ macro_name SUN_STUDIO binary_name CC -output_to_option "-o " -add_include_dir_option -I -add_lib_dir_option -L -add_lib_option -l - -compile_flags "-c" -debug_info_flags "-g" optimization_flags "-xO2" shared_flags "-KPIC" warning_flags "+w -erroff=truncwarn,wnoretvalue" lang_flags "-std=c++11 +p -features=extensions -D__FUNCTION__=__func__" -ar_command "CC -xar -o" +ar_command CC +ar_options "-xar -o" makefile_style gmake diff --git a/src/build-data/cc/xlc.txt b/src/build-data/cc/xlc.txt index 36eaf29d22e..28620b7e149 100644 --- a/src/build-data/cc/xlc.txt +++ b/src/build-data/cc/xlc.txt @@ -2,13 +2,6 @@ macro_name XLC binary_name xlC -output_to_option "-o " -add_include_dir_option -I -add_lib_dir_option -L -add_lib_option -l - -compile_flags "-c" -debug_info_flags "-g" optimization_flags "-O2" lang_flags "-std=c++11" diff --git a/src/build-data/makefile/gmake.in b/src/build-data/makefile/gmake.in index a943392ba6b..c8e7017e5d6 100644 --- a/src/build-data/makefile/gmake.in +++ b/src/build-data/makefile/gmake.in @@ -47,8 +47,7 @@ $(TEST): $(LIBRARIES) $(TESTOBJS) $(STATIC_LIB): $(LIBOBJS) $(RM) $(STATIC_LIB) - $(AR) $(STATIC_LIB) $(LIBOBJS) - $(RANLIB) $(STATIC_LIB) + $(AR) %{ar_options} $(STATIC_LIB) $(LIBOBJS) # Fake targets .PHONY: clean distclean docs install valgrind lcov diff --git a/src/build-data/makefile/gmake_commands.in b/src/build-data/makefile/gmake_commands.in index 33c6634c32e..ae058644366 100644 --- a/src/build-data/makefile/gmake_commands.in +++ b/src/build-data/makefile/gmake_commands.in @@ -9,6 +9,5 @@ INSTALL_CMD_DATA = %{install_cmd_data} LN = ln -fs MKDIR = @mkdir MKDIR_INSTALL = @umask 022; mkdir -p -m 755 -RANLIB = %{ranlib_command} RM = @rm -f RM_R = @rm -rf diff --git a/src/build-data/makefile/nmake.in b/src/build-data/makefile/nmake.in index b721ffd6779..8ed1625f528 100644 --- a/src/build-data/makefile/nmake.in +++ b/src/build-data/makefile/nmake.in @@ -67,7 +67,7 @@ tests: $(TEST) !If "$(SO_OBJ_FLAGS)" == "" # static lib $(LIB_FILENAME): $(LIBOBJS) - $(AR) /OUT:$@ $(LIBOBJS) + $(AR) %{ar_options} /OUT:$@ $(LIBOBJS) !Else # shared lib # Creates the DLL $(SO_FILENAME) and the .lib $(LIB_FILENAME) diff --git a/src/build-data/os/darwin.txt b/src/build-data/os/darwin.txt index 6b02bd8dda6..78ad4a948c3 100644 --- a/src/build-data/os/darwin.txt +++ b/src/build-data/os/darwin.txt @@ -4,10 +4,6 @@ soname_pattern_base "libbotan-{version_major}.dylib" soname_pattern_abi "libbotan-{version_major}.{abi_rev}.dylib" soname_pattern_patch "libbotan-{version_major}.{abi_rev}.{version_minor}.{version_patch}.dylib" -# It doesn't have the 's' option; you need to use needs ranlib -ar_command "ar cr" -ar_needs_ranlib yes - doc_dir doc diff --git a/src/build-data/os/ios.txt b/src/build-data/os/ios.txt index 5ac6824a490..ddd283cd93f 100644 --- a/src/build-data/os/ios.txt +++ b/src/build-data/os/ios.txt @@ -4,10 +4,6 @@ soname_pattern_base "libbotan-{version_major}.{version_minor}.dylib" soname_pattern_abi "libbotan-{version_major}.{version_minor}.{abi_rev}.dylib" soname_pattern_patch "libbotan-{version_major}.{version_minor}.{abi_rev}.{version_patch}.dylib" -# It doesn't have the 's' option; you need to use needs ranlib -ar_command "ar cr" -ar_needs_ranlib yes - doc_dir doc diff --git a/src/build-data/os/llvm.txt b/src/build-data/os/llvm.txt index 119d641e4bf..9eeff5cbaf5 100644 --- a/src/build-data/os/llvm.txt +++ b/src/build-data/os/llvm.txt @@ -2,7 +2,8 @@ obj_suffix bc building_shared_supported no -ar_command "llvm-link -o" +ar_command llvm-link +ar_options -o filesystem diff --git a/src/build-data/os/mingw.txt b/src/build-data/os/mingw.txt index 45fad382d2a..bf4333ec001 100644 --- a/src/build-data/os/mingw.txt +++ b/src/build-data/os/mingw.txt @@ -6,9 +6,6 @@ static_suffix a building_shared_supported no -ar_command "ar crs" -ar_needs_ranlib yes - install_root /mingw header_dir include lib_dir lib diff --git a/src/scripts/ci_build.py b/src/scripts/ci_build.py index 1294921db71..e7fd1e80c8e 100755 --- a/src/scripts/ci_build.py +++ b/src/scripts/ci_build.py @@ -129,8 +129,8 @@ def determine_flags(target, target_os, target_cpu, target_cc, cc_bin, ccache, ro else: raise Exception("Unknown cross target '%s' for iOS" % (target)) elif target == 'cross-win32': - flags += ['--cpu=x86_32', '--cc-abi-flags=-static'] cc_bin = 'i686-w64-mingw32-g++' + flags += ['--cpu=x86_32', '--cc-abi-flags=-static', '--ar-command=i686-w64-mingw32-ar'] test_cmd = [os.path.join(root_dir, 'botan-test.exe')] # No runtime prefix required for Wine else: