Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 693444 | Differences between
and this patch

Collapse All | Expand All

(-)ld64-530/src/ld/InputFiles.cpp (+8 lines)
Lines 60-66 Link Here
60
#include "macho_dylib_file.h"
60
#include "macho_dylib_file.h"
61
#include "textstub_dylib_file.hpp"
61
#include "textstub_dylib_file.hpp"
62
#include "archive_file.h"
62
#include "archive_file.h"
63
#ifdef LTO
63
#include "lto_file.h"
64
#include "lto_file.h"
65
#endif
64
#include "opaque_section_file.h"
66
#include "opaque_section_file.h"
65
#include "MachOFileAbstraction.hpp"
67
#include "MachOFileAbstraction.hpp"
66
#include "Snapshot.h"
68
#include "Snapshot.h"
Lines 205-213 Link Here
205
		return result;
207
		return result;
206
	}
208
	}
207
209
210
#ifdef LTO
208
	result = lto::archName(p, len);
211
	result = lto::archName(p, len);
209
	if ( result != NULL  )
212
	if ( result != NULL  )
210
		 return result;
213
		 return result;
214
#endif
211
215
212
	const char* archiveArchName;
216
	const char* archiveArchName;
213
	if ( ::archive::isArchiveFile(p, len, &platform, &archiveArchName) )
217
	if ( ::archive::isArchiveFile(p, len, &platform, &archiveArchName) )
Lines 355-360 Link Here
355
		return objResult;
359
		return objResult;
356
	}
360
	}
357
361
362
#ifdef LTO
358
	// see if it is an llvm object file
363
	// see if it is an llvm object file
359
	objResult = lto::parse(p, len, info.path, info.modTime, info.ordinal, _options.architecture(), _options.subArchitecture(), _options.logAllFiles(), _options.verboseOptimizationHints());
364
	objResult = lto::parse(p, len, info.path, info.modTime, info.ordinal, _options.architecture(), _options.subArchitecture(), _options.logAllFiles(), _options.verboseOptimizationHints());
360
	if ( objResult != NULL ) {
365
	if ( objResult != NULL ) {
Lines 362-367 Link Here
362
		OSAtomicIncrement32(&_totalObjectLoaded);
367
		OSAtomicIncrement32(&_totalObjectLoaded);
363
		return objResult;
368
		return objResult;
364
	}
369
	}
370
#endif
365
371
366
	// see if it is a dynamic library (or text-based dynamic library)
372
	// see if it is a dynamic library (or text-based dynamic library)
367
	ld::dylib::File* dylibResult;
373
	ld::dylib::File* dylibResult;
Lines 413-418 Link Here
413
		return archiveResult;
419
		return archiveResult;
414
	}
420
	}
415
	
421
	
422
#ifdef LTO
416
	// does not seem to be any valid linker input file, check LTO misconfiguration problems
423
	// does not seem to be any valid linker input file, check LTO misconfiguration problems
417
	if ( lto::archName((uint8_t*)p, len) != NULL ) {
424
	if ( lto::archName((uint8_t*)p, len) != NULL ) {
418
		if ( lto::libLTOisLoaded() ) {
425
		if ( lto::libLTOisLoaded() ) {
Lines 442-447 Link Here
442
			throwf("could not process llvm bitcode object file, because %s could not be loaded", libLTO);
449
			throwf("could not process llvm bitcode object file, because %s could not be loaded", libLTO);
443
		}
450
		}
444
	}
451
	}
