build-bom
build-bom copied to clipboard
build-bom confusingly creates .bc files that are ELF files in some error circumstances
I was running build-bom in an automated fashion over a large set of compilation tasks, and programmatically fetching all bitcode files produced this way.
Surprisingly, some ".bc" files had incorrect magic number, and turned out to be ELF files.
The circumstances under which this seems to happen is for compilation commands of the shape:
clang -c file1.c file2.c
where the intent was to produce a bunch of matching .o files.
build-bom does raise an error message, but then it also ends up creating .bc files.
Reproducer:
$ cat a.c
int foo() { return 0; }
$ cat b.c
int bar() { return 1; }
$ build-bom generate-bitcode --suppress-automatic-debug -- clang -c -march=x86-64 *.c
[2025-09-16T23:13:56Z ERROR bom::bom::bitcode] Error building bitcode: Multiple input files found for command: files ["a.c", "b.c"] from args ["-c", "-march=x86-64", "a.c", "b.c"]
[2025-09-16T23:13:56Z ERROR bom::bom::bitcode] Unresolved implicit outputs with multiple input files in command '"clang" ["-c", "-march=x86-64", "a.c", "b.c"]'
$ file a.bc
a.bc: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped