Skip to content

Commit

Permalink
Allow overriding ar command
Browse files Browse the repository at this point in the history
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
  • Loading branch information
randombit committed Nov 29, 2017
1 parent 93466a5 commit a9e4eed
Show file tree
Hide file tree
Showing 17 changed files with 31 additions and 87 deletions.
32 changes: 22 additions & 10 deletions configure.py
Expand Up @@ -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')

Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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': '',
Expand All @@ -1102,6 +1112,7 @@ def __init__(self, infofile):
'visibility_build_flags': '',
'visibility_attribute': '',
'ar_command': None,
'ar_options': None,
'makefile_style': ''
})

Expand All @@ -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
Expand Down Expand Up @@ -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',
Expand All @@ -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 == '':
Expand All @@ -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
Expand All @@ -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())]
Expand Down Expand Up @@ -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,

Expand Down
8 changes: 0 additions & 8 deletions src/build-data/cc/clang.txt
Expand Up @@ -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"
Expand Down
10 changes: 2 additions & 8 deletions src/build-data/cc/ekopath.txt
Expand Up @@ -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"

Expand Down
7 changes: 0 additions & 7 deletions src/build-data/cc/gcc.txt
Expand Up @@ -2,20 +2,13 @@ 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
warning_flags "-Wall -Wextra -Wpedantic -Wstrict-aliasing -Wstrict-overflow=5 -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor"

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"

Expand Down
8 changes: 0 additions & 8 deletions src/build-data/cc/hpcc.txt
Expand Up @@ -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"
Expand Down
7 changes: 0 additions & 7 deletions src/build-data/cc/icc.txt
Expand Up @@ -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"

Expand Down
7 changes: 0 additions & 7 deletions src/build-data/cc/pgi.txt
Expand Up @@ -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"

Expand Down
10 changes: 2 additions & 8 deletions src/build-data/cc/sunstudio.txt
Expand Up @@ -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

Expand Down
7 changes: 0 additions & 7 deletions src/build-data/cc/xlc.txt
Expand Up @@ -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"
Expand Down
3 changes: 1 addition & 2 deletions src/build-data/makefile/gmake.in
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/build-data/makefile/gmake_commands.in
Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/build-data/makefile/nmake.in
Expand Up @@ -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)
Expand Down
4 changes: 0 additions & 4 deletions src/build-data/os/darwin.txt
Expand Up @@ -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

<target_features>
Expand Down
4 changes: 0 additions & 4 deletions src/build-data/os/ios.txt
Expand Up @@ -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

<target_features>
Expand Down
3 changes: 2 additions & 1 deletion src/build-data/os/llvm.txt
Expand Up @@ -2,7 +2,8 @@
obj_suffix bc
building_shared_supported no

ar_command "llvm-link -o"
ar_command llvm-link
ar_options -o

<target_features>
filesystem
Expand Down
3 changes: 0 additions & 3 deletions src/build-data/os/mingw.txt
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/ci_build.py
Expand Up @@ -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:
Expand Down

0 comments on commit a9e4eed

Please sign in to comment.