forked from OSchip/llvm-project
[OffloadPackager] Use appropriate kind for LTO bitcode
Summary: Currently we just check the extension to set the image kind. This incorrectly labels the `.o` files created during LTO as object files. This patch simply adds a check for the bitcode magic bytes instead.
This commit is contained in:
parent
a4e2c1f762
commit
b6178ccfe8
|
@ -1,5 +1,6 @@
|
|||
set(LLVM_LINK_COMPONENTS
|
||||
${LLVM_TARGETS_TO_BUILD}
|
||||
BinaryFormat
|
||||
Object
|
||||
Support)
|
||||
|
||||
|
|
|
@ -99,9 +99,14 @@ int main(int argc, const char **argv) {
|
|||
llvm::MemoryBuffer::getFileOrSTDIN(KeyAndValue.getValue());
|
||||
if (std::error_code EC = ObjectOrErr.getError())
|
||||
return reportError(errorCodeToError(EC));
|
||||
|
||||
// Clang uses the '.o' suffix for LTO bitcode.
|
||||
if (identify_magic((*ObjectOrErr)->getBuffer()) == file_magic::bitcode)
|
||||
ImageBinary.TheImageKind = object::IMG_Bitcode;
|
||||
else
|
||||
ImageBinary.TheImageKind = getImageKind(
|
||||
sys::path::extension(KeyAndValue.getValue()).drop_front());
|
||||
ImageBinary.Image = std::move(*ObjectOrErr);
|
||||
ImageBinary.TheImageKind = getImageKind(
|
||||
sys::path::extension(KeyAndValue.getValue()).drop_front());
|
||||
} else if (Key == "kind") {
|
||||
ImageBinary.TheOffloadKind = getOffloadKind(KeyAndValue.getValue());
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue