From 7bb2b060f83cf2b63da519dab59fd0b160beae34 Mon Sep 17 00:00:00 2001 From: Paul Mucur Date: Sun, 24 Sep 2023 13:19:54 +0100 Subject: [PATCH 1/5] Add workflow to upgrade vendored dependencies 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 https://github.com/mudge/re2/issues/107 --- .github/workflows/dependencies.yml | 26 ++++++++++++++++++++++ dependencies.yml | 10 ++++----- scripts/update-dependencies | 35 ++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/dependencies.yml create mode 100755 scripts/update-dependencies diff --git a/.github/workflows/dependencies.yml b/.github/workflows/dependencies.yml new file mode 100644 index 00000000..76cd8f1f --- /dev/null +++ b/.github/workflows/dependencies.yml @@ -0,0 +1,26 @@ +name: Upgrade vendored dependencies + +on: + workflow_dispatch: + schedule: + - cron: '15 3 1 * *' + +jobs: + upgrade: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: "3.2" + - name: Upgrade all vendored dependencies to their latest versions + run: ./scripts/update-dependencies + - uses: peter-evans/create-pull-request@v5 + with: + branch: 'upgrade-vendored-dependencies' + title: 'Upgrade vendored dependencies' + commit-message: 'Upgrade vendored dependencies to latest versions' + labels: dependencies + body: | + - Upgrade RE2 + - Upgrade Abseil diff --git a/dependencies.yml b/dependencies.yml index e813866c..667e22b2 100644 --- a/dependencies.yml +++ b/dependencies.yml @@ -1,9 +1,7 @@ +--- libre2: - version: "2023-09-01" - sha256: "5bb6875ae1cd1e9fedde98018c346db7260655f86fdb8837e3075103acd3649b" - # sha-256 hash provided in https://github.com/google/re2/releases/download/2023-09-01/re2-2023-09-01.tar.gz - + version: '2023-09-01' + sha256: 5bb6875ae1cd1e9fedde98018c346db7260655f86fdb8837e3075103acd3649b abseil: - version: "20230125.3" + version: '20230125.3' sha256: 5366d7e7fa7ba0d915014d387b66d0d002c03236448e1ba9ef98122c13b35c36 - # sha-256 hash provided in https://github.com/abseil/abseil-cpp/archive/refs/tags/20230125.3.tar.gz diff --git a/scripts/update-dependencies b/scripts/update-dependencies new file mode 100755 index 00000000..9ba628ff --- /dev/null +++ b/scripts/update-dependencies @@ -0,0 +1,35 @@ +#!/usr/bin/env ruby + +require "net/http" +require "digest/sha2" +require "yaml" + +re2_response = Net::HTTP.get_response(URI("https://github.com/google/re2/releases/latest")) +exit 1 unless re2_response.is_a?(Net::HTTPRedirection) + +re2_release = File.basename(URI(re2_response["Location"]).path) +re2_redirect = Net::HTTP.get_response(URI("https://github.com/google/re2/releases/download/#{re2_release}/re2-#{re2_release}.tar.gz")) +exit 1 unless re2_redirect.is_a?(Net::HTTPRedirection) + +re2_archive = Net::HTTP.get_response(URI(re2_redirect["Location"])) +exit 1 unless re2_archive.is_a?(Net::HTTPSuccess) +re2_sha256sum = Digest::SHA2.hexdigest(re2_archive.body) + +abseil_response = Net::HTTP.get_response(URI("https://github.com/abseil/abseil-cpp/releases/latest")) +exit 1 unless abseil_response.is_a?(Net::HTTPRedirection) + +abseil_tag = File.basename(URI(abseil_response["Location"]).path) +abseil_redirect = Net::HTTP.get_response(URI("https://github.com/abseil/abseil-cpp/archive/refs/tags/#{abseil_tag}.tar.gz")) +exit 1 unless abseil_redirect.is_a?(Net::HTTPRedirection) + +abseil_archive = Net::HTTP.get_response(URI(abseil_redirect["Location"])) +exit 1 unless abseil_archive.is_a?(Net::HTTPSuccess) +abseil_sha256sum = Digest::SHA2.hexdigest(abseil_archive.body) + +File.write( + File.expand_path("../dependencies.yml", __dir__), + { + "libre2" => { "version" => re2_release, "sha256" => re2_sha256sum }, + "abseil" => { "version" => abseil_tag, "sha256" => abseil_sha256sum } + }.to_yaml +) From f3180e2d0ee4bcdb5e5d2b3ce771427beea3813d Mon Sep 17 00:00:00 2001 From: Paul Mucur Date: Sat, 9 Sep 2023 12:31:10 +0100 Subject: [PATCH 2/5] Upgrade Abseil to 20230802.1 --- dependencies.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dependencies.yml b/dependencies.yml index 667e22b2..42c8aea9 100644 --- a/dependencies.yml +++ b/dependencies.yml @@ -3,5 +3,5 @@ libre2: version: '2023-09-01' sha256: 5bb6875ae1cd1e9fedde98018c346db7260655f86fdb8837e3075103acd3649b abseil: - version: '20230125.3' - sha256: 5366d7e7fa7ba0d915014d387b66d0d002c03236448e1ba9ef98122c13b35c36 + version: "20230802.1" + sha256: "987ce98f02eefbaf930d6e38ab16aa05737234d7afbab2d5c4ea7adbe50c28ed" From a227b5fc096905293608070083cf93908d4f3c20 Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Sat, 9 Sep 2023 23:23:57 -0700 Subject: [PATCH 3/5] Update abseil library list for Windows Due to a bug in pkgconf v1.9.3 (https://github.com/pkgconf/pkgconf/issues/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. --- ext/re2/extconf.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ext/re2/extconf.rb b/ext/re2/extconf.rb index f8fd706d..7049d17f 100644 --- a/ext/re2/extconf.rb +++ b/ext/re2/extconf.rb @@ -296,17 +296,18 @@ def build_with_system_libraries -labsl_crc32c -labsl_crc_internal -labsl_crc_cpu_detect + -labsl_raw_hash_set -labsl_hash -labsl_city -labsl_bad_variant_access -labsl_low_level_hash - -labsl_raw_hash_set -labsl_hashtablez_sampler -labsl_exponential_biased -labsl_bad_optional_access -labsl_str_format_internal -labsl_synchronization -labsl_graphcycles_internal + -labsl_kernel_timeout_internal -labsl_stacktrace -labsl_symbolize -ldbghelp @@ -316,9 +317,10 @@ def build_with_system_libraries -labsl_time -labsl_civil_time -labsl_strings + -labsl_string_view -labsl_strings_internal - -ladvapi32 -labsl_base + -ladvapi32 -labsl_spinlock_wait -labsl_int128 -labsl_throw_delegate From 6de8bcaf24463a763dfa0001df1ddd763c572a1c Mon Sep 17 00:00:00 2001 From: Paul Mucur Date: Sun, 24 Sep 2023 07:41:24 +0100 Subject: [PATCH 4/5] Compile against C++14, not C++17 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). --- ext/re2/recipes.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/re2/recipes.rb b/ext/re2/recipes.rb index f2702e2e..2ee2698f 100644 --- a/ext/re2/recipes.rb +++ b/ext/re2/recipes.rb @@ -10,7 +10,7 @@ def build_recipe(name, version) recipe.target = File.join(PACKAGE_ROOT_DIR, 'ports') recipe.configure_options += [ # abseil needs a C++14 compiler - '-DCMAKE_CXX_STANDARD=17', + '-DCMAKE_CXX_STANDARD=14', # needed for building the C extension shared library with -fPIC '-DCMAKE_POSITION_INDEPENDENT_CODE=ON', # ensures pkg-config and installed libraries will be in lib, not lib64 From 5f742e57d9bdabf6d281dc76ca47b0bbd33d24f1 Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Sat, 9 Sep 2023 22:17:38 -0700 Subject: [PATCH 5/5] Work around x64-mingw-ucrt build failures in abseil-cpp 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 https://github.com/abseil/abseil-cpp/issues/1510#issuecomment-1694254348, work around the issue by explicitly defining `-DABSL_FORCE_WAITER_MODE=4` (4 = `ABSL_WAITER_MODE_STDCPP`). --- ext/re2/extconf.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ext/re2/extconf.rb b/ext/re2/extconf.rb index 7049d17f..fd917e69 100644 --- a/ext/re2/extconf.rb +++ b/ext/re2/extconf.rb @@ -398,6 +398,8 @@ def build_with_vendored_libraries process_recipe(abseil_recipe) do |recipe| recipe.configure_options += ['-DABSL_PROPAGATE_CXX_STD=ON', '-DCMAKE_CXX_VISIBILITY_PRESET=hidden'] + # Workaround for https://github.com/abseil/abseil-cpp/issues/1510 + recipe.configure_options += ['-DCMAKE_CXX_FLAGS=-DABSL_FORCE_WAITER_MODE=4'] if windows? end process_recipe(re2_recipe) do |recipe|