diff --git a/build/icc/VERSIONS b/build/icc/VERSIONS new file mode 100644 index 00000000..10c25354 --- /dev/null +++ b/build/icc/VERSIONS @@ -0,0 +1 @@ +2021.2.0 diff --git a/build/icc/docker/Dockerfile b/build/icc/docker/Dockerfile new file mode 100644 index 00000000..738dfbf7 --- /dev/null +++ b/build/icc/docker/Dockerfile @@ -0,0 +1,14 @@ +FROM ubuntu:16.04 + +MAINTAINER melpon + +RUN apt-get update && \ + apt-get install -y software-properties-common apt-transport-https ca-certificates wget && \ + wget -O - https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB 2>/dev/null | apt-key add - && \ + add-apt-repository -y "deb https://apt.repos.intel.com/oneapi all main" && \ + apt-get update && \ + apt-get install -y --no-install-recommends \ + g++ \ + && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* diff --git a/build/icc/install.sh b/build/icc/install.sh new file mode 100755 index 00000000..dc6820f4 --- /dev/null +++ b/build/icc/install.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +. ../init.sh + +if [ $# -lt 1 ]; then + echo "$0 " + exit 0 +fi + +VERSION=$1 +PREFIX=/opt/wandbox/icc-$VERSION + +# install + +# pip3 install dpcpp-cpp-rt==$VERSION +apt-get update + +install_package() { + apt-get install -y $1=$(apt list -a $1 2>/dev/null | grep -o "$VERSION-[0-9]*" | head -n 1) +} +# install_package intel-oneapi-ippcp-devel +install_package intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic + +rm -r $PREFIX || true +cp -r /opt/intel/oneapi/ $PREFIX || true + +cp $BASE_DIR/resources/run-icc.sh.in $PREFIX/run-icc.sh +sed -i "s#@icc_prefix@#$PREFIX#g" $PREFIX/run-icc.sh +chmod +x $PREFIX/run-icc.sh + +cp $BASE_DIR/resources/run-icc.sh.in $PREFIX/run-icpc.sh +sed -i "s#@icc_prefix@#$PREFIX#g" $PREFIX/run-icpc.sh +chmod +x $PREFIX/run-icpc.sh diff --git a/build/icc/resources/run-icc.sh.in b/build/icc/resources/run-icc.sh.in new file mode 100644 index 00000000..781c463b --- /dev/null +++ b/build/icc/resources/run-icc.sh.in @@ -0,0 +1,5 @@ +#!/bin/bash + +. @icc_prefix@/setvars.sh 2>&1 >/dev/null + +icc "$@" diff --git a/build/icc/resources/run-icpc.sh.in b/build/icc/resources/run-icpc.sh.in new file mode 100644 index 00000000..79e2e4d4 --- /dev/null +++ b/build/icc/resources/run-icpc.sh.in @@ -0,0 +1,5 @@ +#!/bin/bash + +. @icc_prefix@/setvars.sh 2>&1 >/dev/null + +icpc "$@" diff --git a/build/icc/resources/test.c b/build/icc/resources/test.c new file mode 100644 index 00000000..4048912c --- /dev/null +++ b/build/icc/resources/test.c @@ -0,0 +1,5 @@ +#include + +int main(void) { + printf("hello\n"); +} diff --git a/build/icc/resources/test.cpp b/build/icc/resources/test.cpp new file mode 100644 index 00000000..8f6534e9 --- /dev/null +++ b/build/icc/resources/test.cpp @@ -0,0 +1,5 @@ +#include + +int main() { + std::cout << "hello" << std::endl; +} diff --git a/build/icc/test.sh b/build/icc/test.sh new file mode 100755 index 00000000..810447cf --- /dev/null +++ b/build/icc/test.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +. ../init.sh + +if [ $# -lt 1 ]; then + echo "$0 " + exit 0 +fi + +VERSION=$1 +PREFIX=/opt/wandbox/icc-$VERSION + +$PREFIX/run-icc.sh $BASE_DIR/resources/test.cpp +./a.out > /dev/null +test "`./a.out`" = "hello" +rm a.out diff --git a/cattleshed-conf/compilers.py b/cattleshed-conf/compilers.py index a605678e..0bdd5c85 100644 --- a/cattleshed-conf/compilers.py +++ b/cattleshed-conf/compilers.py @@ -257,7 +257,8 @@ def make_boost(self): gcc_vers = sort_version(get_gcc_versions(includes_gcc_1=False, with_head=True)) clang_vers = sort_version(get_generic_versions('clang', with_head=True)) zapcc_vers = sort_version(get_generic_versions('zapcc', with_head=False)) - compiler_vers = [('gcc', v) for v in gcc_vers] + [('clang', v) for v in clang_vers] + [('zapcc', v) for v in zapcc_vers] + icpc_vers = sort_version(get_generic_versions('icc', with_head=False)) + compiler_vers = [('gcc', v) for v in gcc_vers] + [('clang', v) for v in clang_vers] + [('zapcc', v) for v in zapcc_vers] + [('icpc', v) for v in icpc_vers] boost_ver_set = set(get_boost_versions_with_head()) boost_libs = {} @@ -1026,6 +1027,141 @@ def make_zapcc(self): return compilers + def make_icc(self): + icc_vers = sort_version(get_generic_versions('icc', with_head=False), reverse=True) + + compilers = [] + for cv in icc_vers: + switches = [] + initial_checked = [] + + # default + switches += ['warning', 'optimize', 'cpp-verbose'] + initial_checked += ['warning'] + + # C + switches += ['std-c-default', 'c89', 'gnu89', 'c99', 'gnu99', 'c11', 'c17', 'c18'] + initial_checked += [switches[-1]] + + # pedantic + switches += ['cpp-no-pedantic', 'cpp-pedantic', 'cpp-pedantic-errors'] + + # -fansi-escape-codes + ansi_escape_codes = ['-fansi-escape-codes'] + + # compile-command + compile_command = [ + '/opt/wandbox/icc-{cv}/run-icc.sh', + '-oprog.exe', + '-fcolor-diagnostics' + ] + ansi_escape_codes + [ + 'prog.c' + ] + + display_name = 'icc' + version_command = ['/bin/echo', '{cv}'] + + compilers.append(format_value({ + 'name': 'icc-{cv}', + 'compile-command': compile_command, + 'version-command': version_command, + 'display-name': display_name, + 'display-compile-command': 'icc prog.c', + 'language': 'C', + 'output-file': 'prog.c', + 'run-command': './prog.exe', + 'displayable': True, + 'compiler-option-raw': True, + 'switches': switches, + 'initial-checked': initial_checked, + 'jail-name': 'melpon2-default', + 'templates': ['icc'], + }, cv=cv)) + + return compilers + + def make_icpc(self): + boost_vers = sort_version(set(a for a, _, _ in get_boost_versions_with_head())) + icpc_vers = sort_version(get_generic_versions('icc', with_head=False), reverse=True) + + boost_ver_set = set(get_boost_versions_with_head()) + # boost versions + boost_switches = {} + for cv in icpc_vers: + xs = [] + for bv in boost_vers: + if (bv, 'icpc', cv) not in boost_ver_set: + continue + xs.append('{bv}'.format(bv=bv)) + nothing = ['boost-nothing-icpc-{cv}'.format(cv=cv)] + boost_switches[cv] = nothing + ['boost-{x}-icpc-{cv}'.format(x=x, cv=cv) for x in sort_version(xs)] + + compilers = [] + for cv in icpc_vers: + switches = [] + initial_checked = [] + + # default + switches += ['warning', 'optimize', 'cpp-verbose'] + initial_checked += ['warning'] + + # boost + if cv in boost_switches: + bs = boost_switches[cv] + switches += bs + initial_checked += [bs[-1]] + + # libs + switches += ['sprout', 'msgpack'] + + # C++ + switches += ['std-c++-default', 'c++98', 'gnu++98', 'c++11', 'gnu++11', 'c++14', 'gnu++14', 'c++17', 'gnu++17', 'c++20', 'gnu++20'] + initial_checked += [switches[-1]] + + # pedantic + switches += ['cpp-no-pedantic', 'cpp-pedantic', 'cpp-pedantic-errors'] + + # -fansi-escape-codes + ansi_escape_codes = ['-fansi-escape-codes'] + + # compile-command + compile_command = [ + '/opt/wandbox/icc-{cv}/run-icpc.sh', + '-oprog.exe', + '-fcolor-diagnostics' + ] + ansi_escape_codes + [ + '-lpthread', + '-I/opt/wandbox/boost-sml/include', + '-I/opt/wandbox/boost-di/include', + '-I/opt/wandbox/range-v3/include', + '-I/opt/wandbox/nlohmann-json/include', + '-I/opt/wandbox/cmcstl2/include', + '-I/opt/wandbox/te/include'] + compile_command += ['prog.cc'] + + # head specific + display_name = 'icpc' + version_command = ['/bin/echo', '{cv}'] + + compilers.append(format_value({ + 'name': 'icpc-{cv}', + 'compile-command': compile_command, + 'version-command': version_command, + 'display-name': display_name, + 'display-compile-command': 'icpc prog.cc', + 'language': 'C++', + 'output-file': 'prog.cc', + 'run-command': './prog.exe', + 'displayable': True, + 'compiler-option-raw': True, + 'switches': switches, + 'initial-checked': initial_checked, + 'jail-name': 'melpon2-default', + 'templates': ['icpc'], + }, cv=cv)) + + return compilers + def make_mono(self): mono_vers = sort_version(get_generic_versions('mono', with_head=True), reverse=True) compilers = [] @@ -2375,6 +2511,8 @@ def make(self): self.make_clang_pp() + self.make_clang() + self.make_zapcc() + + self.make_icc() + + self.make_icpc() + self.make_mono() + self.make_rill() + self.make_erlang() + diff --git a/cattleshed-conf/templates/icc/prog.c b/cattleshed-conf/templates/icc/prog.c new file mode 100644 index 00000000..07ebc058 --- /dev/null +++ b/cattleshed-conf/templates/icc/prog.c @@ -0,0 +1,16 @@ +// This file is a "Hello, world!" in C language by gcc for wandbox. +#include +#include + +int main(void) +{ + puts("Hello, Wandbox!"); + return EXIT_SUCCESS; +} + +// Intel reference: +// https://software.intel.com/content/www/us/en/develop/tools/oneapi/components/dpc-compiler.html#gs.ztuee0 + +// C language references: +// https://msdn.microsoft.com/library/fw5abdx6.aspx +// https://www.gnu.org/software/gnu-c-manual/ diff --git a/cattleshed-conf/templates/icpc/prog.cc b/cattleshed-conf/templates/icpc/prog.cc new file mode 100644 index 00000000..e2267657 --- /dev/null +++ b/cattleshed-conf/templates/icpc/prog.cc @@ -0,0 +1,20 @@ +// This file is a "Hello, world!" in C++ language by Zapcc for wandbox. +#include +#include + +int main() +{ + std::cout << "Hello, Wandbox!" << std::endl; +} + +// Intel reference: +// https://software.intel.com/content/www/us/en/develop/tools/oneapi/components/dpc-compiler.html#gs.ztuee0 + +// C++ language references: +// https://msdn.microsoft.com/library/3bstk3k5.aspx +// http://www.cplusplus.com/ +// https://isocpp.org/ +// http://www.open-std.org/jtc1/sc22/wg21/ + +// Boost libraries references: +// http://www.boost.org/doc/ diff --git a/test/run.py b/test/run.py index 3890c6f7..1ed7b1fc 100644 --- a/test/run.py +++ b/test/run.py @@ -199,6 +199,13 @@ def test_boost_head(): add_test(name, lambda: run_boost(version, compiler, 'head', code, '23\n0\nSuccess\n')) +def test_icpc(): + code = codecs.open('../build/icc/resources/test.c', 'r', 'utf-8').read() + for cv in get_generic_versions('icc', with_head=False): + compiler = 'icpc-{cv}'.format(cv=cv) + add_test(compiler, lambda compiler=compiler: run(compiler, code, 'hello\n')) + + def test_preprocessor(): compiler = 'gcc-head-pp' code = codecs.open('../build/gcc-head/resources/test.pp', 'r', 'utf-8').read() @@ -249,6 +256,8 @@ def register(): test_generic(name='clang', test_file='test.c', expected='hello\n', with_head=True, post_name='-c') test_generic(name='clang', test_file='test.cpp', expected='hello\n', with_head=True) test_generic(name='zapcc', test_file='test.cpp', expected='hello\n', with_head=False) + test_generic(name='icc', test_file='test.c', expected='hello\n', with_head=False) + test_icpc() test_preprocessor() test_generic(name='mono', test_file='test.cs', expected='hello\n', with_head=True) test_generic(name='erlang', test_file='prog.erl', expected='hello\n', with_head=True)