appender: gate symlink support to platforms that support it#3568
Open
ameyypawar wants to merge 1 commit into
Open
appender: gate symlink support to platforms that support it#3568ameyypawar wants to merge 1 commit into
ameyypawar wants to merge 1 commit into
Conversation
…#3536) `tracing-appender` 0.2.5 added the `latest_symlink` builder option, which depends on the `symlink` crate. That crate only defines `symlink_file` and `remove_symlink_file` on `unix`, `windows`, and `redox`, so the appender no longer compiles on targets such as `wasm32-unknown-unknown`: error[E0425]: cannot find function `remove_symlink_file` in crate `symlink` Gate the `symlink` dependency and the code that uses it to those targets. On platforms without symbolic-link support, `latest_symlink` becomes a no-op (the log file is still written; no symlink is created), and the crate compiles again. Fixes: tokio-rs#3536
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation
tracing-appender0.2.5 added thelatest_symlinkbuilder option (#3447), whichdepends on the
symlinkcrate. That crateonly defines
symlink_fileandremove_symlink_fileonunix,windows, andredox, so on other targets — notablywasm32-unknown-unknown— the appender nolonger compiles:
tracing-appender 0.2.4 built fine on
wasm32; 0.2.5 regressed.Fixes: #3536
Solution
Gate the
symlinkdependency to the platforms that support symbolic links, andgate the code that uses it the same way:
Cargo.toml, movesymlinkinto[target.'cfg(any(unix, windows, target_os = "redox"))'.dependencies].rolling.rs, extract the symlink logic fromcreate_writerinto anupdate_latest_symlinkhelper with twocfg-gated definitions: the real onefor symlink-capable targets, and a no-op for the rest.
test_latest_symlinkis gated the same way.
On platforms without symbolic-link support,
latest_symlinkis now a no-op (thelog file is still written; no symlink is created), and the crate compiles again.
The existing
test-build-wasmCI job buildstracing-appenderforwasm32.