452
#endif
445
453
446
	if ( dylibsNotAllowed ) {
454
	if ( dylibsNotAllowed ) {
447
		cpu_type_t dummy1;
455
		cpu_type_t dummy1;
(-)ld64-530/src/ld/ld.cpp (+6 lines)
Lines 81-93 Link Here
81
#include "passes/branch_shim.h"
81
#include "passes/branch_shim.h"
82
#include "passes/objc.h"
82
#include "passes/objc.h"
83
#include "passes/dylibs.h"
83
#include "passes/dylibs.h"
84
#ifdef LTO
84
#include "passes/bitcode_bundle.h"
85
#include "passes/bitcode_bundle.h"
86
#endif
85
#include "passes/code_dedup.h"
87
#include "passes/code_dedup.h"
86
88
87
#include "parsers/archive_file.h"
89
#include "parsers/archive_file.h"
88
#include "parsers/macho_relocatable_file.h"
90
#include "parsers/macho_relocatable_file.h"
89
#include "parsers/macho_dylib_file.h"
91
#include "parsers/macho_dylib_file.h"
92
#ifdef LTO
90
#include "parsers/lto_file.h"
93
#include "parsers/lto_file.h"
94
#endif
91
#include "parsers/opaque_section_file.h"
95
#include "parsers/opaque_section_file.h"
92
96
93
97
Lines 1381-1387 Link Here
1381
		ld::passes::branch_island::doPass(options, state);	// must be after stubs and order pass
1385
		ld::passes::branch_island::doPass(options, state);	// must be after stubs and order pass
1382
		ld::passes::dtrace::doPass(options, state);
1386
		ld::passes::dtrace::doPass(options, state);
1383
		ld::passes::compact_unwind::doPass(options, state);  // must be after order pass
1387
		ld::passes::compact_unwind::doPass(options, state);  // must be after order pass
1388
#ifdef LTO
1384
		ld::passes::bitcode_bundle::doPass(options, state);  // must be after dylib
1389
		ld::passes::bitcode_bundle::doPass(options, state);  // must be after dylib
1390
#endif
1385
1391
1386
		// Sort again so that we get the segments in order.
1392
		// Sort again so that we get the segments in order.
1387
		state.sortSections();
1393
		state.sortSections();
(-)ld64-530/src/ld/Options.cpp (+6 lines)
Lines 53-64 Link Here
53
#define VAL(x) #x
53
#define VAL(x) #x
54
#define STRINGIFY(x) VAL(x)
54
#define STRINGIFY(x) VAL(x)
55
55
56
#ifdef LTO
56
// upward dependency on lto::version()
57
// upward dependency on lto::version()
57
namespace lto {
58
namespace lto {
58
	extern const char* version();
59
	extern const char* version();
59
	extern unsigned static_api_version();
60
	extern unsigned static_api_version();
60
	extern unsigned runtime_api_version();
61
	extern unsigned runtime_api_version();
61
}
62
}
63
#endif
62
64
63
// magic to place command line in crash reports
65
// magic to place command line in crash reports
64
const int crashreporterBufferSize = 2000;
66
const int crashreporterBufferSize = 2000;
Lines 4127-4136 Link Here
4127
			fprintf(stderr, "configured to support archs: %s\n", ALL_SUPPORTED_ARCHS);
4129
			fprintf(stderr, "configured to support archs: %s\n", ALL_SUPPORTED_ARCHS);
4128
			 // if only -v specified, exit cleanly
4130
			 // if only -v specified, exit cleanly
4129
			 if ( argc == 2 ) {
4131
			 if ( argc == 2 ) {
4132
#ifdef LTO
4130
				const char* ltoVers = lto::version();
4133
				const char* ltoVers = lto::version();
4131
				if ( ltoVers != NULL )
4134
				if ( ltoVers != NULL )
4132
					fprintf(stderr, "LTO support using: %s (static support for %d, runtime is %d)\n",
4135
					fprintf(stderr, "LTO support using: %s (static support for %d, runtime is %d)\n",
4133
							ltoVers, lto::static_api_version(), lto::runtime_api_version());
4136
							ltoVers, lto::static_api_version(), lto::runtime_api_version());
4137
#endif
4134
				fprintf(stderr, "TAPI support using: %s\n", tapi::Version::getFullVersionAsString().c_str());
4138
				fprintf(stderr, "TAPI support using: %s\n", tapi::Version::getFullVersionAsString().c_str());
4135
				exit(0);
4139
				exit(0);
4136
			}
4140
			}
Lines 4153-4158 Link Here
4153
			}
4157
			}
4154
			fprintf(stdout, "\n\t],\n");
4158
			fprintf(stdout, "\n\t],\n");
4155
4159
4160
#ifdef LTO
4156
			const char* ltoVers = lto::version();
4161
			const char* ltoVers = lto::version();
4157
			if ( ltoVers != NULL ) {
4162
			if ( ltoVers != NULL ) {
4158
				fprintf(stdout, "\t\"lto\": {\n");
4163
				fprintf(stdout, "\t\"lto\": {\n");
Lines 4161-4166 Link Here
4161
				fprintf(stdout, "\t\t\"version_string\": \"%s\"\n", ltoVers);
4166
				fprintf(stdout, "\t\t\"version_string\": \"%s\"\n", ltoVers);
4162
				fprintf(stdout, "\t},\n");
4167
				fprintf(stdout, "\t},\n");
4163
			}
4168
			}
4169
#endif
4164
4170
4165
			fprintf(stdout, "\t\"tapi\": {\n");
4171
			fprintf(stdout, "\t\"tapi\": {\n");
