Skip to content

verilator_process_wrapper not returning correct exit code #420

@benreynwar

Description

@benreynwar

When verilator fails to compile the return value is sometimes incorrect, causing bazel to think it was successfull when it wasn't.

Currently it does (see verilator/private/verilator_process_wrapper.cc)

int result = std::system(cmd.c_str());
if (result != 0) {
  return result;
}

but std::system doesn't return the exit code. Running on ubuntu it returns exit_code << 8 for me, so a 1 becomes 256 which bazel then helpfully converts to 0.

I'm now using

if (result != 0) {
        if (WIFEXITED(result)) {
            int exit_code = WEXITSTATUS(result);
            return exit_code;
        } else {
            return 1; // Process was terminated by signal
        }
    }

and it works, but I have no idea whether this is a portable solution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions