diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-09-29 15:10:17 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-09-29 15:10:17 +0000 |
commit | 4c47a04c0431d4f1cad46094c7a6daf497846a25 (patch) | |
tree | cd3b4ff74b4f4ba042780676731541c8d3e000a9 /gcc/toplev.c | |
parent | d07112c342791bf7dabe3de99dbf274e3a4961f5 (diff) | |
download | gcc-4c47a04c0431d4f1cad46094c7a6daf497846a25.tar.gz |
2011-09-29 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 179351 using svnmerge.
gcc/
2011-09-29 Basile Starynkevitch <basile@starynkevitch.net>
* melt-runtime.c (melt_really_initialize): Change, because
get_random_seed gives a string in GCC 4.6 and a number in GCC 4.7.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@179356 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/toplev.c')
-rw-r--r-- | gcc/toplev.c | 109 |
1 files changed, 74 insertions, 35 deletions
diff --git a/gcc/toplev.c b/gcc/toplev.c index 300d4d66ea9..b968b76ec93 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -147,6 +147,9 @@ static const char *flag_random_seed; user has specified a particular random seed. */ unsigned local_tick; +/* Random number for this compilation */ +HOST_WIDE_INT random_seed; + /* -f flags. */ /* Generate code for GNU or NeXT Objective-C runtime environment. */ @@ -257,7 +260,7 @@ announce_function (tree decl) } } -/* Initialize local_tick with the time of day, or -1 if +/* Initialize local_tick with a random number or -1 if flag_random_seed is set. */ static void @@ -265,7 +268,17 @@ init_local_tick (void) { if (!flag_random_seed) { - /* Get some more or less random data. */ + /* Try urandom first. Time of day is too likely to collide. + In case of any error we just use the local tick. */ + + int fd = open ("/dev/urandom", O_RDONLY); + if (fd >= 0) + { + read (fd, &random_seed, sizeof (random_seed)); + close (fd); + } + + /* Now get the tick anyways */ #ifdef HAVE_GETTIMEOFDAY { struct timeval tv; @@ -292,24 +305,28 @@ init_local_tick (void) static void init_random_seed (void) { - unsigned HOST_WIDE_INT value; - static char random_seed[HOST_BITS_PER_WIDE_INT / 4 + 3]; - - value = local_tick ^ getpid (); + if (flag_random_seed) + { + char *endp; - sprintf (random_seed, HOST_WIDE_INT_PRINT_HEX, value); - flag_random_seed = random_seed; + /* When the driver passed in a hex number don't crc it again */ + random_seed = strtoul (flag_random_seed, &endp, 0); + if (!(endp > flag_random_seed && *endp == 0)) + random_seed = crc32_string (0, flag_random_seed); + } + else if (!random_seed) + random_seed = local_tick ^ getpid (); /* Old racey fallback method */ } -/* Obtain the random_seed string. Unless NOINIT, initialize it if +/* Obtain the random_seed. Unless NOINIT, initialize it if it's not provided in the command line. */ -const char * +HOST_WIDE_INT get_random_seed (bool noinit) { if (!flag_random_seed && !noinit) init_random_seed (); - return flag_random_seed; + return random_seed; } /* Modify the random_seed string to VAL. Return its previous @@ -575,40 +592,45 @@ compile_file (void) return; } - varpool_assemble_pending_decls (); - finish_aliases_2 (); + /* Compilation unit is finalized. When producing non-fat LTO object, we are + basically finished. */ + if (in_lto_p || !flag_lto || flag_fat_lto_objects) + { + varpool_assemble_pending_decls (); + finish_aliases_2 (); - /* Likewise for mudflap static object registrations. */ - if (flag_mudflap) - mudflap_finish_file (); + /* Likewise for mudflap static object registrations. */ + if (flag_mudflap) + mudflap_finish_file (); - output_shared_constant_pool (); - output_object_blocks (); + output_shared_constant_pool (); + output_object_blocks (); - /* Write out any pending weak symbol declarations. */ - weak_finish (); + /* Write out any pending weak symbol declarations. */ + weak_finish (); - /* This must be at the end before unwind and debug info. - Some target ports emit PIC setup thunks here. */ - targetm.asm_out.code_end (); + /* This must be at the end before unwind and debug info. + Some target ports emit PIC setup thunks here. */ + targetm.asm_out.code_end (); - /* Do dbx symbols. */ - timevar_push (TV_SYMOUT); + /* Do dbx symbols. */ + timevar_push (TV_SYMOUT); -#if defined DWARF2_DEBUGGING_INFO || defined DWARF2_UNWIND_INFO - if (dwarf2out_do_frame ()) - dwarf2out_frame_finish (); -#endif + #if defined DWARF2_DEBUGGING_INFO || defined DWARF2_UNWIND_INFO + if (dwarf2out_do_frame ()) + dwarf2out_frame_finish (); + #endif - (*debug_hooks->finish) (main_input_filename); - timevar_pop (TV_SYMOUT); + (*debug_hooks->finish) (main_input_filename); + timevar_pop (TV_SYMOUT); - /* Output some stuff at end of file if nec. */ + /* Output some stuff at end of file if nec. */ - dw2_output_indirect_constants (); + dw2_output_indirect_constants (); - /* Flush any pending external directives. */ - process_pending_assemble_externals (); + /* Flush any pending external directives. */ + process_pending_assemble_externals (); + } /* Emit LTO marker if LTO info has been previously emitted. This is used by collect2 to determine whether an object file contains IL. @@ -629,6 +651,23 @@ compile_file (void) (unsigned HOST_WIDE_INT) 1, (unsigned HOST_WIDE_INT) 1); #endif + /* Let linker plugin know that this is a slim object and must be LTOed + even when user did not ask for it. */ + if (!flag_fat_lto_objects) + { +#if defined ASM_OUTPUT_ALIGNED_DECL_COMMON + ASM_OUTPUT_ALIGNED_DECL_COMMON (asm_out_file, NULL_TREE, + "__gnu_slim_lto", + (unsigned HOST_WIDE_INT) 1, 8); +#elif defined ASM_OUTPUT_ALIGNED_COMMON + ASM_OUTPUT_ALIGNED_COMMON (asm_out_file, "__gnu_slim_lto", + (unsigned HOST_WIDE_INT) 1, 8); +#else + ASM_OUTPUT_COMMON (asm_out_file, "__gnu_slim_lto", + (unsigned HOST_WIDE_INT) 1, + (unsigned HOST_WIDE_INT) 1); +#endif + } } /* Attach a special .ident directive to the end of the file to identify |