Skip to content

fix(doctest): search native libs in build script outputs#13490

Merged
bors merged 3 commits into
rust-lang:masterfrom
weihanglo:rustdoc-shared-libs
Feb 26, 2024
Merged

fix(doctest): search native libs in build script outputs#13490
bors merged 3 commits into
rust-lang:masterfrom
weihanglo:rustdoc-shared-libs

Conversation

@weihanglo

Copy link
Copy Markdown
Member

What does this PR try to resolve?

rustdoc --test not only compiles but executes doctests.
Ideally only execution phase should have search paths appended,
so the executions can find native libs just like other tests.
However, there is no way to separate these two phase, so this
hack is added for both phases.

How should we test and review this PR?

There are some concerns for this fix but is pretty rare.

  • rustdoc --test does two things: compile and run tests. One proc-macro may load wrong shared libs when compiling doctest.
  • Dynamic linkers may load dylibs built for a different platform and fail.

However, for cargo doc proc-macro already has bugs when loading shared libs, so this use case is perhaps unlikely to happen. The Cargo team had a discussion and decided to proceed to a fix before tools are able to separate build/run phases.

Additional information

Fixes #8531.

See #10469 (comment) and this Zulip topic.

Also prior pull requests #12710 and #10469.

This new test demonstrate the current behavior.
HACK: `rustdoc --test` not only compiles but executes doctests.
Ideally only execution phase should have search paths appended,
so the executions can find native libs just like other tests.
However, there is no way to separate these two phase, so this
hack is added for both phases.
@rustbot

rustbot commented Feb 26, 2024

Copy link
Copy Markdown
Collaborator

r? @epage

rustbot has assigned @epage.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-build-execution Area: anything dealing with executing the compiler S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 26, 2024
@weihanglo

Copy link
Copy Markdown
Member Author

@weihanglo

Copy link
Copy Markdown
Member Author

@bors try

@weihanglo weihanglo added the A-doctests Area: rustdoc --test label Feb 26, 2024
@bors

bors commented Feb 26, 2024

Copy link
Copy Markdown
Contributor

⌛ Trying commit 34215b1 with merge b5f5149...

bors added a commit that referenced this pull request Feb 26, 2024
fix(doctest): search native libs in build script outputs
@bors

bors commented Feb 26, 2024

Copy link
Copy Markdown
Contributor

☀️ Try build successful - checks-actions
Build commit: b5f5149 (b5f51498d169a886993bdc8c438b2b9b521f6673)

@epage epage left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

r= me when CI is ready

@weihanglo

Copy link
Copy Markdown
Member Author

Thanks!

bors try shows it passed, so merge.

@bors r=epage

@bors

bors commented Feb 26, 2024

Copy link
Copy Markdown
Contributor

📌 Commit 34215b1 has been approved by epage

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 26, 2024
@bors

bors commented Feb 26, 2024

Copy link
Copy Markdown
Contributor

⌛ Testing commit 34215b1 with merge a7e9347...

@bors

bors commented Feb 26, 2024

Copy link
Copy Markdown
Contributor

☀️ Test successful - checks-actions
Approved by: epage
Pushing a7e9347 to master...

1 similar comment
@bors

bors commented Feb 26, 2024

Copy link
Copy Markdown
Contributor

☀️ Test successful - checks-actions
Approved by: epage
Pushing a7e9347 to master...

@bors bors merged commit a7e9347 into rust-lang:master Feb 26, 2024
@bors

bors commented Feb 26, 2024

Copy link
Copy Markdown
Contributor

👀 Test was successful, but fast-forwarding failed: 422 Changes must be made through a pull request.

bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 28, 2024
Update cargo

16 commits in 194a60b2952bd5d12ba15dd2577a97eed7d3c587..8964c8ccff6e420e2a38b8696d178d69fab84d9d
2024-02-21 01:53:45 +0000 to 2024-02-27 19:22:46 +0000
- feat: Add "-Zpublic-dependency" for public-dependency feature. (rust-lang/cargo#13340)
- Stabilize global cache data tracking. (rust-lang/cargo#13492)
- chore: bump baseline version requirement of sub crates (rust-lang/cargo#13494)
- fix(doctest): search native libs in build script outputs (rust-lang/cargo#13490)
- chore: fixed a typo(two->too) (rust-lang/cargo#13489)
- test: relax help text assertion (rust-lang/cargo#13488)
- refactor: clean up for `GlobalContext` rename (rust-lang/cargo#13486)
- test(cli): Verify terminal styling (rust-lang/cargo#13461)
- fix(cli): Respect CARGO_TERM_COLOR in '--list' and '-Zhelp' (rust-lang/cargo#13479)
- Error messages when collecting workspace members now mention the workspace root location (rust-lang/cargo#13480)
- fix(add): Improve error when adding registry packages while vendored (rust-lang/cargo#13281)
- [docs]:Add missing jump links (rust-lang/cargo#13478)
- Add global_cache_tracker stability tests. (rust-lang/cargo#13467)
- fix(cli): Control clap colors through config (rust-lang/cargo#13463)
- chore: remove the unused function (rust-lang/cargo#13472)
- Fix missing brackets (rust-lang/cargo#13470)
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 28, 2024
Update cargo

16 commits in 194a60b2952bd5d12ba15dd2577a97eed7d3c587..8964c8ccff6e420e2a38b8696d178d69fab84d9d
2024-02-21 01:53:45 +0000 to 2024-02-27 19:22:46 +0000
- feat: Add "-Zpublic-dependency" for public-dependency feature. (rust-lang/cargo#13340)
- Stabilize global cache data tracking. (rust-lang/cargo#13492)
- chore: bump baseline version requirement of sub crates (rust-lang/cargo#13494)
- fix(doctest): search native libs in build script outputs (rust-lang/cargo#13490)
- chore: fixed a typo(two->too) (rust-lang/cargo#13489)
- test: relax help text assertion (rust-lang/cargo#13488)
- refactor: clean up for `GlobalContext` rename (rust-lang/cargo#13486)
- test(cli): Verify terminal styling (rust-lang/cargo#13461)
- fix(cli): Respect CARGO_TERM_COLOR in '--list' and '-Zhelp' (rust-lang/cargo#13479)
- Error messages when collecting workspace members now mention the workspace root location (rust-lang/cargo#13480)
- fix(add): Improve error when adding registry packages while vendored (rust-lang/cargo#13281)
- [docs]:Add missing jump links (rust-lang/cargo#13478)
- Add global_cache_tracker stability tests. (rust-lang/cargo#13467)
- fix(cli): Control clap colors through config (rust-lang/cargo#13463)
- chore: remove the unused function (rust-lang/cargo#13472)
- Fix missing brackets (rust-lang/cargo#13470)
@rustbot rustbot added this to the 1.78.0 milestone Feb 28, 2024
@weihanglo weihanglo deleted the rustdoc-shared-libs branch March 1, 2024 03:37
@weihanglo weihanglo restored the rustdoc-shared-libs branch March 1, 2024 03:37
@weihanglo weihanglo deleted the rustdoc-shared-libs branch March 1, 2024 03:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-build-execution Area: anything dealing with executing the compiler A-doctests Area: rustdoc --test S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cargo test --doc not load same shared libraries as cargo test --lib

4 participants