Skip to content

Commit

Permalink
fastfec: build with older zig
Browse files Browse the repository at this point in the history
  • Loading branch information
cho-m committed Sep 16, 2024
1 parent 850553e commit 2e07728
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion Formula/f/fastfec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ class Fastfec < Formula
desc "Extremely fast FEC filing parser written in C"
homepage "https://www.washingtonpost.com/fastfec/"
# Check whether PCRE linking issue is fixed in Zig at version bump.
# Switch to `zig` formula when supported: https://github.com/washingtonpost/FastFEC/issues/66
url "https://github.com/washingtonpost/FastFEC/archive/refs/tags/0.2.0.tar.gz"
sha256 "d983cf9e7272700fc24642118759d6ab4185fca74b193851fa6a21e3c73964ab"
license "MIT"
Expand All @@ -16,8 +17,15 @@ class Fastfec < Formula
sha256 cellar: :any_skip_relocation, x86_64_linux: "bf228d820220f1c3499eced326d33d6492bcb86745db6aaaef29e41e8405f01f"
end

depends_on "cmake" => :build # for zig resource
depends_on "llvm@16" => :build # for zig resource
depends_on "pkg-config" => :build
depends_on "zig" => :build
# TODO: depends_on "zig" => :build
depends_on "zstd" => :build # for zig resource
depends_on macos: :big_sur # for zig resource - https://github.com/ziglang/zig/issues/13313

uses_from_macos "ncurses" => :build # for zig resource
uses_from_macos "zlib" => :build # for zig resource

on_macos do
# Zig attempts to link with `libpcre.a` on Linux.
Expand All @@ -28,7 +36,30 @@ class Fastfec < Formula
depends_on "pcre" # PCRE2 issue: https://github.com/washingtonpost/FastFEC/issues/57
end

resource "zig" do
url "https://ziglang.org/download/0.11.0/zig-0.11.0.tar.xz"
sha256 "72014e700e50c0d3528cef3adf80b76b26ab27730133e8202716a187a799e951"
end

def install

Check failure on line 44 in Formula/f/fastfec.rb

View workflow job for this annotation

GitHub Actions / Linux

`brew install --verbose --formula --build-bottle fastfec` failed on Linux!

