2 desc "Garbage collector for C and C++"
3 homepage "https://www.hboehm.info/gc/"
4 url "https://github.com/ivmai/bdwgc/releases/download/v8.2.8/gc-8.2.8.tar.gz"
5 sha256 "7649020621cb26325e1fb5c8742590d92fb48ce5c259b502faf7d9fb5dabb160"
7 head "https://github.com/ivmai/bdwgc.git", branch: "master"
11 strategy :github_latest
15 sha256 cellar: :any, arm64_sequoia: "58c2b5cf58c6ea30fc56a34aacfe36f774bed4cee1dca9808ef58d154a5ec965"
16 sha256 cellar: :any, arm64_sonoma: "26862c04a22c24bbbe25d7fd1a2fa4d499d5a7216101625115be645123ea0445"
17 sha256 cellar: :any, arm64_ventura: "55890248e3f2624e882660e38695e9090a8be1bff6c9a829ef35b0a30a890fee"
18 sha256 cellar: :any, arm64_monterey: "013ffdfc107f8ec5d5382af87412bdfd4cb3503e866555fbe3252c3d7dcdcc10"
19 sha256 cellar: :any, sonoma: "54cd5df410fb01fc0f7a9b212b5ef40e8160e360e597b5d20e6e489df306ce37"
20 sha256 cellar: :any, ventura: "71c1beb334094059de83c81be4f1239e4ece22a1f7baf5c98d9682a2243b13bb"
21 sha256 cellar: :any, monterey: "33e2046794356d765327d03b638c8449e38a69055f801542ee4abd2ea6329f49"
22 sha256 cellar: :any_skip_relocation, x86_64_linux: "f666fdf55ce3b41704f5869120ddfd3e973051d1fc0dc32a80733f20ba15ea0c"
25 depends_on "cmake" => :build
30 -Denable_large_config=ON
31 -Dwithout_libatomic_ops=OFF
32 -Dwith_libatomic_ops=OFF
35 system "cmake", "-S", ".", "-B", "build",
37 "-DBUILD_SHARED_LIBS=ON",
38 "-DCMAKE_INSTALL_RPATH=#{rpath}",
39 *args, *std_cmake_args,
40 "-DBUILD_TESTING=ON" # Pass this *after* `std_cmake_args`
41 system "cmake", "--build", "build"
42 if OS.linux? || Hardware::CPU.arm? || MacOS.version > :monterey
44 system "ctest", "--test-dir", "build",
45 "--parallel", ENV.make_jobs,
49 system "cmake", "--install", "build"
51 system "cmake", "-S", ".", "-B", "build-static", "-DBUILD_SHARED_LIBS=OFF", *args, *std_cmake_args
52 system "cmake", "--build", "build-static"
53 lib.install buildpath.glob("build-static/*.a")
57 (testpath/"test.c").write <<~C
67 for (i = 0; i < 10000000; ++i)
69 int **p = (int **) GC_MALLOC(sizeof(int *));
70 int *q = (int *) GC_MALLOC_ATOMIC(sizeof(int));
72 *p = (int *) GC_REALLOC(q, 2 * sizeof(int));
78 system ENV.cc, "test.c", "-I#{include}", "-L#{lib}", "-lgc", "-o", "test"