提交 c416c5eb authored 作者: Frédéric Bastien's avatar Frédéric Bastien

Merge pull request #2242 from cocu/allow_cxx_flag_full_path

allow cxx flag to be full path to compiler
......@@ -131,22 +131,22 @@ AddConfigVar('mode',
'FAST_COMPILE', 'PROFILE_MODE', 'DEBUG_MODE'),
in_c_key=False)
enum = EnumStr("g++", "")
param = StrParam("g++")
# Test whether or not g++ is present: disable C code if it is not.
try:
rc = call_subprocess_Popen(['g++', '-v'])
except OSError:
enum = EnumStr("")
param = StrParam("")
rc = 1
AddConfigVar('cxx',
"The C++ compiler to use. Currently only g++ is"
" supported, but supporting additional compilers should not be "
"too difficult. "
"If it is empty, no C++ code is compiled.",
enum,
param,
in_c_key=False)
del enum
del param
if rc == 0 and config.cxx != "":
# Keep the default linker the same as the one for the mode FAST_RUN
......
......@@ -1522,7 +1522,7 @@ def gcc_llvm():
"""
if gcc_llvm.is_llvm is None:
try:
p_out = output_subprocess_Popen(['g++', '--version'])
p_out = output_subprocess_Popen([theano.config.cxx, '--version'])
output = p_out[0] + p_out[1]
except OSError:
# Typically means g++ cannot be found.
......@@ -1544,7 +1544,7 @@ class GCC_compiler(object):
@staticmethod
def version_str():
return "g++ " + gcc_version_str
return theano.config.cxx + " " + gcc_version_str
@staticmethod
def compile_args():
......@@ -1572,6 +1572,17 @@ class GCC_compiler(object):
GCC_compiler.march_flags = []
break
if not "g++" in theano.config.cxx:
_logger.warn(
"OPTIMIZATION WARNING: your Theano flag `cxx` seems not to be"
" the g++ compiler. So we disable the compiler optimization"
" specific to g++ that tell to compile for a specific CPU."
" At worst, this could cause slow down.\n"
" You can add yourself those parameters to the compiler"
" via the Theano flag `gcc.cxxflags`."
)
detect_march = False
if detect_march:
GCC_compiler.march_flags = []
......@@ -1611,7 +1622,7 @@ class GCC_compiler(object):
# The '-' at the end is needed. Otherwise, g++ do not output
# enough information.
native_lines = get_lines("g++ -march=native -E -v -")
native_lines = get_lines("%s -march=native -E -v -" % theano.config.cxx)
if native_lines is None:
_logger.info("Call to 'g++ -march=native' failed,"
"not setting -march flag")
......@@ -1625,7 +1636,7 @@ class GCC_compiler(object):
if len(native_lines) == 0:
# That means we did not select the right lines, so
# we have to report all the lines instead
reported_lines = get_lines("g++ -march=native -E -v -",
reported_lines = get_lines("%s -march=native -E -v -" % theano.config.cxx,
parse=False)
else:
reported_lines = native_lines
......@@ -1638,7 +1649,7 @@ class GCC_compiler(object):
" problem:\n %s",
reported_lines)
else:
default_lines = get_lines("g++ -E -v -")
default_lines = get_lines("%s -E -v -" % theano.config.cxx)
_logger.info("g++ default lines: %s", default_lines)
if len(default_lines) < 1:
_logger.warn(
......@@ -1649,7 +1660,7 @@ class GCC_compiler(object):
" functions. Please submit the following lines to"
" Theano's mailing list so that we can fix this"
" problem:\n %s",
get_lines("g++ -E -v -", parse=False))
get_lines("%s -E -v -" % theano.config.cxx, parse=False))
else:
# Some options are actually given as "-option value",
# we want to treat them as only one token when comparing
......@@ -1821,7 +1832,7 @@ class GCC_compiler(object):
os.close(fd)
fd = None
out, err, p_ret = output_subprocess_Popen(
['g++', path, '-o', exe_path] + flags)
[theano.config.cxx, path, '-o', exe_path] + flags)
if p_ret != 0:
compilation_ok = False
elif try_run:
......@@ -1947,7 +1958,7 @@ class GCC_compiler(object):
(module_name, get_lib_extension()))
_logger.debug('Generating shared lib %s', lib_filename)
cmd = ['g++', get_gcc_shared_library_arg(), '-g']
cmd = [theano.config.cxx, get_gcc_shared_library_arg(), '-g']
if config.cmodule.remove_gxx_opt:
cmd.extend(p for p in preargs if not p.startswith('-O'))
......
......@@ -22,7 +22,7 @@ from theano.misc.windows import output_subprocess_Popen
_logger = logging.getLogger("theano.gof.compiledir")
try:
p_out = output_subprocess_Popen(['g++', '-dumpversion'])
p_out = output_subprocess_Popen([theano.config.cxx, '-dumpversion'])
gcc_version_str = p_out[0].strip().decode()
except OSError:
# Typically means gcc cannot be found.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论