add -femit-llvm-bc CLI option and implement it, and improve -fcompiler-rt support #9440
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Emitting LLVM bitcode & improvements to stage2 LLVM backend
std.Target.ObjectFormat
enumstd.Target.oFileExt
is removed because it is incorrect for Plan-9targets. Instead, use
std.Target.ObjectFormat.fileExt
and pass aCPU architecture.
Compilation.Directory.joinZ
for when a null byte is desired.Compilation.create
logic for computinguse_llvm
and reporting errors in contradictory flags.
-femit-llvm-ir
and-femit-llvm-bc
will now imply-fLLVM
..bc
files on the command line.some errors rather than dumping to stderr; others turn into panics.
ZigLLVMTargetMachineEmitToFile and implement calculation of the
respective parameters (cpu features, code model, abi name, lto,
tsan, etc).
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 -fcompiler-rt in conjunction with build-obj
When using
build-exe
orbuild-lib -dynamic
,-fcompiler-rt
means buildingcompiler-rt into a static library and then linking it into the executable.
When using
build-lib
,-fcompiler-rt
means building compiler-rt into anobject file and then adding it into the static archive.
Before this commit, when using
build-obj
, zig would build compiler-rtinto an object file, and then on ELF, use
lld -r
to merge it into themain object file. Other linker backends of LLD do not support
-r
tomerge objects, so this failed with error messages for those targets.
Now,
-fcompiler-rt
when used withbuild-obj
acts as if the user puts_ = @import("compiler_rt");
inside their root source file. The symbolsof compiler-rt go into the same compilation unit as the root source file.
This is hooked up for stage1 only for now. Once stage2 is capable of
building compiler-rt, it should be hooked up there as well.