Skip to content

Commit c3b96a2

Browse files
committed
libc++2
Closes #646. Signed-off-by: paperchalice <29250197+paperchalice@users.noreply.github.com>
1 parent c1f70e3 commit c3b96a2

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

Formula/llvm/libc++2.rb

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
class Libcxx2 < Formula
2+
desc "LLVM C++ standard library (unstable ABI)"
3+
homepage "https://libcxx.llvm.org/"
4+
url "https://github.com/llvm/llvm-project/releases/download/llvmorg-20.1.0/llvm-project-20.1.0.src.tar.xz"
5+
sha256 "4579051e3c255fb4bb795d54324f5a7f3ef79bd9181e44293d7ee9a7f62aad9a"
6+
license "Apache-2.0" => { with: "LLVM-exception" }
7+
8+
bottle do
9+
root_url "https://github.com/paperchalice/homebrew-private/releases/download/libc++-19.1.5"
10+
sha256 cellar: :any, ventura: "8202d54aeb93ffaecd47aec1a9a3b14f2dd3e1c78da52c400ae8bee12b07f652"
11+
end
12+
13+
depends_on "clang" => :build
14+
depends_on "cmake" => :build
15+
16+
depends_on "libc++abi"
17+
depends_on "tzdb"
18+
depends_on "unwind"
19+
20+
def install
21+
inreplace "libcxx/src/experimental/tzdb.cpp" do |s|
22+
tzdb = Formula["tzdb"]
23+
s.gsub! "__linux__", "__APPLE__"
24+
s.gsub! "/usr/share/zoneinfo/", "#{tzdb.share}/zoneinfo/"
25+
end
26+
27+
clang = Formula["clang"]
28+
ENV["CC"] = clang.bin/"clang"
29+
ENV["CXX"] = clang.bin/"clang++"
30+
31+
libunwind = Formula["unwind"]
32+
libcxxabi = Formula["libc++abi"]
33+
rpaths = [rpath, libunwind.opt_lib, libcxxabi.opt_lib]
34+
cmake_args = std_cmake_args+ %W[
35+
-D CMAKE_INSTALL_RPATH=#{rpaths.join(";")}
36+
-D LLVM_ENABLE_RUNTIMES=libcxx;libcxxabi;libunwind
37+
-D LIBCXX_INSTALL_MODULES=ON
38+
-D LIBCXX_ENABLE_TIME_ZONE_DATABASE=ON
39+
-D LIBCXX_ABI_UNSTABLE=ON
40+
41+
-S runtimes
42+
-B build
43+
]
44+
45+
system "cmake", *cmake_args
46+
system "cmake", "--build", "build", "--target", "install-cxx-stripped"
47+
end
48+
49+
test do
50+
(testpath/"main.cpp").write <<~EOS
51+
#include <iostream>
52+
#include <vector>
53+
int main() {
54+
std::vector<int> vec = {1, 2, 3};
55+
for(const auto &i : vec) {
56+
std::cout << vec[0] << std::endl;
57+
}
58+
return 0;
59+
}
60+
EOS
61+
args = %W[
62+
-std=c++17
63+
-nostdlibinc
64+
-I#{include}/c++/v1
65+
-L#{lib}
66+
]
67+
system ENV.cxx, "main.cpp", *args
68+
end
69+
end

0 commit comments

Comments
 (0)