Skip to content

Add an opt-in DYLINT_HOME for storing drivers - #2180

Open
dblock wants to merge 1 commit into
trailofbits:masterfrom
dblock:unified-cache-defaults
Open

dblock wants to merge 1 commit into
trailofbits:masterfrom
dblock:unified-cache-defaults

Conversation

@dblock

@dblock dblock commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Narrowed per review discussion: this PR only introduces an opt-in DYLINT_HOME for drivers. Defaults are unchanged; switching the default to ~/.dylint is left for a future breaking release.

Changes

  • Add DYLINT_HOME, an absolute path. When set, Dylint stores rustc drivers in $DYLINT_HOME/drivers/<toolchain>/. Empty or relative values are rejected.
  • When DYLINT_HOME is unset, drivers remain in ~/.dylint_drivers/<toolchain>/ as before.
  • DYLINT_DRIVER_PATH is unchanged and still takes precedence over DYLINT_HOME for drivers.
  • Leave DYLINT_LIBRARIES_DIR unset by default; the README and CLI help suggest ~/.dylint/libraries as a location for it.
  • Update CLI help, the three synchronized READMEs, and the changelog.

Validation

On macOS (Apple Silicon):

  • Unit tests for driver-directory resolution: ~/.dylint_drivers without DYLINT_HOME, $DYLINT_HOME/drivers with it, and empty or relative DYLINT_HOME rejected.
  • Integration tests: dylint_driver_path (still works and takes precedence over DYLINT_HOME) and dylint_home (drivers built under a not-yet-existing DYLINT_HOME containing a space, with README.txt, and runnable directly).
  • Clippy (-D warnings) on dylint, cargo-dylint, and dylint_internal; the workspace self-lint (ci::lint); fmt, usage, README synchronization, and Markdown checks.

Linux and Windows are left to CI.

AI disclosure: This PR was authored by an AI assistant (Claude) on behalf of @dblock.

🤖 Generated with Claude Code

https://claude.ai/code/session_011Gr21iB7eqGFMpDHcr3JJE

@dblock
dblock requested a review from smoelius as a code owner November 13, 2026 19:23
@dblock
dblock force-pushed the unified-cache-defaults branch 7 times, most recently from beecbef to e8681cb Compare November 13, 2026 22:20
@dblock dblock mentioned this pull request Nov 13, 2026
@dblock
dblock force-pushed the unified-cache-defaults branch 3 times, most recently from 4be0392 to 049e86e Compare November 17, 2026 03:51
@smoelius

Copy link
Copy Markdown
Collaborator

#2179 is merged. (Thanks, BTW. 🙏) When you get a chance, could you please update this PR?

@dblock
dblock force-pushed the unified-cache-defaults branch from 049e86e to 391feaf Compare November 19, 2026 15:14
@dblock

dblock commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

Updated.

@smoelius

Copy link
Copy Markdown
Collaborator

I like the DYLINT_HOME idea.

But could you please make changing the libraries directory layout its own PR?

Also, I don't think we discussed changing the drivers directory layout. Why is that needed?

@dblock

dblock commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

Thanks! How about narrowing this PR to DYLINT_HOME and relocating caches beneath it, while preserving the existing per-toolchain layouts and explicit directory overrides? I’d move the library layout changes into a separate PR.

The driver layout change was meant to avoid different Dylint versions or development checkouts replacing each other’s cached drivers. It isn’t required for DYLINT_HOME, so I propose dropping it from this PR and discussing it separately if useful.

Would that scope work for you?

AI assistant on behalf of @dblock.

@smoelius

Copy link
Copy Markdown
Collaborator

Thanks! How about narrowing this PR to DYLINT_HOME and relocating caches beneath it, while preserving the existing per-toolchain layouts and explicit directory overrides? I’d move the library layout changes into a separate PR.

The driver layout change was meant to avoid different Dylint versions or development checkouts replacing each other’s cached drivers. It isn’t required for DYLINT_HOME, so I propose dropping it from this PR and discussing it separately if useful.

Would that scope work for you?

Yes to all.

In a previous discussion, I think you proposed (or I assumed) we would use:

~/.dylint/drivers   # Would hold what ~/.dylint_drivers currently holds
~/.dylint/libraries # Would be the obvious place to point `DYLINT_LIBRARIES_DIR`

I like that organization.

I don't see an obvious reason to have an additional cache subdirectory, especially since we will use DYLINT_HOME. But you are welcome to argue otherwise.

Deprecating but continuing to honor DYLINT_DRIVER_PATH sounds good.

Let's please continue to leave DYLINT_LIBRARIES_DIR unset by default.

