bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug binutils/11843] ld long link times due to compute_bucket_count() ch


From: todd dot veldhuizen at logicblox dot com
Subject: [Bug binutils/11843] ld long link times due to compute_bucket_count() choosing hash table size
Date: 28 Jul 2010 22:05:52 -0000

------- Additional Comments From todd dot veldhuizen at logicblox dot com  
2010-07-28 22:05 -------
Here is a C++ program that will create a bunch of .c files, compile and then
link them, hitting the bug.  It links very quickly without the -O1 option, and
with the -O1 option it takes a very long time.


---==== cut-here

#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <map>

int main()
{
   const int num_symbols = 199933;
   const int ref_symbol_delta = 37199;
   const int num_files = 25;
   char tbuf[128];

   srand(1);

   std::string objfiles;
   int ref_symbol = 0;
   int i = 0;
   for (int j=0; j < num_files; ++j)
   {
      int symbols_ceil = (num_symbols*(j+1))/num_files;
      sprintf(tbuf, "many_symbols%03d.c", j+1);
      FILE* dst = fopen(tbuf, "w");

      std::map<int,int> sites;

      for (; i < symbols_ceil; ++i)
      {
         ref_symbol = (ref_symbol + ref_symbol_delta) % num_symbols;
         sites[i] = ref_symbol;
         fprintf(dst, "void foo%d();\n", ref_symbol);
      }

      for (std::map<int,int>::iterator iter = sites.begin();
         iter != sites.end(); ++iter)
      {
         fprintf(dst, "void foo%d() { foo%d(); }\n", iter->first,
            iter->second);
      }
      fclose(dst);

      sprintf(tbuf, "gcc -c -fPIC many_symbols%03d.c -o many_symbols%03d.o",
         j+1, j+1);
      printf("%s\n", tbuf);
      system(tbuf);

      sprintf(tbuf, "many_symbols%03d.o", j+1);
      objfiles += ((j > 0) ? " " : "") + std::string(tbuf);
   }

   system("time ld -O1 many_symbols???.o -shared -o libxxx.so");
}

---==== cut-here

-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=11843

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]