mudge / re2

Ruby bindings to RE2, a "fast, safe, thread-friendly alternative to backtracking regular expression engines like those used in PCRE, Perl, and Python".
http://mudge.name/re2/
BSD 3-Clause "New" or "Revised" License
130 stars 13 forks source link

Fix compilation with re2 2023-07-01 #65

Closed stanhu closed 1 year ago

stanhu commented 1 year ago

https://code-review.googlesource.com/c/re2/+/61250 made re2 depend directly on abseil. The latest version of abseil now requires C++14 (https://github.com/abseil/abseil-cpp/issues/1127). However, it seems that supplying -std=c++14 isn't enough (https://github.com/abseil/abseil-cpp/issues/1431). -std=c++17 needs to be used at least.

This commit fixes the compilation by trying C++20 and C++17 if the initial compilation fails. This fixes build issues on macOS.

stanhu commented 1 year ago

It seems abseil is no longer an optional dependency on a separate branch: https://github.com/google/re2/issues/388

https://code-review.googlesource.com/c/re2/+/61270 updated the README to make this official.

mudge commented 1 year ago

Thanks for this, @stanhu. I'll try and get the new 2023-07-01 release (with its added abseil dependency) into the CI matrix (via re2-ci).

mudge commented 1 year ago

Have you had any luck compiling the latest re2 from scratch on Ubuntu 20.04?

stanhu commented 1 year ago

Have you had any luck compiling the latest re2 from scratch on Ubuntu 20.04?

@mudge Yes, but only by installing a PPA with libabsl-dev. It seems that the libabsl-dev package is only available with Ubuntu 22.04: https://packages.ubuntu.com/jammy/libabsl-dev. This is what I ran:

docker run -it ubuntu:20.04 bash
apt update && apt install -y software-properties-common build-essential pkg-config git
add-apt-repository ppa:savoury1/build-tools
apt install -y libabsl-dev
git clone https://github.com/google/re2.git /tmp/re2
cd /tmp/re2
make
mudge commented 1 year ago

I hoped I could bump the more recent Ruby builds to Ubuntu 22.04 so we could use libabsl-dev (and libabsl20210324) but it looks like there are fatal problems trying to use RubyGems on Ubuntu 22.04 so I'll need to use the PPA or package up my own libabsl and stick with Ubuntu 20.04 for older Rubies.

stanhu commented 1 year ago

@mudge Is there a reason these older Ruby versions still need to be supported? Even Ruby 2.7 reached end-of-life 3 months ago.

mudge commented 1 year ago

It's not a popular opinion but until it becomes extraordinarily painful (which might not be too far away), I don't want to break compatibility for anyone who can already run the gem.

In this case, I've added the PPA you mentioned to the existing 20.04 build (and I've packaged up a .deb of re2 2023-07-01 compiled against the libabsl-dev from the PPA) but it looks like the build is failing: https://github.com/mudge/re2/actions/runs/5456057642/jobs/9928355646

mudge commented 1 year ago

OK, I've fixed the build (libabsl2206 isn't enough, we needed the full libabsl-dev).

mudge commented 1 year ago

Thanks @stanhu, I've now rebased this into https://github.com/mudge/re2/commit/8b62c5c4ac5552d6b3465d0d4a3b6494604bcb1b and it'll go out in version 1.7.0 once the tests pass on main.