gold plugin: move target initialization to the top of the onload function.
authorPeter Collingbourne <peter@pcc.me.uk>
Thu, 3 Jul 2014 23:28:03 +0000 (23:28 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Thu, 3 Jul 2014 23:28:03 +0000 (23:28 +0000)
On at least my machine, ar does not register an all symbols read hook (which
previously triggered target initialization), but it does register a claim
files hook, which depends on the targets being initialized.

Differential Revision: http://reviews.llvm.org/D4372

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212303 91177308-0d34-0410-b5e6-96231b3b80d8

tools/gold/gold-plugin.cpp

index 2c6257a0323cef1b6823e5fb829496e6c57ac70f..343a73988d1d5356943a49a24ccbad7097bd244d 100644 (file)
@@ -135,6 +135,12 @@ static ld_plugin_status cleanup_hook(void);
 
 extern "C" ld_plugin_status onload(ld_plugin_tv *tv);
 ld_plugin_status onload(ld_plugin_tv *tv) {
 
 extern "C" ld_plugin_status onload(ld_plugin_tv *tv);
 ld_plugin_status onload(ld_plugin_tv *tv) {
+  InitializeAllTargetInfos();
+  InitializeAllTargets();
+  InitializeAllTargetMCs();
+  InitializeAllAsmParsers();
+  InitializeAllAsmPrinters();
+
   // We're given a pointer to the first transfer vector. We read through them
   // until we find one where tv_tag == LDPT_NULL. The REGISTER_* tagged values
   // contain pointers to functions that we need to call to register our own
   // We're given a pointer to the first transfer vector. We read through them
   // until we find one where tv_tag == LDPT_NULL. The REGISTER_* tagged values
   // contain pointers to functions that we need to call to register our own
@@ -228,11 +234,6 @@ ld_plugin_status onload(ld_plugin_tv *tv) {
   if (!RegisteredAllSymbolsRead)
     return LDPS_OK;
 
   if (!RegisteredAllSymbolsRead)
     return LDPS_OK;
 
-  InitializeAllTargetInfos();
-  InitializeAllTargets();
-  InitializeAllTargetMCs();
-  InitializeAllAsmParsers();
-  InitializeAllAsmPrinters();
   CodeGen = new LTOCodeGenerator();
 
   // Pass through extra options to the code generator.
   CodeGen = new LTOCodeGenerator();
 
   // Pass through extra options to the code generator.