Skip to content

Commit

Permalink
✨ clang compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
comavius committed Feb 12, 2025
1 parent 89b7de5 commit 5f1bbce
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 3 deletions.
25 changes: 25 additions & 0 deletions exec-container/compilers/clang/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{pkgs}: let
myClang = pkgs.clang;
myBoost = pkgs.boost;
myGmp = pkgs.gmp;
myEigen = pkgs.eigen;
myAcLibrary = pkgs.ac-library;
in
pkgs.writeShellScriptBin "clang++" ''
export LD_LIBRARY_PATH="${myBoost}/lib:${myGmp}/lib:${myEigen}/share:$LD_LIBRARY_PATH"
export LIBRARY_PATH="${myBoost}/lib:${myGmp}/lib:${myEigen}/share:$LIBRARY_PATH"
export CPLUS_INCLUDE_PATH="${myBoost.dev}/include:${myGmp.dev}/include:${myEigen}/include:${myAcLibrary.dev}/include:$CPLUS_INCLUDE_PATH"
exec "${myClang}/bin/clang++" "$@" -lgmpxx -lgmp
''
// {
traojudge = {
languages = [
{
binName = "clang++";
compile = "${myClang}/bin/g++ -std=c++23 -o $OUT $SRC";
name = "C++(clang)";
run = "$OUT";
}
];
};
}
49 changes: 49 additions & 0 deletions exec-container/compilers/clang/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#include <iostream>
#include <boost/multiprecision/cpp_int.hpp>
#include <gmpxx.h>
#include <eigen3/Eigen/Dense>
#include <atcoder/modint>

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;

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 5f1bbce

Please sign in to comment.