Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compilation with re2 2023-07-01 #65

Closed
wants to merge 7 commits into from

Conversation

stanhu
Copy link
Collaborator

@stanhu stanhu commented Jul 3, 2023

https://code-review.googlesource.com/c/re2/+/61250 made re2 depend directly on abseil. The latest version of abseil now requires C++14 (abseil/abseil-cpp#1127). However, it seems that supplying -std=c++14 isn't enough (abseil/abseil-cpp#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.

https://code-review.googlesource.com/c/re2/+/61250 made re2 depend
directly on abseil. The latest version of abseil now requires C++14
(abseil/abseil-cpp#1127). However, it seems
that supplying `-std=c++14` isn't enough
(abseil/abseil-cpp#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 stanhu force-pushed the sh-support-re2-2023-07-01 branch from a97200c to a6b007f Compare July 3, 2023 18:13
@stanhu
Copy link
Collaborator Author

stanhu commented Jul 3, 2023

It seems abseil is no longer an optional dependency on a separate branch: google/re2#388

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

@mudge
Copy link
Owner

mudge commented Jul 3, 2023

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).

# https://github.com/abseil/abseil-cpp/issues/1431). However, the
# `std=c++14` flag doesn't appear to suffice; we need at least
# `std=c++17`.
checking_for("re2 requires a C++14 compiler") do
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way for us to print the relevant message as we check for a C++17 compiler separately from checking for a C++11 compiler (for versions of re2 prior to release 2023-07-01)?

It's also worth noting that the return value of the block is used to determine whether it will print yes or no when compiling, e.g. when I tried this on my machine with the latest release, I see:

checking for re2 requires a C++14 compiler... no

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mudge Good point, I've improved the messages.

This commit will now display a "checking for" message for each C++
version attempted. For example:

```
checking for -lstdc++... yes
checking for stdint.h... yes
checking for rb_str_sublen()... yes
checking for -lre2... yes
checking for re2 requires explicit C++ version flag... yes
checking for re2 compiles with -std=c++20... no
checking for re2 compiles with -std=c++17... yes
checking for RE2::Match() with endpos argument... yes
checking for RE2::Set::Match() with error information... yes
creating Makefile
```
@stanhu stanhu force-pushed the sh-support-re2-2023-07-01 branch from 98e910b to 7e927e9 Compare July 3, 2023 19:23
@mudge
Copy link
Owner

mudge commented Jul 3, 2023

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

@stanhu
Copy link
Collaborator Author

stanhu commented Jul 3, 2023

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 added a commit to mudge/re2-ci that referenced this pull request Jul 4, 2023
GitHub: mudge/re2#65

From release 2023-07-01, re2 now requires Abseil (libabsl-dev) which is
only available by default on Ubuntu 22.04. As older versions of re2
compiled on Ubuntu 20.04 should continue to work, we'll continue to use
those even on newer GitHub Actions runners.
@mudge
Copy link
Owner

mudge commented Jul 4, 2023

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.

GitHub: mudge#65

In order to test against re2 2023-07-01, we need libabsl available on
the GitHub Actions runner.
@stanhu
Copy link
Collaborator Author

stanhu commented Jul 4, 2023

@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
Copy link
Owner

mudge commented Jul 4, 2023

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
Copy link
Owner

mudge commented Jul 4, 2023

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

@mudge
Copy link
Owner

mudge commented Jul 4, 2023

Thanks @stanhu, I've now rebased this into 8b62c5c and it'll go out in version 1.7.0 once the tests pass on main.

@mudge mudge closed this Jul 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants