# add \-femit-llvm-bc CLI option and implement it · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/a5fb28070f37c2cad92ac8805bcc704e872fc538)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: a5fb28070f37c2cad92ac8805bcc704e872fc538

Requested commit: a5fb28070f37c2cad92ac8805bcc704e872fc538

Commit: a5fb28070f37c2cad92ac8805bcc704e872fc538

Tree: 05e8432688cd83fcb4989a13087c01c74df172c5

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
add -femit-llvm-bc CLI option and implement it

 * Added doc comments for `std.Target.ObjectFormat` enum
 * `std.Target.oFileExt` is removed because it is incorrect for Plan-9
   targets. Instead, use `std.Target.ObjectFormat.fileExt` and pass a
   CPU architecture.
 * Added `Compilation.Directory.joinZ` for when a null byte is desired.
 * Improvements to `Compilation.create` logic for computing `use_llvm`
   and reporting errors in contradictory flags. `-femit-llvm-ir` and
   `-femit-llvm-bc` will now imply `-fLLVM`.
 * Fix compilation when passing `.bc` files on the command line.
 * Improvements to the stage2 LLVM backend:
   - cleaned up error messages and error reporting. Properly bubble up
     some errors rather than dumping to stderr; others turn into panics.
   - properly call ZigLLVMCreateTargetMachine and
     ZigLLVMTargetMachineEmitToFile and implement calculation of the
     respective parameters (cpu features, code model, abi name, lto,
     tsan, etc).
   - LLVM module verification only runs in debug builds of the compiler
   - use LLVMDumpModule rather than printToString because in the case
     that we incorrectly pass a null pointer to LLVM it may crash during
     dumping the module and having it partially printed is helpful in
     this case.
   - support -femit-asm, -fno-emit-bin, -femit-llvm-ir, -femit-llvm-bc
   - Support LLVM backend when used with Mach-O and WASM linkers.

```

## Parents

- [36295d712fbd561c3de9b3eb46e776d63e646e9a](https://git.cafe/gitcafe/zig/commit/36295d712fbd561c3de9b3eb46e776d63e646e9a?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/a5fb28070f37c2cad92ac8805bcc704e872fc538?format=markdown)
