Skip to content

Commit

Permalink
Merge pull request #199 from traP-jp/feat/#198-clang-compiler
Browse files Browse the repository at this point in the history
✨ clang compiler
  • Loading branch information
comavius authored Feb 24, 2025
2 parents 3b04402 + 76836ce commit 110085c
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 3 deletions.
26 changes: 26 additions & 0 deletions exec-container/compilers/clang/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{pkgs}: let
myClang = pkgs.clang;
myBoost = pkgs.boost;
myGmp = pkgs.gmp;
myEigen = pkgs.eigen;
myAcLibrary = pkgs.ac-library;
myZ3 = pkgs.z3;
in
pkgs.writeShellScriptBin "clang++" ''
export LD_LIBRARY_PATH="${myBoost}/lib:${myGmp}/lib:${myEigen}/share:${myZ3.lib}/lib:$LD_LIBRARY_PATH"
export LIBRARY_PATH="${myBoost}/lib:${myGmp}/lib:${myEigen}/share:${myZ3.lib}/lib:$LIBRARY_PATH"
export CPLUS_INCLUDE_PATH="${myBoost.dev}/include:${myGmp.dev}/include:${myEigen}/include:${myAcLibrary.dev}/include:${myZ3.dev}/include:$CPLUS_INCLUDE_PATH"
exec "${myClang}/bin/clang++" "$@" -lgmpxx -lgmp -lz3
''
// {
traojudge = {
languages = [
{
binName = "clang++";
compile = "${myClang}/bin/g++ -std=c++23 -o $OUT $SRC";
name = "C++(clang)";
run = "$OUT";
}
];
};
}
60 changes: 60 additions & 0 deletions exec-container/compilers/clang/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#include <iostream>
#include <boost/multiprecision/cpp_int.hpp>
#include <gmpxx.h>
#include <eigen3/Eigen/Dense>
#include <atcoder/modint>
#include <z3++.h>

using namespace std;
using namespace boost::multiprecision;
using namespace Eigen;
using namespace atcoder;

int main(void)
{
cout << "Hello, World!" << endl;

// Boostテスト
cpp_int a = 1;
for (int i = 1; i <= 100; i++)
{
a += i;
}
cout << a << endl;

// GMPテスト
mpz_class b = 1;
for (int i = 1; i <= 100; i++)
{
b += i;
}
cout << b << endl;

// Eigenテスト
MatrixXd m(2, 2);
m(0, 0) = 3;
m(1, 0) = 2.5;
m(0, 1) = -1;
m(1, 1) = m(1, 0) + m(0, 1);
cout << m << endl;

// ac-libraryテスト
modint1000000007 c = 1;
for (int i = 1; i <= 100; i++)
{
c += i;
}
cout << c.val() << endl;

// Z3テスト
z3::context ctx;
z3::solver s(ctx);
z3::expr x = ctx.int_const("x");
z3::expr y = ctx.int_const("y");
s.add(x + y == 10);
s.add(x > 3);
s.add(y > 3);
cout << s.check() << endl;

return 0;
}
9 changes: 6 additions & 3 deletions exec-container/compilers/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
haxe = import ./haxe {inherit pkgs;};
raku = import ./raku {pkgs = allpkgs.release2411;};
java = import ./java {pkgs = allpkgs.release2411;};
gcc = import ./gcc {pkgs = allpkgs.release2411;};
gxx = import ./g++ {pkgs = allpkgs.release2411;};
gcc = import ./gcc {inherit pkgs;};
gxx = import ./g++ {inherit pkgs;};
clang = import ./clang {pkgs = allpkgs.release2411;};
in {
all = [
golang
Expand All @@ -24,6 +25,7 @@ in {
java
gcc
gxx
clang
];
traojudge =
[
Expand All @@ -36,7 +38,8 @@ in {
#haxe.traojudge
#raku.traojudge
]
++ java.traojudge.languages;
++ java.traojudge.languages
++ clang.traojudge.languages;
#++ gcc.traojudge.languages;
#++ gxx.traojudge.languages;
}

0 comments on commit 110085c

Please sign in to comment.