4166
			fprintf(stdout, "\t\t\"version\": \"%s\",\n", tapi::Version::getAsString().c_str());
4172
			fprintf(stdout, "\t\t\"version\": \"%s\",\n", tapi::Version::getAsString().c_str());
(-)ld64-530/src/ld/parsers/archive_file.cpp (-2 / +18 lines)
Lines 92-99 Link Here
92
92
93
	static bool										validMachOFile(const uint8_t* fileContent, uint64_t fileLength,
93
	static bool										validMachOFile(const uint8_t* fileContent, uint64_t fileLength,
94
																	const mach_o::relocatable::ParserOptions& opts);
94
																	const mach_o::relocatable::ParserOptions& opts);
95
#ifdef LTO
95
	static bool										validLTOFile(const uint8_t* fileContent, uint64_t fileLength, 
96
	static bool										validLTOFile(const uint8_t* fileContent, uint64_t fileLength, 
96
																	const mach_o::relocatable::ParserOptions& opts);
97
																	const mach_o::relocatable::ParserOptions& opts);
98
#endif
97
	static cpu_type_t								architecture();
99
	static cpu_type_t								architecture();
98
100
99
	class Entry : ar_hdr
101
	class Entry : ar_hdr
Lines 237-242 Link Here
237
	return mach_o::relocatable::isObjectFile(fileContent, fileLength, opts);
239
	return mach_o::relocatable::isObjectFile(fileContent, fileLength, opts);
238
}
240
}
239
241
242
#ifdef LTO
240
template <typename A>
243
template <typename A>
241
bool File<A>::validLTOFile(const uint8_t* fileContent, uint64_t fileLength, const mach_o::relocatable::ParserOptions& opts)
244
bool File<A>::validLTOFile(const uint8_t* fileContent, uint64_t fileLength, const mach_o::relocatable::ParserOptions& opts)
242
{
245
{
Lines 247-252 Link Here
247
		return false;
250
		return false;
248
	return lto::isObjectFile(fileContent, fileLength, opts.architecture, opts.subType);
251
	return lto::isObjectFile(fileContent, fileLength, opts.architecture, opts.subType);
249
}
252
}
253
#endif
250
254
251
255
252
256
Lines 271-277 Link Here
271
			continue;
275
			continue;
272
#endif
276
#endif
273
		// archive is valid if first .o file is valid
277
		// archive is valid if first .o file is valid
274
		return (validMachOFile(p->content(), p->contentSize(), opts) || validLTOFile(p->content(), p->contentSize(), opts));
278
		return (validMachOFile(p->content(), p->contentSize(), opts)
279
#ifdef LTO
280
				|| validLTOFile(p->content(), p->contentSize(), opts)
281
#endif	
282
				);
275
	}	
283
	}	
276
	// empty archive
284
	// empty archive
277
	return true;
285
	return true;
Lines 407-412 Link Here
407
			_instantiatedEntries[member] = state;
415
			_instantiatedEntries[member] = state;
408
			return _instantiatedEntries[member];
416
			return _instantiatedEntries[member];
409
		}
417
		}
418
#ifdef LTO
410
		// see if member is llvm bitcode file
419
		// see if member is llvm bitcode file
411
		result = lto::parse(member->content(), member->contentSize(), 
420
		result = lto::parse(member->content(), member->contentSize(), 
412
								mPath, member->modificationTime(), ordinal, 
421
								mPath, member->modificationTime(), ordinal, 
Lines 416-423 Link Here
416
			_instantiatedEntries[member] = state;
425
			_instantiatedEntries[member] = state;
417
			return _instantiatedEntries[member];
426
			return _instantiatedEntries[member];
418
		}
427
		}
428
#endif
419
			
429
			
420
		throwf("archive member '%s' with length %d is not mach-o or llvm bitcode", memberName, member->contentSize());
430
		throwf("archive member '%s' with length %d is not mach-o"
431
#ifdef LTO
432
				" or llvm bitcode"
433
#endif
434
				, memberName, member->contentSize());
421
	}
435
	}
