X-Git-Url: https://git.saurik.com/apple/ld64.git/blobdiff_plain/eaf282aaf65b222563e6b3db98e12d720fb161bf..dd9e569f384b2c941bcc73d89d1468756788ee5b:/src/ld/Resolver.cpp diff --git a/src/ld/Resolver.cpp b/src/ld/Resolver.cpp index 094c98d..948906f 100644 --- a/src/ld/Resolver.cpp +++ b/src/ld/Resolver.cpp @@ -363,7 +363,6 @@ void Resolver::doFile(const ld::File& file) this->doLinkerOption(*it, file.path()); } } - // Resolve bitcode section in the object file if ( _options.bundleBitcode() ) { if ( objFile->getBitcode() == NULL ) { @@ -383,35 +382,25 @@ void Resolver::doFile(const ld::File& file) "You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target.", file.path()); break; case Options::kPlatformWatchOS: +#if SUPPORT_APPLE_TV + case Options::kPlatform_tvOS: +#endif throwf("'%s' does not contain bitcode. " "You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE) or obtain an updated library from the vendor", file.path()); break; - #if SUPPORT_APPLE_TV - case Options::kPlatform_tvOS: - warning("URGENT: all bitcode will be dropped because '%s' was built without bitcode. " - "You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE) or obtain an updated library from the vendor. " - "Note: This will be an error in the future.", file.path()); - _internal.filesWithBitcode.clear(); - _internal.dropAllBitcode = true; - break; - #endif } } } else { // contains bitcode, check if it is just a marker if ( objFile->getBitcode()->isMarker() ) { - // if the bitcode is just a marker, - // the executable will be created without bitcode section. - // Otherwise, create a marker. - if ( _options.outputKind() != Options::kDynamicExecutable && - _options.outputKind() != Options::kStaticExecutable ) - _internal.embedMarkerOnly = true; - // Issue a warning if the marker is in the static library and filesWithBitcode is not empty. - // That means there are object files actually compiled with full bitcode but the archive only has marker. - // Don't warn on normal object files because it can be a debug build using archives with full bitcode. - if ( !_internal.filesWithBitcode.empty() && objFile->sourceKind() == ld::relocatable::File::kSourceArchive ) - warning("full bitcode bundle could not be generated because '%s' was built only with bitcode marker. " - "The library must be generated from Xcode archive build with bitcode enabled (Xcode setting ENABLE_BITCODE)", objFile->path()); + // if -bitcode_verify_bundle is used, check if all the object files participate in the linking have full bitcode embedded. + // error on any marker encountered. + if ( _options.verifyBitcode() ) + throwf("bitcode bundle could not be generated because '%s' was built without full bitcode. " + "All object files and libraries for bitcode must be generated from Xcode Archive or Install build", + objFile->path()); + // update the internal state that marker is encountered. + _internal.embedMarkerOnly = true; _internal.filesWithBitcode.clear(); _internal.dropAllBitcode = true; } else if ( !_internal.dropAllBitcode ) @@ -542,8 +531,8 @@ void Resolver::doFile(const ld::File& file) if ( dylibFile != NULL ) { // Check dylib for bitcode, if the library install path is relative path or @rpath, it has to contain bitcode if ( _options.bundleBitcode() ) { - if ( dylibFile->getBitcode() == NULL && - dylibFile->installPath()[0] != '/' ) { + bool isSystemFramework = ( dylibFile->installPath() != NULL ) && ( dylibFile->installPath()[0] == '/' ); + if ( dylibFile->getBitcode() == NULL && !isSystemFramework ) { // Check if the dylib is from toolchain by checking the path char tcLibPath[PATH_MAX]; char ldPath[PATH_MAX]; @@ -574,21 +563,21 @@ void Resolver::doFile(const ld::File& file) "You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target.", file.path()); break; case Options::kPlatformWatchOS: +#if SUPPORT_APPLE_TV + case Options::kPlatform_tvOS: +#endif throwf("'%s' does not contain bitcode. " "You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE) or obtain an updated library from the vendor", file.path()); break; - #if SUPPORT_APPLE_TV - case Options::kPlatform_tvOS: - warning("URGENT: all bitcode will be dropped because '%s' was built without bitcode. " - "You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE) or obtain an updated library from the vendor. " - "Note: This will be an error in the future.", file.path()); - _internal.filesWithBitcode.clear(); - _internal.dropAllBitcode = true; - break; - #endif } } } + // Error on bitcode marker in non-system frameworks if -bitcode_verify is used + if ( _options.verifyBitcode() && !isSystemFramework && + dylibFile->getBitcode() != NULL && dylibFile->getBitcode()->isMarker() ) + throwf("bitcode bundle could not be generated because '%s' was built without full bitcode. " + "All frameworks and dylibs for bitcode must be generated from Xcode Archive or Install build", + dylibFile->path()); } // update which form of ObjC dylibs are being linked @@ -729,7 +718,7 @@ void Resolver::doAtom(const ld::Atom& atom) // tell symbol table about non-static atoms if ( atom.scope() != ld::Atom::scopeTranslationUnit ) { - _symbolTable.add(atom, _options.deadCodeStrip() && _completedInitialObjectFiles); + _symbolTable.add(atom, _options.deadCodeStrip() && (_completedInitialObjectFiles || _options.allowDeadDuplicates())); // add symbol aliases defined on the command line if ( _options.haveCmdLineAliases() ) {