Open Bug 1674726 Opened 4 years ago Updated 1 year ago

Clippy linter should set MOZ_TOPOBJDIR

Categories

(Developer Infrastructure :: Lint and Formatting, defect, P3)

Tracking

(Not tracked)

ASSIGNED

People

(Reporter: janerik, Assigned: Sylvestre)

References

(Blocks 1 open bug)

Details

Attachments

(1 obsolete file)

For FOG we're relying on some buildtime-generated code, which is placed into a directory under MOZ_TOPOBJDIR and then included from Rust code like this:

include!(concat!(
    env!("MOZ_TOPOBJDIR"),
    "/toolkit/components/glean/api/src/pings.rs"
));

This breaks clippy linting as MOZ_TOPOBJDIR isn't set, the include fails and thus the build fails.
For now we can work around that by using:

#[cfg(not(feature = "cargo-clippy"))]

and manually write a subset of what would normally be auto-generated.
It would be nice if the clippy task sets MOZ_TOPOBJDIR correctly.
Now I'm not sure how these tasks run on CI and whether the build happens before that such that the files are even generated.
If not then of course this wouldn't help and we still need the workaround to get clippy to work correctly on try.

Type: task → defect
Summary: Clippy linter doesn't set MOZ_TOPOBJDIR → Clippy linter should set MOZ_TOPOBJDIR
See Also: → 1674728

Hm.... maybe?
Doesn't look like any of the linters uses any MOZ_* environment variable, so I wonder if clippy really should.

And the question still stands if clippy actually depends on a build, because without those there won't be any files in MOZ_TOPOBJDIR anyway and we still need the workaround.

We have linters taking different paths for the CI. For example:
https://searchfox.org/mozilla-central/source/tools/lint/clang-format/__init__.py#140-144
https://searchfox.org/mozilla-central/source/tools/lint/android/lints.py#29-31
etc

We could require some pre-analysis step (ex: "mach build foo/") in clippy if needed.

The severity field is not set for this bug.
:ahal, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(ahal)
Severity: -- → S2
Flags: needinfo?(ahal)
Priority: -- → P3

Might not fully work as it expects also
obj-x86_64-pc-linux-gnu/dist/xpcrs/bt/all.rs or
obj-x86_64-pc-linux-gnu/dist/xpcrs/bt/nsIEarlyHintObserver.rs

Assignee: nobody → sledru
Status: NEW → ASSIGNED

Setting this variable fixes some issues but not all of them.
clippy expects some generated files in the obj directories. They will need to be generated before doing anything else.

Blocks: clippy
Product: Firefox Build System → Developer Infrastructure
Attachment #9256786 - Attachment is obsolete: true
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: