Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

lint

Runs a linter on the sources. Used by the Lint flow, where its outcome is the lint result. A job has one linter.

Depends onfilelist (the sources) and flatten (the list naming them)
Runs inlint/
OutputsThe linter’s logs, and lint/messages.json: the messages parsed from them
Timeouttimeout from the config. None by default
LinterCommandKeyed by the version printed byMessages are read from
verilatorverilator --lint-only -f flatten/filelist.f --Mdir lint/obj_dir [--top-module <top>] [<args>]verilator --versionlint/stderr.log
veriblexargs -a flatten/filelist.f -d '\n' verible-verilog-lint --flagfile=../flatten/verible.flags [<args>]verible-verilog-lint --versionlint/stdout.log, lint/stderr.log
slangslang -f flatten/filelist.f [<args>]slang --versionlint/stderr.log, lint/stdout.log
ascentlintxargs -a ../flatten/ascentlint.flags -d '\n' ascentlint -log ascentlint.log [<args>]ascentlint -version, the line AscentLint ...lint/ascentlint.rpt, lint/ascentlint.log

<args> is the linter’s tools.<linter>.lint.args from the lint config, as given. They come after the options the core’s target gives, except where xargs adds what the flatten step wrote: for Verible they are in front of the files, and for AscentLint in front of -i, the run script and the target’s options.

  • Verilator generates nothing when linting, so lint/obj_dir is not made. --top-module comes after the filelist, so the design file’s top wins over the target’s toplevel. verilator is tools.verilator.command if the config sets it, for the command and for the version.
  • Verible takes the files as arguments and reads no argument file, and the files are only known once the filelist step has run. So xargs reads them from the list. If they don’t fit one command line it runs Verible more than once, each time with the same flags.
  • slang has its top module in the command file, where the flatten step put it.
  • AscentLint runs flatten/ascentlint.tcl, the script Edalize’s backend would write, which sources the waivers, analyzes the files of flatten/filelist.f, elaborates the top and writes lint/ascentlint.rpt. Its options are only known once the filelist step has run, so xargs reads them from flatten/ascentlint.flags, with -i and the script. Each run holds one licence from the ascentlint resource pool. Its version is only the line of ascentlint -version that names the release and build: the rest of what it prints, such as the date and the working directory, changes every run.

Every other option comes from the core’s target, through the flatten step, or from tools.<linter>.lint.args.

The parsed messages

When the linter has run to the end, doris parses its logs once, in-process, into lint/messages.json: the messages, each with its severity, rule, file, line, column and text, and the log to point at. A file is named from the job’s directory, such as filelist/work/src/aes_0/rtl/aes.sv, not as the linter named it from lint/, so the file is the same in every checkout. The step’s verdict is decided from those messages, and the job’s result file is written from them, so the logs are never parsed twice. messages.json is an output of the step, so a step taken from the cache has the messages of the run that was stored.

What passed means

The step’s outcome is decided in this order:

CheckIf it fails
The linter was not killed by a signal, and finished within the timeoutstep error
Its exit code is one a linter that ran to the end givesstep error
Its logs exist, and its messages were parsed into messages.jsonstep error
Verilator only: no message contains Internal Errorstep error
It did not exit non-zero without reporting an error or warningstep error
It reported no error and no warningfailed

What counts as a message, and which exit codes are accepted:

LinterExit codesA message is a lineRule
verilator0, 1Starting %Error or %Warning. The closing %Error: Exiting due to ... line is a count, not a messageWIDTHEXPAND
verible0, 123FILE:LINE:COLUMN: TEXT. With a [rule] at the end it is a warning. Without one it is an error, such as a syntax errorline-length
slangAny[FILE:LINE:COLUMN: ]error: TEXT or warning: TEXT [-Wname]. Notes are not messageswidth-trunc
ascentlint0, 123, 124In ascentlint.rpt: a row of E or W, then RULE:, FILE:LINE and the text, in columns padded with spaces; the columns after the text are left out. FILE is the name only. A violation at several places has a row for each, and each row is a message, so the counts can be more than the report’s summary gives. Infos, I, are not messages, and a text that goes on in the next line is cut there. In ascentlint.log: starting Error: , ERROR, ERR, Warning: or WARN, which belong to no ruleNOT_READ

xargs exits 123 when Verible exited non-zero, which it does for any violation or syntax error. slang’s exit code names the kind of failure and is not the same in every version, so its messages decide: a non-zero exit with no message, such as an option it does not know, is a step error. AscentLint exits 0 when it finds violations, so its messages decide; xargs exits 123 or 124 when AscentLint exited non-zero. A FlexNet licensing error in its log is a step error, not a lint error: it says nothing about the design. If AscentLint stops before it writes ascentlint.rpt, as it may on an error in analysis with -stop_on_error, the missing report is a step error, and ascentlint.log has the errors.

Warnings fail the design. That includes Verilator warnings made non-fatal with -Wno-fatal, slang warnings, for which slang itself exits 0, and AscentLint’s warnings in its log, other than that a licence will expire. Errors that belong to no rule fail it too: a syntax error, or a module that can’t be found, says the design can’t be linted as it is described.

So passed means: the linter read every source the core’s target names and reported nothing. It does not mean:

  • The checks you expect ran. The options come from the core’s target and the lint config’s tools table. A target without -Wall passes Verilator with far fewer checks, and Verible with no rules file checks only its default rules.
  • Nothing was waived. No linter reports what a waiver turns off, so waived messages are neither listed nor counted. A waiver that is too broad hides real findings, and one that no longer matches anything is not reported either. Review the waiver files named in flatten/.
  • The whole design was read. Verilator, slang and AscentLint check only what is instantiated below the top module. A module in the filelist that nothing instantiates is parsed, but not elaborated. Verible reads every source file but no include file.
  • The linters agree. Each has its own checks. A design that passes one can fail another, and vendored code written to another style guide will fail Verible’s style rules until it is waived.

To check by hand

Compare the counts in result.json with the linter’s own:

jq '.errors, .warnings' result.json
tail -n 1 lint/stderr.log                    # Verilator's own count; absent on a clean run
grep -c '\[Style: ' lint/stdout.log lint/stderr.log   # Verible's violations
tail -n 1 lint/stdout.log                    # slang's "Build succeeded: 0 errors, 0 warnings"
grep -cE '^[EW] +[A-Z0-9_]+:' lint/ascentlint.rpt     # AscentLint's errors and warnings in the report
grep -E '^(Error: |ERROR|  ERR |Warning: |  WARN )' lint/ascentlint.log   # and in the log

Only the first line of each message is kept in the result. The log also has what the linter prints under it: the instance, the source line and hints.

The logs the messages are read from are outputs of the step, as is messages.json, so they are there after any run, pass or fail, and for a step taken from the cache. Verilator’s lint/stdout.log is not one. It is only left by a step that did not pass or a run with --debug (see What is left in a step’s directory).