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

Upgrade abseil to 20230802.1 #95

Closed
wants to merge 5 commits into from
Closed

Conversation

mudge
Copy link
Owner

@mudge mudge commented Sep 9, 2023

RE2 2023-09-01 was released a week ago and there is a more recent LTS version of Abseil for us to use. However, when I initially pushed this to our v2.0.x branch, it looks like there are quite a few build failures to investigate.

@mudge mudge requested a review from stanhu September 9, 2023 11:44
@mudge
Copy link
Owner Author

mudge commented Sep 9, 2023

If it’s a distraction right now, we could skip the abseil upgrade but it’d be good to know why it doesn’t work when the January release does.

@stanhu
Copy link
Collaborator

stanhu commented Sep 9, 2023

It looks like there are two main issues:

  1. macOS (https://github.com/mudge/re2/actions/runs/6130653443/job/16639942206): absel::optional is aliased to C++17 std::optional, but the call to value() (introduced in abseil-cpp via abseil/abseil-cpp@751ade0) is only available starting in macOS 10.14. Even though the macOS SDK 11.1 is used, I'd have to presume the compiler tries to target a lower minimum target version:
 [ 97%] Building CXX object absl/status/CMakeFiles/status.dir/status.cc.o
/tmp/d20230909-93-us36r9/tmp/arm64-apple-darwin/ports/abseil/20230802.0/abseil-cpp-20230802.0/absl/status/status.cc:126:51: error: 'value' is unavailable: introduced in macOS 10.14
  if (index.has_value()) return (*payloads)[index.value()].payload;
                                                  ^

I think we might be able to set ABSL_OPTION_USE_STD_OPTIONAL to 0 to disable this aliasing, or consider raising the macOS minimum version. clang --help shows this option:

-mmacosx-version-min=<value>
                      Set Mac OS X deployment target
  1. Windows (https://github.com/mudge/re2/actions/runs/6130653443/job/16639942231):
[ 37%] Building CXX object absl/synchronization/CMakeFiles/synchronization.dir/internal/create_thread_identity.cc.obj
In file included from /tmp/d20230909-93-l6kcab/tmp/x86_64-w64-mingw32/ports/abseil/20230802.0/abseil-cpp-20230802.0/absl/synchronization/internal/create_thread_identity.cc:21:
/tmp/d20230909-93-l6kcab/tmp/x86_64-w64-mingw32/ports/abseil/20230802.0/abseil-cpp-20230802.0/absl/synchronization/internal/waiter.h:44:2: error: #error ABSL_WAITER_MODE is undefined
   44 | #error ABSL_WAITER_MODE is undefined
      |  ^~~~~
/tmp/d20230909-93-l6kcab/tmp/x86_64-w64-mingw32/ports/abseil/20230802.0/abseil-cpp-20230802.0/absl/synchronization/internal/waiter.h:51:5: warning: "ABSL_WAITER_MODE" is not defined, evaluates to 0 [-Wundef]
   51 | #if ABSL_WAITER_MODE == ABSL_WAITER_MODE_FUTEX
      |     ^~~~~~~~~~~~~~~~
In file included from /tmp/d20230909-93-l6kcab/tmp/x86_64-w64-mingw32/ports/abseil/20230802.0/abseil-cpp-20230802.0/absl/synchronization/internal/create_thread_identity.cc:21:
/tmp/d20230909-93-l6kcab/tmp/x86_64-w64-mingw32/ports/abseil/20230802.0/abseil-cpp-20230802.0/absl/synchronization/internal/waiter.h:52:16: error: 'FutexWaiter' does not name a type
   52 | using Waiter = FutexWaiter;
      |                ^~~~~~~~~~~
make[2]: *** [absl/synchronization/CMakeFiles/synchronization.dir/build.make:92: absl/synchronization/CMakeFiles/synchronization.dir/internal/create_thread_identity.cc.obj] Error 1
make[1]: *** [CMakeFiles/Makefile2:4540: absl/synchronization/CMakeFiles/synchronization.dir/all] Error 2

There appears to be a workaround: abseil/abseil-cpp#1510 (comment).

@stanhu stanhu force-pushed the upgrade-re2-to-2023-09-01 branch from d28c745 to 3e28c66 Compare September 10, 2023 06:03
@@ -23,6 +23,7 @@ if [[ "${BUILD_NATIVE_GEM}" == "ruby" ]] ; then
bundle exec rake clean
bundle exec rake gem
else
export MACOSX_DEPLOYMENT_TARGET=10.14
Copy link
Collaborator

Choose a reason for hiding this comment

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

I tried hard to avoid this duplication in the Rakefile. I originally tried to pass cmake -DCMAKE_CXX_FLAGS=-mmacosx-version-min=10.14 (https://github.com/tpoechtrager/osxcross#deployment-target), but the compiler flags had redundant values, with the latter one overriding the one I set:

-mmacosx-version-min=10.14 -mmacosx-version-min=10.13 ...

Copy link
Owner Author

Choose a reason for hiding this comment

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

Does this mean the native gems for macOS will no longer run on High Sierra (10.13) and instead require Mojave (10.14)? If so, perhaps we should add that to the README along with the glibc requirements.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes. The alternative is to file an upstream fix to abseil to be able control the behavior of ABSL_OPTION_USE_STD_OPTIONAL independently of MACOSX_DEPLOYMENT_TARGET, but I suspect it's not worth the effort.

-labsl_hashtablez_sampler
-labsl_exponential_biased
-labsl_bad_optional_access
-labsl_str_format_internal
-labsl_synchronization
-labsl_graphcycles_internal
-labsl_kernel_timeout_internal
Copy link
Collaborator

Choose a reason for hiding this comment

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

I was hoping we could drop this workaround in #96, but the runners are still using pkgconf 1.9.3. 2.0.0 will fix this: pkgconf/pkgconf#268

@stanhu
Copy link
Collaborator

stanhu commented Sep 10, 2023

@mudge I think this is ready to go.

@mudge mudge mentioned this pull request Sep 10, 2023
@mudge mudge force-pushed the upgrade-re2-to-2023-09-01 branch from 357c626 to 9a9070c Compare September 10, 2023 12:42
@mudge mudge changed the title Upgrade re2 to 2023-09-01 and abseil to 20230802 Upgrade abseil to 20230802 Sep 10, 2023
Base automatically changed from v2.0.x to main September 13, 2023 17:34
@mudge mudge force-pushed the main branch 2 times, most recently from 073ee08 to 09b9b90 Compare September 23, 2023 18:58
@mudge mudge force-pushed the upgrade-re2-to-2023-09-01 branch from 9a9070c to c66733a Compare September 23, 2023 19:17
@mudge mudge changed the title Upgrade abseil to 20230802 Upgrade abseil to 20230802.1 Sep 23, 2023
@mudge
Copy link
Owner Author

mudge commented Sep 23, 2023

Updated for the recently released 20230802.1 (note I removed c284a7e just to see if that regression has been fixed but we may need to restore it restored as it looks like it is still a problem).

@mudge
Copy link
Owner Author

mudge commented Sep 23, 2023

@stanhu any chance you could take a look at this? The Windows failures seem different to with patch level 0.

undefined reference to `absl::lts_20230802::synchronization_internal::Win32Waiter::Win32Waiter()

@mudge
Copy link
Owner Author

mudge commented Sep 23, 2023

Out of interest, is MacPorts providing a version of Abseil that works with versions of macOS older than 10.14? See https://github.com/judaew/macports-ports/blob/master/devel/abseil/Portfile

@stanhu
Copy link
Collaborator

stanhu commented Sep 23, 2023

std::optional was added in C++17, and I see that they have set C++14 in https://github.com/judaew/macports-ports/blob/c536e357838df685f32fdedc7b74dd5d4f0325ce/devel/abseil/Portfile#L68. This might avoid the need to upgrade macOS. Maybe for macOS we can use C++14.

@mudge mudge force-pushed the upgrade-re2-to-2023-09-01 branch from 8f32657 to 1147c0b Compare September 24, 2023 06:41
@mudge
Copy link
Owner Author

mudge commented Sep 24, 2023

std::optional was added in C++17, and I see that they have set C++14 in https://github.com/judaew/macports-ports/blob/c536e357838df685f32fdedc7b74dd5d4f0325ce/devel/abseil/Portfile#L68. This might avoid the need to upgrade macOS. Maybe for macOS we can use C++14.

Good spot. Given Abseil only needs C++14 (and RE2 follows suit), I’ve set our MiniPortile recipes to only target that standard and it seems to fix the macOS build without dropping support for older versions.

@mudge mudge closed this Sep 24, 2023
@mudge mudge reopened this Sep 24, 2023
@stanhu
Copy link
Collaborator

stanhu commented Sep 24, 2023

Did this branch drop 0b57520?

@mudge mudge force-pushed the upgrade-re2-to-2023-09-01 branch from 1147c0b to 0c23084 Compare September 24, 2023 07:18
@mudge
Copy link
Owner Author

mudge commented Sep 24, 2023

Yes, I've restored it now (I was trying to see what was and wasn't required with patch level 1).

@mudge
Copy link
Owner Author

mudge commented Sep 24, 2023

The build is now green and (aside from the necessary workaround for abseil/abseil-cpp#1510) I'm happier with the diff especially as we're not dropping support for any existing users.

@mudge
Copy link
Owner Author

mudge commented Sep 24, 2023

If you're happy, I'd be tempted to merge this but not include it in a release until RE2 2023-10-01 is out (assuming it has a monthly release cadence now).

@mudge
Copy link
Owner Author

mudge commented Sep 24, 2023

I've raised #111 to partially automate this sort of thing in future: it's set to run on the first of the month and raise a PR with an updated dependencies.yml (if there are any releases). I'm tempted to merge that, trigger it manually and then cherry pick these commits onto the PR that is automatically raised.

So we can stay on top of updates to both RE2 and Abseil now they are
vendored with the gem, run a monthly job to check for any new releases
and update `dependencies.yml` accordingly, raising a PR if there are
any.

Closes #107
@stanhu
Copy link
Collaborator

stanhu commented Sep 24, 2023

If you're happy, I'd be tempted to merge this but not include it in a release until RE2 2023-10-01 is out (assuming it has a monthly release cadence now).

Sounds good!

#112 didn't run CI. Does the user need to be approved?

@mudge
Copy link
Owner Author

mudge commented Sep 24, 2023

I think it’s due to https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#triggering-further-workflow-runs I’ll try one of the workarounds and try triggering it again to make sure it runs CI too.

mudge and others added 4 commits September 24, 2023 07:59
Due to a bug in pkgconf v1.9.3
(pkgconf/pkgconf#268) that has since been
fixed in pkgconf v2.0, we need to maintain the correct order for
linking abseil-cpp libraries. abseil 20230802 added a few new
libraries and re-arranged the link order.
For compatibility with macOS < 10.14, only try to compile Abseil with
C++14 rather than C++17 (which would require macOS 14 or later).
Previously the build would fail with this error message:

```
[ 37%] Building CXX object absl/synchronization/CMakeFiles/synchronization.dir/internal/create_thread_identity.cc.obj
In file included from /tmp/d20230909-93-l6kcab/tmp/x86_64-w64-mingw32/ports/abseil/20230802.0/abseil-cpp-20230802.0/absl/synchronization/internal/create_thread_identity.cc:21:
/tmp/d20230909-93-l6kcab/tmp/x86_64-w64-mingw32/ports/abseil/20230802.0/abseil-cpp-20230802.0/absl/synchronization/internal/waiter.h:44:2: error: #error ABSL_WAITER_MODE is undefined
   44 | #error ABSL_WAITER_MODE is undefined
      |  ^~~~~
/tmp/d20230909-93-l6kcab/tmp/x86_64-w64-mingw32/ports/abseil/20230802.0/abseil-cpp-20230802.0/absl/synchronization/internal/waiter.h:51:5: warning: "ABSL_WAITER_MODE" is not defined, evaluates to 0 [-Wundef]
   51 | #if ABSL_WAITER_MODE == ABSL_WAITER_MODE_FUTEX
      |     ^~~~~~~~~~~~~~~~
In file included from /tmp/d20230909-93-l6kcab/tmp/x86_64-w64-mingw32/ports/abseil/20230802.0/abseil-cpp-20230802.0/absl/synchronization/internal/create_thread_identity.cc:21:
/tmp/d20230909-93-l6kcab/tmp/x86_64-w64-mingw32/ports/abseil/20230802.0/abseil-cpp-20230802.0/absl/synchronization/internal/waiter.h:52:16: error: 'FutexWaiter' does not name a type
   52 | using Waiter = FutexWaiter;
      |                ^~~~~~~~~~~
make[2]: *** [absl/synchronization/CMakeFiles/synchronization.dir/build.make:92: absl/synchronization/CMakeFiles/synchronization.dir/internal/create_thread_identity.cc.obj] Error 1
```

As mentioned in
abseil/abseil-cpp#1510 (comment),
work around the issue by explicitly defining
`-DABSL_FORCE_WAITER_MODE=4` (4 = `ABSL_WAITER_MODE_STDCPP`).
@mudge
Copy link
Owner Author

mudge commented Sep 24, 2023

Closing in favour of #113 as that PR was raised automatically.

@mudge mudge closed this Sep 24, 2023
@mudge mudge deleted the upgrade-re2-to-2023-09-01 branch September 24, 2023 18:33
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