Closed Bug 1794001 Opened 3 years ago Closed 3 years ago

Use `rure` instead of the `regex-ffi`

Categories

(Core :: XPCOM, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
107 Branch
Tracking Status
firefox107 --- fixed

People

(Reporter: nika, Assigned: nika)

References

Details

Attachments

(6 files)

While we already have an in-tree regex-ffi crate which provides basic access to the rust regex crate for use in FormAutofillNative, the regex crate itself provides and maintains its own c api as the rure crate in-tree (https://github.com/rust-lang/regex/tree/0d0023e412f7ead27b0809f5d2f95690d0f0eaef/regex-capi).

We should consider vendoring in rure to allow us to use the more-fully-featured official ffi, and migrate existing uses of regex-ffi to use it instead.

While we already have an in-tree regex-ffi crate which provides basic
access to regex functionality for use in FormAutofillNative, the regex
crate itself provides and maintains its own c api as the rure crate.
This patch vendors in rure to allow us to use the more-fully-featured
official ffi.

Depends on D158872

This makes the API more ergonomic to use from our c++ code, managing things
like lifecycles automatically.

Documentation comments are copied from the rure.h header, and modified
slightly to reflect the C++ types.

Depends on D158873

The RustRegex wrapper is built on the official rure ffi bindings for the
regex crate, which was added in previous parts. The regex-ffi crate will be
removed in the next part.

Depends on D158874

It is no longer necessary now that rure bindings are in use.

Depends on D158875

This will make customizing flags on the regex type less error-prone, as passing
a flag (e.g. RustRegex::FLAG_CASEI) will not implicitly disable the default
UNICODE flag.

Names and comments were taken from the original RegexBuilder type in the
regex crate which this type is inspired by, and the type was changed to be
cheaply copyable and support method chaining, so that it can be used more
ergonomically.

Depends on D158874

Attachment #9297645 - Attachment description: Bug 1794001 - Part 3: Use RustRegex in FormAutofillNative instead of our regex-ffi crate, r=dimi! → Bug 1794001 - Part 4: Use RustRegex in FormAutofillNative instead of our regex-ffi crate, r=dimi!
Attachment #9297646 - Attachment description: Bug 1794001 - Part 4: remove the regex-ffi crate, r=#xpcom-reviewers! → Bug 1794001 - Part 5: remove the regex-ffi crate, r=#xpcom-reviewers!
Pushed by nlayzell@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/80b01e63ca54 Part 1: Import the `rure` crate for rust regex ffi, r=xpcom-reviewers,supply-chain-reviewers,kmag https://hg.mozilla.org/integration/autoland/rev/d1030c02b560 Part 2: Add a c++ wrapper for the rust regex (rure) API, r=xpcom-reviewers,kmag https://hg.mozilla.org/integration/autoland/rev/27715593ce6f Part 3: Combine RustRegex::Flags and RustRegexOptions, r=xpcom-reviewers,kmag https://hg.mozilla.org/integration/autoland/rev/ea8ba9ce54c8 Part 4: Use RustRegex in FormAutofillNative instead of our regex-ffi crate, r=dimi https://hg.mozilla.org/integration/autoland/rev/e286fb05d64f Part 5: remove the regex-ffi crate, r=xpcom-reviewers,kmag

Backed out for causing build bustages on RustRegex.h

Log tier 2: https://treeherder.mozilla.org/logviewer?job_id=392996025&repo=autoland

Flags: needinfo?(nika)
Pushed by nlayzell@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/148d136ce549 Part 1: Import the `rure` crate for rust regex ffi, r=xpcom-reviewers,supply-chain-reviewers,kmag https://hg.mozilla.org/integration/autoland/rev/d4f9b4a3029a Part 2: Add a c++ wrapper for the rust regex (rure) API, r=xpcom-reviewers,kmag https://hg.mozilla.org/integration/autoland/rev/dd03b0396eb9 Part 3: Combine RustRegex::Flags and RustRegexOptions, r=xpcom-reviewers,kmag https://hg.mozilla.org/integration/autoland/rev/3cfe4087793d Part 4: Use RustRegex in FormAutofillNative instead of our regex-ffi crate, r=dimi https://hg.mozilla.org/integration/autoland/rev/b8dbabe61a9a Part 5: remove the regex-ffi crate, r=xpcom-reviewers,kmag

Backed out for causing build bustages

  • Backout link
  • Push with failures
  • Failure Log
  • Failure line: clang-14: error: linker command failed with exit code 1 (use -v to see invocation)
    gmake[4]: *** [/builds/worker/checkouts/gecko/config/makefiles/rust.mk:433: force-cargo-library-build] Error 101

And xpcshell failures: https://treeherder.mozilla.org/logviewer?job_id=393044321&repo=autoland

Cargo will attempt to build all targets for dependencies, and there
appears to be no option to turn that functionality off (see
https://github.com/rust-lang/cargo/issues/11232). If we try to build the
rure crate as a cdylib during a PGO build, it causes linker issues,
which make the build fail. As this artifact isn't necessary for our
build, we can patch the crate to remove the cdylib and staticlib
crate-type definitions, making the build pass as only the artifact we
need is built.

Depends on D158876

Pushed by nlayzell@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/54ecd33212a9 Part 1: Import the `rure` crate for rust regex ffi, r=xpcom-reviewers,supply-chain-reviewers,kmag https://hg.mozilla.org/integration/autoland/rev/2533ff4898b3 Part 2: Add a c++ wrapper for the rust regex (rure) API, r=xpcom-reviewers,kmag https://hg.mozilla.org/integration/autoland/rev/0e4aa3c8da14 Part 3: Combine RustRegex::Flags and RustRegexOptions, r=xpcom-reviewers,kmag https://hg.mozilla.org/integration/autoland/rev/69586ab16a36 Part 4: Use RustRegex in FormAutofillNative instead of our regex-ffi crate, r=dimi https://hg.mozilla.org/integration/autoland/rev/24e8f8b9b759 Part 5: remove the regex-ffi crate, r=xpcom-reviewers,kmag
Pushed by smolnar@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/59a66b8852f5 Part 6: Patch rure to remove cdylib and staticlib targets, r=#xpcom-reviewers CLOSED TREE
Flags: needinfo?(nika)
See Also: → 1796059
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: