mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Include information about the Swift ABI version in
the objc_imageinfo record. rdar://17528908 Swift SVN r21104
This commit is contained in:
@@ -192,18 +192,38 @@ static std::unique_ptr<llvm::Module> performIRGeneration(IRGenOptions &Opts,
|
||||
// Objective-C image information.
|
||||
// Generate module-level named metadata to convey this information to the
|
||||
// linker and code-gen.
|
||||
unsigned version = 0; // Version is unused?
|
||||
|
||||
// The ABI version of the imageinfo header structure itself.
|
||||
unsigned imageInfoVersion = 0;
|
||||
|
||||
// The ABI version of the ObjC data generated by this file.
|
||||
unsigned objcVersion = 2;
|
||||
|
||||
// The ABI version of the Swift data generated by this file.
|
||||
unsigned swiftVersion = 1;
|
||||
const char *section = "__DATA, __objc_imageinfo, regular, no_dead_strip";
|
||||
|
||||
// These module flags don't affect code generation; they just let us
|
||||
// error during LTO if the user tries to combine files across ABIs.
|
||||
Module->addModuleFlag(llvm::Module::Error, "Objective-C Version",
|
||||
objcVersion);
|
||||
Module->addModuleFlag(llvm::Module::Error, "Swift Version",
|
||||
swiftVersion);
|
||||
|
||||
// Add the ObjC ABI version to the module flags.
|
||||
Module->addModuleFlag(llvm::Module::Error, "Objective-C Version", 2);
|
||||
Module->addModuleFlag(llvm::Module::Error, "Objective-C Image Info Version",
|
||||
version);
|
||||
imageInfoVersion);
|
||||
Module->addModuleFlag(llvm::Module::Error, "Objective-C Image Info Section",
|
||||
llvm::MDString::get(Module->getContext(), section));
|
||||
|
||||
// LLVM's object-file emission collects a fixed set of keys for the
|
||||
// image info.
|
||||
// Using "Objective-C Garbage Collection" as the key here is a hack,
|
||||
// but LLVM's object-file emission isn't general enough to collect
|
||||
// arbitrary keys to put in the
|
||||
Module->addModuleFlag(llvm::Module::Override,
|
||||
"Objective-C Garbage Collection", (uint32_t)0);
|
||||
"Objective-C Garbage Collection",
|
||||
(uint32_t) (objcVersion << 8));
|
||||
|
||||
// Mark iOS simulator images.
|
||||
if (tripleIsiOSSimulator(llvm::Triple(Opts.Triple)))
|
||||
|
||||
@@ -107,3 +107,11 @@ class WeakObjC {
|
||||
var bar: AnyObject? = id
|
||||
}
|
||||
}
|
||||
|
||||
// rdar://17528908
|
||||
// CHECK: metadata !{i32 1, metadata !"Objective-C Version", i32 2}
|
||||
// CHECK: metadata !{i32 1, metadata !"Swift Version", i32 1}
|
||||
// CHECK: metadata !{i32 1, metadata !"Objective-C Image Info Version", i32 0}
|
||||
// CHECK: metadata !{i32 1, metadata !"Objective-C Image Info Section", metadata !"__DATA, __objc_imageinfo, regular, no_dead_strip"}
|
||||
// 512 == (1 << 8). 1 is the Swift ABI version.
|
||||
// CHECK: metadata !{i32 4, metadata !"Objective-C Garbage Collection", i32 512}
|
||||
|
||||
Reference in New Issue
Block a user