: Leaving directory '/tmp/fastfec--zig-20240916-10328-xkirt7/zig-0.11.0/build' [ 68%] Built target zig1 /usr/bin/make -f CMakeFiles/zig2.dir/build.make CMakeFiles/zig2.dir/depend make[2]: Entering directory '/tmp/fastfec--zig-20240916-10328-xkirt7/zig-0.11.0/build' [ 73%] Running zig1.wasm to produce /tmp/fastfec--zig-20240916-10328-xkirt7/zig-0.11.0/build/zig2.c [ 78%] Running zig1.wasm to produce /tmp/fastfec--zig-20240916-10328-xkirt7/zig-0.11.0/build/compiler_rt.c cd /tmp/fastfec--zig-20240916-10328-xkirt7/zig-0.11.0 && /tmp/fastfec--zig-20240916-10328-xkirt7/zig-0.11.0/build/zig1 /tmp/fastfec--zig-20240916-10328-xkirt7/zig-0.11.0/lib build-exe src/main.zig -ofmt=c -lc -OReleaseSmall --name zig2 -femit-bin="/tmp/fastfec--zig-20240916-10328-xkirt7/zig-0.11.0/build/zig2.c" --mod build_options::/tmp/fastfec--zig-20240916-10328-xkirt7/zig-0.11.0/build/config.zig --deps build_options -target x86_64-linux cd /tmp/fastfec--zig-20240916-10328-xkirt7/zig-0.11.0 && /tmp/fastfec--zig-20240916-10328-xkirt7/zig-0.11.0/build/zig1 /tmp/fastfec--zig-20240916-10328-xkirt7/zig-0.11.0/lib build-obj lib/compiler_rt.zig -ofmt=c -OReleaseSmall --name compiler_rt -femit-bin="/tmp/fastfec--zig-20240916-10328-xkirt7/zig-0.11.0/build/compiler_rt.c" --mod build_options::/tmp/fastfec--zig-20240916-10328-xkirt7/zig-0.11.0/build/config.zig --deps build_options -target x86_64-linux cd /tmp/fastfec--zig-20240916-10328-xkirt7/zig-0.11.0/build && /home/linuxbrew/.linuxbrew/Cellar/cmake/3.30.3/bin/cmake -E cmake_depends "Unix Makefiles" /tmp/fastfec--zig-20240916-10328-xkirt7/zig-0.11.0 /tmp/fastfec--zig-20240916-10328-xkirt7/zig-0.11.0 /tmp/fastfec--zig-20240916-10328-xkirt7/zig-0.11.0/build /tmp/fastfec--zig-20240916-10328-xkirt7/zig-0.11.0/build /tmp/fastfec--zig-20240916-10328-xkirt7/zig-0.11.0/build/CMakeFiles/zig2.dir/DependInfo.cmake "--color=" make[2]: Leaving directory '/tmp/fastfec--zig-20240916-10328-xkirt7/zig-0.11.0/build' /usr/bin/make -f CMakeFiles/zig2.dir/build.make CMakeFiles/zig2.dir/build make[2]: Entering directory '/tmp/fastfec--zig-20240916-10328-xkirt7/zig-0.11.0/build' [ 89%] Building C object CMakeFiles/zig2.dir/compiler_rt.c.o [ 89%] Building C object CMakeFiles/zig2.dir/zig2.c.o /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/shims/linux/super/gcc-11 -I/tmp/fastfec--zig-20240916-10328-xkirt7/zig-0.11.0 -I/tmp/fastfec--zig-20240916-10328-xkirt7/zig-0.11.0/build -I/tmp/fastfec--zig-20240916-10328-xkirt7/zig-0.11.0/src -I/tmp/fastfec--zig-20240916-10328-xkirt7/zig-0.11.0/stage1 -O3 -DNDEBUG -std=c99 -O0 -fno-stack-protector -MD -MT CMakeFiles/zig2.dir/zig2.c.o -MF CMakeFiles/zig2.dir/zig2.c.o.d -o CMakeFiles/zig2.dir/zig2.c.o -c /tmp/fastfec--zig-20240916-10328-xkirt7/zig-0.11.0/build/zig2.c /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/shims/linux/super/gcc-11 -I/tmp/fastfec--zig-20240916-10328-xkirt7/zig-0.11.0 -I/tmp/fastfec--zig-20240916-10328-xkirt7/zig-0.11.0/build -I/tmp/fastfec--zig-20240916-10328-xkirt7/zig-0.11.0/src -I/tmp/fastfec--zig-20240916-10328-xkirt7/zig-0.11.0/stage1 -O3 -DNDEBUG -std=c99 -O0 -fno-stack-protector -MD -MT CMakeFiles/zig2.dir/compiler_rt.c.o -MF CMakeFiles/zig2.dir/compiler_rt.c.o.d -o CMakeFiles/zig2.dir/compiler_rt.c.o -c /tmp/fastfec--zig-20240916-10328-xkirt7/zig-0.11.0/build/compiler_rt.c [ 94%] Linking CXX executable zig2 /home/linuxbrew/.linuxbrew/Cellar/cmake/3.30.3/bin/cmake -E cmake_link_script CMakeFiles/zig2.dir/link.txt --verbose=1 /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/shims/linux/super/g++-11 -O3 -DNDEBUG -Wl,-z,stack-size=0x10000000 CMakeFiles/zig2.dir/zig2.c.o CMakeFiles/zig2.dir/compiler_rt.c.o -o zig2 -L/home/linuxbrew/.linuxbrew/Cellar/llvm@16/16.0.6_1/lib -Wl,-rpath,/home/linuxbrew/.linuxbrew/Cellar/llvm@16/16.0.6_1/lib zigcpp/libzigcpp.a /home/linuxbrew/.linuxbrew/opt/llvm@16/lib/libclangFrontendTool.a /home/linuxbrew/.linuxbrew/opt/llvm@16/lib/libclangCodeGen.a /home/linuxbrew/.linuxbrew/opt/llvm@16/lib/libclangFrontend.a /home/linuxbrew/.linuxbrew/opt/llvm@16/lib/libclangDriver.a /home/linuxbrew/.linuxbrew/opt/llvm@16/lib/libclangSeriali
resource("zig").stage do
ENV["NIX_LDFLAGS"] = ENV["HOMEBREW_RPATH_PATHS"].split(":").map { |p| "-rpath #{p}" }.join(" ") if OS.linux?

cpu = case Hardware.oldest_cpu
when :arm_vortex_tempest then "apple_m1" # See `zig targets`.
else Hardware.oldest_cpu
end

args = ["-DZIG_STATIC_LLVM=ON"]
args << "-DZIG_TARGET_MCPU=#{cpu}" if build.bottle?
args << "-DCMAKE_EXE_LINKER_FLAGS=-Wl,-ld_classic" if DevelopmentTools.clang_build_version >= 1500

system "cmake", "-S", ".", "-B", "build", *args, *std_cmake_args(install_prefix: buildpath/"zig")
system "cmake", "--build", "build"
system "cmake", "--install", "build"
ENV.prepend_path "PATH", buildpath/"zig/bin"
end

# Set `vendored-pcre` to `false` unconditionally when `pcre` linkage is fixed upstream.
system "zig", "build", "-Dvendored-pcre=#{OS.linux?}"
bin.install "zig-out/bin/fastfec"
Expand Down

0 comments on commit 2e07728

Please sign in to comment.