add an alloy.py option to build ispc binary with g++

This commit is contained in:
Anton Mitrokhin
2014-07-14 16:18:07 +04:00
parent 6da9d43f69
commit ff2f3c896f

View File

@@ -239,7 +239,7 @@ def check_targets():
answer_sde = [] answer_sde = []
# check what native targets do we have # check what native targets do we have
if current_OS != "Windows": if current_OS != "Windows":
try_do_LLVM("build check_ISA", "clang check_isa.cpp -o check_isa.exe", True) try_do_LLVM("build check_ISA", "g++ check_isa.cpp -o check_isa.exe", True)
else: else:
try_do_LLVM("build check_ISA", "cl check_isa.cpp", True) try_do_LLVM("build check_ISA", "cl check_isa.cpp", True)
SSE2 = ["sse2-i32x4", "sse2-i32x8"] SSE2 = ["sse2-i32x4", "sse2-i32x8"]
@@ -296,6 +296,18 @@ def check_targets():
def build_ispc(version_LLVM, make): def build_ispc(version_LLVM, make):
current_path = os.getcwd() current_path = os.getcwd()
os.chdir(os.environ["ISPC_HOME"]) os.chdir(os.environ["ISPC_HOME"])
# the default 'make' variable for ISPC and LLVM may be actually different,
# so we have to manually set a new make command here (make targets are already verified in Main() )
if (options.ispc_compiler == "clang"):
make_target = "clang"
elif (options.ispc_compiler == "gcc"):
make_target = "gcc"
elif (options.ispc_compiler == "g++"):
make_target = "gcc"
make_ispc = "make " + make_target + " -j" + options.speed
if current_OS != "Windows": if current_OS != "Windows":
p_temp = os.getenv("PATH") p_temp = os.getenv("PATH")
os.environ["PATH"] = os.environ["LLVM_HOME"] + "/bin-" + version_LLVM + "/bin:" + os.environ["PATH"] os.environ["PATH"] = os.environ["LLVM_HOME"] + "/bin-" + version_LLVM + "/bin:" + os.environ["PATH"]
@@ -312,7 +324,7 @@ def build_ispc(version_LLVM, make):
(revision_llvm, err) = p.communicate() (revision_llvm, err) = p.communicate()
try_do_LLVM("recognize LLVM revision", "svn info " + folder, True) try_do_LLVM("recognize LLVM revision", "svn info " + folder, True)
try_do_LLVM("build ISPC with LLVM version " + version_LLVM + " ", make, True) try_do_LLVM("build ISPC with LLVM version " + version_LLVM + " ", make_ispc, True)
os.environ["PATH"] = p_temp os.environ["PATH"] = p_temp
else: else:
p_temp = os.getenv("LLVM_INSTALL_DIR") p_temp = os.getenv("LLVM_INSTALL_DIR")
@@ -650,6 +662,19 @@ def Main():
parser.print_help() parser.print_help()
exit(0) exit(0)
# set appropriate makefile target
# gcc and g++ options are equal and added for ease of use
if (options.ispc_compiler == "clang"):
make_target = "clang"
elif (options.ispc_compiler == "gcc"):
make_target = "gcc"
elif (options.ispc_compiler == "g++"):
make_target = "gcc"
else:
error("unknow option for --ispc-compiler: " + options.ispc_compiler, 1)
parser.print_help()
exit(0)
setting_paths(options.llvm_home, options.ispc_home, options.sde_home) setting_paths(options.llvm_home, options.ispc_home, options.sde_home)
if os.environ.get("LLVM_HOME") == None: if os.environ.get("LLVM_HOME") == None:
error("you have no LLVM_HOME", 1) error("you have no LLVM_HOME", 1)
@@ -759,6 +784,8 @@ if __name__ == '__main__':
help='ask for validation run', default=False, action="store_true") help='ask for validation run', default=False, action="store_true")
parser.add_option('-j', dest='speed', parser.add_option('-j', dest='speed',
help='set -j for make', default=num_threads) help='set -j for make', default=num_threads)
parser.add_option('--ispc-compiler', dest='ispc_compiler',
help='set compiler to build ispc binary (clang or g++)', default="clang")
# options for activity "build LLVM" # options for activity "build LLVM"
llvm_group = OptionGroup(parser, "Options for building LLVM", llvm_group = OptionGroup(parser, "Options for building LLVM",
"These options must be used with -b option.") "These options must be used with -b option.")