From ff2f3c896f4b91761d58a1b686d6c3815aa06153 Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Mon, 14 Jul 2014 16:18:07 +0400 Subject: [PATCH 1/3] add an alloy.py option to build ispc binary with g++ --- alloy.py | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/alloy.py b/alloy.py index 8bed9381..3809ec58 100755 --- a/alloy.py +++ b/alloy.py @@ -239,7 +239,7 @@ def check_targets(): answer_sde = [] # check what native targets do we have 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: try_do_LLVM("build check_ISA", "cl check_isa.cpp", True) SSE2 = ["sse2-i32x4", "sse2-i32x8"] @@ -296,6 +296,18 @@ def check_targets(): def build_ispc(version_LLVM, make): current_path = os.getcwd() 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": p_temp = os.getenv("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() 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 else: p_temp = os.getenv("LLVM_INSTALL_DIR") @@ -650,6 +662,19 @@ def Main(): parser.print_help() 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) if os.environ.get("LLVM_HOME") == None: error("you have no LLVM_HOME", 1) @@ -759,6 +784,8 @@ if __name__ == '__main__': help='ask for validation run', default=False, action="store_true") parser.add_option('-j', dest='speed', 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" llvm_group = OptionGroup(parser, "Options for building LLVM", "These options must be used with -b option.") From 1461b09b5f411c1f1a4d678149e781dd40666c08 Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Mon, 14 Jul 2014 22:04:03 +0400 Subject: [PATCH 2/3] '--ispc_compiler' changed to '--ispc_build_compiler', 'check_isa.cpp' now compiles with '--ispc_build_compiler' (g++ or clang), removed code duplication --- alloy.py | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/alloy.py b/alloy.py index 3809ec58..068531c6 100755 --- a/alloy.py +++ b/alloy.py @@ -33,6 +33,7 @@ # // Author: Filippov Ilia + def attach_mail_file(msg, filename, name): if os.path.exists(filename): fp = open(filename, "rb") @@ -239,7 +240,12 @@ def check_targets(): answer_sde = [] # check what native targets do we have if current_OS != "Windows": - try_do_LLVM("build check_ISA", "g++ check_isa.cpp -o check_isa.exe", True) + if options.ispc_build_compiler == "clang": + cisa_compiler = "clang" + elif options.ispc_build_compiler == "gcc": + cisa_compiler = "g++" + + try_do_LLVM("build check_ISA", cisa_compiler + " check_isa.cpp -o check_isa.exe", True) else: try_do_LLVM("build check_ISA", "cl check_isa.cpp", True) SSE2 = ["sse2-i32x4", "sse2-i32x8"] @@ -297,16 +303,7 @@ def build_ispc(version_LLVM, make): current_path = os.getcwd() 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 + make_ispc = "make " + options.ispc_build_compiler + " -j" + options.speed if current_OS != "Windows": p_temp = os.getenv("PATH") @@ -664,14 +661,9 @@ def Main(): # 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) + if options.ispc_build_compiler != "clang" and \ + options.ispc_build_compiler != "gcc": + error("unknow option for --ispc-compiler: " + options.ispc_build_compiler, 1) parser.print_help() exit(0) @@ -784,8 +776,8 @@ if __name__ == '__main__': help='ask for validation run', default=False, action="store_true") parser.add_option('-j', dest='speed', 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") + parser.add_option('--ispc-build-compiler', dest='ispc_build_compiler', + help='set compiler to build ispc binary (clang/gcc)', default="clang") # options for activity "build LLVM" llvm_group = OptionGroup(parser, "Options for building LLVM", "These options must be used with -b option.") From 21cb6094233d6d90fc11df26709a08c392781a24 Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Wed, 16 Jul 2014 15:12:39 +0400 Subject: [PATCH 3/3] changed 'ispc-compiler' to 'ispc-build-compiler' in error message --- alloy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/alloy.py b/alloy.py index 0d096950..8bd26d6c 100755 --- a/alloy.py +++ b/alloy.py @@ -677,7 +677,7 @@ def Main(): # gcc and g++ options are equal and added for ease of use if options.ispc_build_compiler != "clang" and \ options.ispc_build_compiler != "gcc": - error("unknow option for --ispc-compiler: " + options.ispc_build_compiler, 1) + error("unknow option for --ispc-build-compiler: " + options.ispc_build_compiler, 1) parser.print_help() exit(0)