Skip to content

In memory and instrumented, a compilation goes on after a driver error #264

Open

Description

@SizzleUnrlsd

Summary

When Clang's driver reports an error while it builds the compilation, compilerlib::compile still runs the jobs, and succeeds, in every mode but plain file output. Seen with -working-directory naming a directory that does not exist: clang and a plain compilation fail with unable to set working directory, while a compilation to memory, or an instrumented one, prints the same error and returns its output.

Observed

cc at main (f0a22d9), macOS arm64, LLVM 20.1.2; <missing> does not exist, u.c is given by an absolute path and includes nothing:

Command Exit status Output
clang -working-directory <missing> -c u.c -o u.o 1 none
cc -working-directory <missing> -c u.c -o u.o 1 none
cc --in-mem -working-directory <missing> -S -emit-llvm u.c 0 the IR
cc --instrument -working-directory <missing> -c u.c -o u.o 0 u.o

The three cc commands print error: unable to set working directory: <missing>.

Cause

Plain file output runs the jobs through the driver's ExecuteCompilation, which returns a failure after such an error, as clang does. The other modes run the jobs themselves once BuildCompilation returns a compilation (compiler.cpp L1312-L1362), without asking whether the driver reported an error.

Found by

coretrace-stack-analyzer, adapted to pass each compile command's directory as -working-directory (#262): its bitcode compilation of a command whose directory is missing failed, and its fallback to textual IR in memory succeeded. The adaptation now checks the directory itself.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions