Skip to content

Commit

Permalink
Add sequence diagram to README to help explain build-bom operation
Browse files Browse the repository at this point in the history
  • Loading branch information
kquick committed Nov 10, 2024
1 parent 414261b commit 3ca23dd
Show file tree
Hide file tree
Showing 4 changed files with 145 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ There are four key observations enabling this approach to bitcode collection:

We wrap our generated bitcode in singleton tar files and allow the linker to accumulate them for us. When we want to collect aggregated bitcode for executable artifacts, we simply extract the tar file from their special LLVM bitcode ELF sections, extract the collected bitcode, and link it together with ~llvm-link~.

[[./doc/build_bom_seq.svg]]

Observe as well that the ~build-bom~ process useful for selective rebuilds: rebuilding only a portion of the sources will still have access to llvm-bitcode ELF sections in object from previous builds. The use of ~build-bom~ also has graceful degradation properties: object files which do not have llvm bitcode sections in their ELF (i.e. built separately without using ~build-bom~) will simply not contributed to the ELF section/tarfile accumulation of bitcode; the final extraction ~llvm-link~ does not need to be total and is tolerant of unresolved symbols.

The bitcode extracted will be representative of the binary code contained in the specified file. It will not necessarily be identical to that code due to strictness flags, differences between clang and the native build compiler, and a different linking step.
Expand Down
21 changes: 21 additions & 0 deletions doc/build_bom_seq.d2
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
shape: sequence_diagram
build-bom
build tool
"Project's build tool": {
build tool."make,\ncmake,\nmeson,\nother ..."
}
build-bom.run -> build tool.all : fork + ptrace
build tool.all -> compile.run
compile.run -> build-bom.run.start : ptrace: "starting"
build-bom.run.start -> compile.run : ptrace: "ok, continue"
compile.run -> build-bom.run.end : ptrace: "finishing"
build-bom.run.end -> clang.run : -emit-llvm
clang.run -> build-bom.run.end : llvm bitcode
build-bom."Insert llvm bitcode in compile's ELF obj file"
build-bom.run.end -> compile.run {
style.stroke-dash: 5
}
build-bom.run.end -> compile.run : ptrace: "ok, continue"
compile.run -> build tool.all
build tool."Repeats above as needed for build"
build tool.all -> build-bom.run
Loading

0 comments on commit 3ca23dd

Please sign in to comment.