correctcomputation / checkedc-clang

This is the primary development repository for 3C, a tool for automatically converting legacy C code to the Checked C extension of C, which aims to enforce spatial memory safety. This repository is a fork of Checked C's.
14 stars 5 forks source link

Compiling a project can fail if multiple independant binaries are included #241

Closed aaronjeline closed 3 years ago

aaronjeline commented 4 years ago

a.c

#include <string_checked.h>

int main(int argc, char **argv) {
  return strlen(argv[0]);
}

b.c

int main() {
  return 3;
}

With the following commands database: compile_commands.json:

[
    {
        "arguments": [
            "cc",
            "-o a.out",
            "./a.c"
        ],
        "directory": "/home/aeline/build/bin/",
        "file": "a.c"
    },
    {
        "arguments": [
            "cc",
            "-o b.out",
            "./b.c"
        ],
        "directory": "/home/aeline/build/bin/",
        "file": "b.c"
    }
]

Compiling this with cconv-standalone -p compile_commands.json a.c b.c -output-postfix=checked will fail.

kyleheadley commented 3 years ago

This is being discussed in later issues (like #283) dealing with multiple functions of the same name.

mattmccutchen-cci commented 3 years ago

FWIW, I think the better duplicate target is #341. #283 is only to make 3C report a diagnostic cleanly in this scenario rather than exhibiting undefined behavior; so far, we got from undefined behavior to an immediate exit, but later we want to get to just a diagnostic for the benefit of clangd3c. #341 is to actually support the scenario.