Thank you very much for working on this.

@dblock

dblock commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

I don't see an obvious reason to have an additional cache subdirectory, especially since we will use DYLINT_HOME. But you are welcome to argue otherwise.

Let's decide this first. I prefer cache because it cleanly separates configuration from a path that can be deleted at any time. It's not clear otherwise to users.

Now that I think of it, maybe the cache should live in /tmp by default and be cleaned up as it takes a lot of disk space. Then we don't need DYLINT_HOME and only DYLINT_CACHE_DIR at the moment as implemented here?

@smoelius

Copy link
Copy Markdown
Collaborator

Let's decide this first. I prefer cache because it cleanly separates configuration from a path that can be deleted at any time. It's not clear otherwise to users.

Now that I think of it, maybe the cache should live in /tmp by default and be cleaned up as it takes a lot of disk space. Then we don't need DYLINT_HOME and only DYLINT_CACHE_DIR at the moment as implemented here?

I think I'm not following. ~/.dylint_drivers is (or ~/.dylint/drivers would be) meant to last for long periods of time, e.g., years. I imagine using ~/.dylint/libraries similarly.

For myself, I wouldn't want those in /tmp.

But maybe you're thinking about this differently?

@dblock

dblock commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

For me these are caches that don't have to survive a reboot because they tend to accumulate large and I do not do dylint development work that often. I suppose there's an even better location for that case, the OS's standard cache location: ~/.cache/dylint on Linux (XDG) and ~/Library/Caches/dylint on macOS for example. Those are made for exactly this: long-lived, safe to delete, and understood by cleanup and backup tools.

I am good with introducing DYLINT_HOME=~/.dylint and then ~/.dylint/drivers and ~/.dylint/libraries without cache. I'll update this PR to do that only and move everything else out.

@dblock
dblock force-pushed the unified-cache-defaults branch from 391feaf to b5d1515 Compare November 20, 2026 19:53
@dblock dblock changed the title Use a unified home cache with automatic legacy migration Add DYLINT_HOME and store drivers in $DYLINT_HOME/drivers Nov 20, 2026
@dblock

dblock commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

@smoelius Updated. Now the next step could be:

  1. Deprecate DYLINT_LIBRARIES_DIR and default it to ~/.dylint/libraries.
  2. Partition shared builds as <directory>/<toolchain>/<package>-<identity-hash>.
  3. Do nothing, I opened some CI improvement PRs.

@smoelius smoelius left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'd like to give this another pass, but please squash your changes into one commit in case everything looks good-to-go.

Thanks again for working on this.

Comment thread dylint/src/driver_builder/mod.rs Outdated
Comment on lines +82 to +83
let dylint_home = dylint_home()?;
let dylint_drivers = dylint_home.join("drivers");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's please have it that if DYLINT_HOME is unset, ~/.dylint_drivers is still created by default.

I would like to treat the ~/.dylint-as-default switch as a breaking change.

Comment thread dylint/src/driver_builder/mod.rs Outdated
Comment on lines +281 to +282
dylint_home_from(None).unwrap(),
home_dir().unwrap().join(".dylint")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nit. In the tests you added, please swap the order of the assert_eq! arguments so that they have expected-actual ordering.

@dblock
dblock force-pushed the unified-cache-defaults branch from b5d1515 to 3882628 Compare November 21, 2026 20:04
@dblock dblock changed the title Add DYLINT_HOME and store drivers in $DYLINT_HOME/drivers Add an opt-in DYLINT_HOME for storing drivers Nov 21, 2026
Introduce `DYLINT_HOME`, an absolute path that, when set, stores rustc
drivers in `$DYLINT_HOME/drivers/<toolchain>/`. When it is unset, drivers
remain in `~/.dylint_drivers`, so the default is unchanged.
`DYLINT_DRIVER_PATH` still takes precedence for drivers.
`DYLINT_LIBRARIES_DIR` remains unset by default; documentation suggests
`~/.dylint/libraries` as a location for it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011Gr21iB7eqGFMpDHcr3JJE
@dblock
dblock force-pushed the unified-cache-defaults branch from 3882628 to 8b36755 Compare November 21, 2026 20:11
@dblock

dblock commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

Thanks! Done: DYLINT_HOME is now purely opt-in. Without it, drivers stay in ~/.dylint_drivers, and DYLINT_DRIVER_PATH is unchanged and still takes precedence. The test assertions are expected-first, and it's still a single commit. Making ~/.dylint the default, and deciding what happens to DYLINT_DRIVER_PATH, can come later in a breaking release.

AI assistant on behalf of @dblock.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants