Skip to content

Commit 110085c

Browse files
authored
Merge pull request #199 from traP-jp/feat/#198-clang-compiler
✨ clang compiler
2 parents 3b04402 + 76836ce commit 110085c

File tree

3 files changed

+92
-3
lines changed

3 files changed

+92
-3
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{pkgs}: let
2+
myClang = pkgs.clang;
3+
myBoost = pkgs.boost;
4+
myGmp = pkgs.gmp;
5+
myEigen = pkgs.eigen;
6+
myAcLibrary = pkgs.ac-library;
7+
myZ3 = pkgs.z3;
8+
in
9+
pkgs.writeShellScriptBin "clang++" ''
10+
export LD_LIBRARY_PATH="${myBoost}/lib:${myGmp}/lib:${myEigen}/share:${myZ3.lib}/lib:$LD_LIBRARY_PATH"
11+
export LIBRARY_PATH="${myBoost}/lib:${myGmp}/lib:${myEigen}/share:${myZ3.lib}/lib:$LIBRARY_PATH"
12+
export CPLUS_INCLUDE_PATH="${myBoost.dev}/include:${myGmp.dev}/include:${myEigen}/include:${myAcLibrary.dev}/include:${myZ3.dev}/include:$CPLUS_INCLUDE_PATH"
13+
exec "${myClang}/bin/clang++" "$@" -lgmpxx -lgmp -lz3
14+
''
15+
// {
16+
traojudge = {
17+
languages = [
18+
{
19+
binName = "clang++";
20+
compile = "${myClang}/bin/g++ -std=c++23 -o $OUT $SRC";
21+
name = "C++(clang)";
22+
run = "$OUT";
23+
}
24+
];
25+
};
26+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#include <iostream>
2+
#include <boost/multiprecision/cpp_int.hpp>
3+
#include <gmpxx.h>
4+
#include <eigen3/Eigen/Dense>
5+
#include <atcoder/modint>
6+
#include <z3++.h>
7+
8+
using namespace std;
9+
using namespace boost::multiprecision;
10+
using namespace Eigen;
11+
using namespace atcoder;
12+
13+
int main(void)
14+
{
15+
cout << "Hello, World!" << endl;
16+
17+
// Boostテスト
18+
cpp_int a = 1;
19+
for (int i = 1; i <= 100; i++)
20+
{
21+
a += i;
22+
}
23+
cout << a << endl;
24+
25+
// GMPテスト
26+
mpz_class b = 1;
27+
for (int i = 1; i <= 100; i++)
28+
{
29+
b += i;
30+
}
31+
cout << b << endl;
32+
33+
// Eigenテスト
34+
MatrixXd m(2, 2);
35+
m(0, 0) = 3;
36+
m(1, 0) = 2.5;
37+
m(0, 1) = -1;
38+
m(1, 1) = m(1, 0) + m(0, 1);
39+
cout << m << endl;
40+
41+
// ac-libraryテスト
42+
modint1000000007 c = 1;
43+
for (int i = 1; i <= 100; i++)
44+
{
45+
c += i;
46+
}
47+
cout << c.val() << endl;
48+
49+
// Z3テスト
50+
z3::context ctx;
51+
z3::solver s(ctx);
52+
z3::expr x = ctx.int_const("x");
53+
z3::expr y = ctx.int_const("y");
54+
s.add(x + y == 10);
55+
s.add(x > 3);
56+
s.add(y > 3);
57+
cout << s.check() << endl;
58+
59+
return 0;
60+
}

exec-container/compilers/default.nix

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
haxe = import ./haxe {inherit pkgs;};
1010
raku = import ./raku {pkgs = allpkgs.release2411;};
1111
java = import ./java {pkgs = allpkgs.release2411;};
12-
gcc = import ./gcc {pkgs = allpkgs.release2411;};
13-
gxx = import ./g++ {pkgs = allpkgs.release2411;};
12+
gcc = import ./gcc {inherit pkgs;};
13+
gxx = import ./g++ {inherit pkgs;};
14+
clang = import ./clang {pkgs = allpkgs.release2411;};
1415
in {
1516
all = [
1617
golang
@@ -24,6 +25,7 @@ in {
2425
java
2526
gcc
2627
gxx
28+
clang
2729
];
2830
traojudge =
2931
[
@@ -36,7 +38,8 @@ in {
3638
#haxe.traojudge
3739
#raku.traojudge
3840
]
39-
++ java.traojudge.languages;
41+
++ java.traojudge.languages
42+
++ clang.traojudge.languages;
4043
#++ gcc.traojudge.languages;
4144
#++ gxx.traojudge.languages;
4245
}

0 commit comments

Comments
 (0)