aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Build/Module.zig
diff options
context:
space:
mode:
authorDavid Rubin <daviru007@icloud.com>2024-12-26 05:30:56 -0800
committerDavid Rubin <87927264+Rexicon226@users.noreply.github.com>2025-02-25 11:22:33 -0800
commit2d4574aafbf95f357ad6306b98d9c8ebebbafe2e (patch)
treecbe4a1fb8e16545bfe49e542f8d8d1f02de9aa36 /lib/std/Build/Module.zig
parenta468929519157cf7a2070a0368357cb73ad80b61 (diff)
downloadzig-2d4574aafbf95f357ad6306b98d9c8ebebbafe2e.tar.gz
zig-2d4574aafbf95f357ad6306b98d9c8ebebbafe2e.zip
Compilation: always import ubsan if a ZCU exists
Unlike `compiler-rt`, `ubsan` uses the standard library quite a lot. Using a similar approach to how `compiler-rt` is handled today, where it's compiled into its own object and then linked would be sub-optimal as we'd be introducing a lot of code bloat. This approach always "imports" `ubsan` if the ZCU, if it exists. If it doesn't such as the case where we're compiling only C code, then we have no choice other than to compile it down to an object and link. There's still a tiny optimization we can do in that case, which is when compiling to a static library, there's no need to construct an archive with a single object. We'd only go back and parse out ubsan from the archive later in the pipeline. So we compile it to an object instead and link that to the static library. TLDR; - `zig build-exe foo.c` -> build `libubsan.a` and links - `zig build-obj foo.c` -> doesn't build anything, just emits references to ubsan runtime - `zig build-lib foo.c -static` -> build `ubsan.o` and link it - `zig build-exe foo.zig bar.c` -> import `ubsan-rt` into the ZCU - `zig build-obj foo.zig bar.c` -> import `ubsan-rt` into the ZCU - `zig build-lib foo.zig bar.c` -> import `ubsan-rt` into the ZCU
Diffstat (limited to 'lib/std/Build/Module.zig')
0 files changed, 0 insertions, 0 deletions