diff options
| author | Sebastian Stenzel | 2014-10-12 22:45:34 +0200 |
|---|---|---|
| committer | Tim D. Smith | 2015-04-07 11:21:25 -0700 |
| commit | c7d403b9306a4662c17055f1766aa69dd2dc2909 (patch) | |
| tree | 0d6f0a59ac582b479cff9a08b3880349efc43e68 /Library/Formula | |
| parent | 656d5b8891a2c23eab563c5e983ccb8a30d85930 (diff) | |
| download | homebrew-c7d403b9306a4662c17055f1766aa69dd2dc2909.tar.bz2 | |
clang-omp 2015.04.01
Installation of OpenMP/Clang compiler as described on http://clang-omp.github.io/
Closes #33278.
Signed-off-by: Tim D. Smith <git@tim-smith.us>
Diffstat (limited to 'Library/Formula')
| -rw-r--r-- | Library/Formula/clang-omp.rb | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/Library/Formula/clang-omp.rb b/Library/Formula/clang-omp.rb new file mode 100644 index 000000000..1905bb825 --- /dev/null +++ b/Library/Formula/clang-omp.rb @@ -0,0 +1,63 @@ +class ClangOmp < Formula + homepage "https://clang-omp.github.io/" + url "https://github.com/clang-omp/llvm/archive/2015-04-01.tar.gz" + version "2015-04-01" + sha256 "37f990ad99b3213507ec88f86702c5a057ce397cc16638eeee5c88906572daec" + + depends_on "libiomp" + depends_on "cmake" => :build + + resource "compiler-rt" do + url "https://github.com/clang-omp/compiler-rt/archive/2015-04-01.tar.gz" + sha256 "5a8d39ff6ce524e23fae32870f85b18d43f2795da2011d3cbb6b29d471bb27b7" + end + + resource "clang" do + url "https://github.com/clang-omp/clang/archive/2015-04-01.tar.gz" + sha256 "2717115e5ba491e3b8119311f0d792420ba41be34a89733b9880eb3d3c09fbe5" + end + + needs :cxx11 + + def install + resource("compiler-rt").stage { (buildpath/"projects/compiler-rt").install Dir["*"] } + resource("clang").stage { (buildpath/"tools/clang").install Dir["*"] } + + system "./configure", "--prefix=#{libexec}", "--enable-cxx11", "--enable-libcpp" + system "make", "install" + + bin.install_symlink libexec/"bin/clang" => "clang-omp" + end + + test do + testfile = <<-EOS.undent + #include <stdlib.h> + #include <stdio.h> + #include <libiomp/omp.h> + + int main() { + #pragma omp parallel num_threads(4) + { + printf("Hello from thread %d, nthreads %d\\n", omp_get_thread_num(), omp_get_num_threads()); + } + return EXIT_SUCCESS; + } + EOS + (testpath/"test.c").write(testfile) + system "#{bin}/clang-omp", "-L/usr/local/lib", "-liomp5", "-fopenmp", "-Werror", "-Wall", "test.c", "-o", "test" + system "./test>#{testpath}/testresult" + + testresult = (testpath/"testresult").read + testresult_lines = testresult.split "\n" + sorted_testresult_lines = testresult_lines.sort + sorted_testresult = sorted_testresult_lines.join "\n" + expected_result = <<-EOS.undent + Hello from thread 0, nthreads 4 + Hello from thread 1, nthreads 4 + Hello from thread 2, nthreads 4 + Hello from thread 3, nthreads 4 + EOS + + assert_equal expected_result.strip, sorted_testresult.strip + end +end |