422
	catch (const char* msg) {
436
	catch (const char* msg) {
423
		throwf("in %s, %s", memberPath, msg);
437
		throwf("in %s, %s", memberPath, msg);
Lines 490-495 Link Here
490
			if ( (member==start) && ((strcmp(mname, SYMDEF_64_SORTED) == 0) || (strcmp(mname, SYMDEF_64) == 0)) )
504
			if ( (member==start) && ((strcmp(mname, SYMDEF_64_SORTED) == 0) || (strcmp(mname, SYMDEF_64) == 0)) )
491
				continue;
505
				continue;
492
#endif
506
#endif
507
#ifdef LTO
493
			if ( validMachOFile(member->content(), member->contentSize(), _objOpts) ) {
508
			if ( validMachOFile(member->content(), member->contentSize(), _objOpts) ) {
494
				MemberState& state = this->makeObjectFileForMember(member);
509
				MemberState& state = this->makeObjectFileForMember(member);
495
				// only look at files not already loaded
510
				// only look at files not already loaded
Lines 513-518 Link Here
513
					}
528
					}
514
				}
529
				}
515
			}
530
			}
531
#endif
516
		}
532
		}
517
	}
533
	}
518
	return didSome;
534
	return didSome;
(-)ld64-530/src/ld/passes/bitcode_bundle.cpp (+2 lines)
Lines 22-27 Link Here
22
 * @APPLE_LICENSE_HEADER_END@
22
 * @APPLE_LICENSE_HEADER_END@
23
 */
23
 */
24
24
25
#ifdef LTO
25
#include <stdio.h>
26
#include <stdio.h>
26
#include <stdlib.h>
27
#include <stdlib.h>
27
#include <fcntl.h>
28
#include <fcntl.h>
Lines 1084-1086 Link Here
1084
} // namespace bitcode_bundle
1085
} // namespace bitcode_bundle
1085
} // namespace passes
1086
} // namespace passes
1086
} // namespace ld
1087
} // namespace ld
1088
#endif
(-)ld64-530/src/ld/Resolver.cpp (+6 lines)
Lines 56-62 Link Here
56
#include "InputFiles.h"
56
#include "InputFiles.h"
57
#include "SymbolTable.h"
57
#include "SymbolTable.h"
58
#include "Resolver.h"
58
#include "Resolver.h"
59
#ifdef LTO
59
#include "parsers/lto_file.h"
60
#include "parsers/lto_file.h"
61
#endif
60
62
61
#include "configure.h"
63
#include "configure.h"
62
64
Lines 1749-1754 Link Here
1749
1751
1750
void Resolver::linkTimeOptimize()
1752
void Resolver::linkTimeOptimize()
1751
{
1753
{
1754
#ifdef LTO
1752
	// only do work here if some llvm obj files where loaded
1755
	// only do work here if some llvm obj files where loaded
1753
	if ( ! _haveLLVMObjs )
1756
	if ( ! _haveLLVMObjs )
1754
		return;
1757
		return;
Lines 1887-1892 Link Here
1887
		}
1890
		}
1888
		_symbolTable.removeDeadUndefs(_atoms, mustPreserve);
1891
		_symbolTable.removeDeadUndefs(_atoms, mustPreserve);
1889
	}
1892
	}
1893
#else
1894
	return;
1895
#endif
1890
}
1896
}
1891
1897
1892
1898
(-)ld64-530/src/other/ObjectDump.cpp (+4 lines)
Lines 33-39 Link Here
33
33
34
#include "MachOFileAbstraction.hpp"
34
#include "MachOFileAbstraction.hpp"
35
#include "parsers/macho_relocatable_file.h"
35
#include "parsers/macho_relocatable_file.h"
36
#ifdef LTO
36
#include "parsers/lto_file.h"
37
#include "parsers/lto_file.h"
38
#endif
37
39
38
const ld::VersionSet ld::File::_platforms;
40
const ld::VersionSet ld::File::_platforms;
39
41
Lines 1279-1288 Link Here
1279
	if ( objResult != NULL )
1281
	if ( objResult != NULL )
1280
		return objResult;
1282
		return objResult;
1281
1283
1284
#ifdef LTO
1282
	// see if it is an llvm object file
1285
	// see if it is an llvm object file
1283
	objResult = lto::parse(p, fileLen, path, stat_buf.st_mtime, ld::File::Ordinal::NullOrdinal(), sPreferredArch, sPreferredSubArch, false, true);
1286
	objResult = lto::parse(p, fileLen, path, stat_buf.st_mtime, ld::File::Ordinal::NullOrdinal(), sPreferredArch, sPreferredSubArch, false, true);
1284
	if ( objResult != NULL ) 
1287
	if ( objResult != NULL ) 
1285
		return objResult;
1288
		return objResult;
1289
#endif
1286
1290
1287
	throwf("not a mach-o object file: %s", path);
1291
	throwf("not a mach-o object file: %s", path);
1288
#else
1292
#else

Return to bug 693444