-
Notifications
You must be signed in to change notification settings - Fork 19
feat: replace C++ FFI with native Rust parser #119
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
Open
countradooku
wants to merge
5
commits into
ada-url:main
Choose a base branch
from
countradooku:feat/native-rust-port
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
40937ed
feat: replace C++ FFI with native Rust parser
countradooku 6269893
perf: eliminate native parser regressions
countradooku 7f829ba
perf: streamline simple URL validation
countradooku 36378c3
feat: eliminate native parser dependencies
countradooku 98372a5
Merge branch 'main' into feat/native-rust-port
countradooku File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,9 @@ on: | |
| paths-ignore: | ||
| - '**/*.md' | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: ${{ github.ref_name != 'main' }} | ||
|
|
@@ -42,7 +45,7 @@ jobs: | |
| sudo dpkg --install wasi-sdk-33.0-x86_64-linux.deb | ||
| curl -LO https://github.com/bytecodealliance/wasmtime/releases/download/v46.0.1/wasmtime-v46.0.1-x86_64-linux.tar.xz | ||
| tar xvf wasmtime-v46.0.1-x86_64-linux.tar.xz | ||
| echo `pwd`/wasmtime-v46.0.1-x86_64-linux >> $GITHUB_PATH | ||
| echo "$PWD/wasmtime-v46.0.1-x86_64-linux" >> "$GITHUB_PATH" | ||
|
|
||
| - uses: Swatinem/rust-cache@v2 | ||
| with: | ||
|
|
@@ -55,68 +58,40 @@ jobs: | |
| uses: taiki-e/install-action@cargo-hack | ||
|
|
||
| - name: Clippy | ||
| run: cargo hack clippy --feature-powerset -- -D warnings | ||
| run: cargo hack clippy --feature-powerset --locked -- -D warnings | ||
|
|
||
| - name: Test | ||
| # `bundled` must stay enabled for every combination: it is what compiles | ||
| # and statically links the C++ ada sources. Without it (and with no | ||
| # external ada provided via ADA_LIB_DIR/ADA_LIB_NAME) the test binaries | ||
| # fail to link with `undefined symbol: ada_*`. `--features bundled` forces | ||
| # it into each powerset entry while still exercising the other features. | ||
| run: cargo hack test --feature-powerset --features bundled | ||
| run: cargo hack test --feature-powerset --locked | ||
|
|
||
| - name: Check Documentation | ||
| env: | ||
| RUSTDOCFLAGS: '-D warnings' | ||
| run: cargo hack doc --feature-powerset | ||
| run: cargo hack doc --feature-powerset --locked | ||
|
|
||
| external-ada: | ||
| name: External ada (non-bundled) | ||
| feature-modes: | ||
| name: no_std and optional features | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v7 | ||
|
|
||
| - uses: Swatinem/rust-cache@v2 | ||
| with: | ||
| shared-key: external-ada | ||
| shared-key: feature-modes | ||
| save-if: ${{ github.ref_name == 'main' }} | ||
|
|
||
| - run: rustup show | ||
|
|
||
| # Exercise the non-bundled linking path: instead of compiling the bundled | ||
| # C++ sources, build ada once as a standalone shared library and link the | ||
| # crate against it via ADA_LIB_DIR / ADA_LIB_NAME. This mirrors how a host | ||
| # build system (Bazel, CMake, a distro package) would provide ada. The | ||
| # shared library records its own libstdc++ dependency (DT_NEEDED), so the | ||
| # final Rust binary needs no extra C++ runtime link flags. | ||
| - name: Build standalone libada.so | ||
| run: | | ||
| c++ -std=c++20 -O2 -DADA_INCLUDE_URL_PATTERN=0 -Ideps -fPIC -shared \ | ||
| deps/ada.cpp -o "$RUNNER_TEMP/libada.so" | ||
|
|
||
| # `bundled` is intentionally disabled (default-features off). `std` is | ||
| # re-enabled because dropping default features also drops it. The serde | ||
| # combination is run separately to cover the extra feature on this path. | ||
| - name: Test against external ada | ||
| env: | ||
| ADA_LIB_DIR: ${{ runner.temp }} | ||
| ADA_LIB_NAME: ada | ||
| LD_LIBRARY_PATH: ${{ runner.temp }} | ||
| - name: Test dependency-free core and Serde integration | ||
| run: | | ||
| cargo test --no-default-features --features std | ||
| cargo test --no-default-features --features serde | ||
| cargo test --no-default-features --locked | ||
| cargo test --no-default-features --features serde --locked | ||
|
|
||
| sanitizers: | ||
| name: AddressSanitizer + LeakSanitizer | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v7 | ||
|
|
||
| # AddressSanitizer (which bundles LeakSanitizer) requires nightly. We use | ||
| # clang for the bundled C++ so it shares the LLVM sanitizer runtime that | ||
| # rustc links into the test binaries. Note: `cargo +nightly` is used | ||
| # explicitly because rust-toolchain.toml pins a stable channel that would | ||
| # otherwise override the default toolchain in this directory. | ||
| - name: Install nightly toolchain | ||
| run: rustup toolchain install nightly --profile minimal | ||
|
|
||
|
|
@@ -127,15 +102,8 @@ jobs: | |
|
|
||
| - run: rustup +nightly show | ||
|
|
||
| # `--target` is required so build scripts / proc-macros (host) are not | ||
| # instrumented. LeakSanitizer is enabled by default under ASan on Linux; | ||
| # this catches regressions like https://github.com/ada-url/rust/issues/101 | ||
| # where the failed-parse path leaked the allocation from `ada_parse`. | ||
| - name: Test under AddressSanitizer + LeakSanitizer | ||
| env: | ||
| CC: clang | ||
| CXX: clang++ | ||
| ADA_SANITIZE: address | ||
| RUSTFLAGS: '-Zsanitizer=address' | ||
| ASAN_OPTIONS: 'detect_leaks=1' | ||
| run: cargo +nightly test --tests --target x86_64-unknown-linux-gnu | ||
|
|
@@ -163,4 +131,22 @@ jobs: | |
|
|
||
| - run: rustup show | ||
|
|
||
| - run: cargo clippy -- -D warnings | ||
| - run: cargo clippy --all-targets --all-features --locked -- -D warnings | ||
|
|
||
| miri: | ||
| name: Miri | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is Miri? |
||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v7 | ||
|
|
||
| - uses: dtolnay/rust-toolchain@nightly | ||
| with: | ||
| components: miri | ||
|
|
||
| - uses: Swatinem/rust-cache@v2 | ||
|
|
||
| # Miri interprets Rust MIR to catch undefined behavior that normal tests | ||
| # cannot reliably observe. rust-toolchain.toml pins stable, so select | ||
| # nightly explicitly. | ||
| - run: cargo +nightly miri setup | ||
| - run: cargo +nightly miri test --lib --no-default-features | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,9 @@ | ||
| /target | ||
| /target/ | ||
| /fuzz/target/ | ||
| /fuzz/corpus/ | ||
| /fuzz/artifacts/ | ||
| /.idea/ | ||
| /.vscode/ | ||
| *.profraw | ||
| *.profdata | ||
| perf.data* |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we keep the workflows?