Using -frandom-seed=0 for reproducible builds?

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

 



Hello,

I noticed that the coverage and profiling instrumentation needs the -frandom-seed flag to be reproducible. The documentation

https://gcc.gnu.org/onlinedocs/gcc/Developer-Options.html#index-frandom-seed

says:

    The string should be different for every file you compile.

Searching the internet suggests that using -frandom-seed=0 is not unusual. Why should the string be different for every file you compile? Or, what could happen if two files use the same random seed?

It seems the random seed is only used in two places:

gcc/tree.cc:#include "toplev.h" /* get_random_seed */
gcc/tree.cc:            crc32_string (0, name), get_random_seed (false));

/* Generate a name for a special-purpose function.
   The generated name may need to be unique across the whole link.
   Changes to this function may also require corresponding changes to
   xstrdup_mask_random.
   TYPE is some string to identify the purpose of this function to the
   linker or collect2; it must start with an uppercase letter,
   one of:
   I - for constructors
   D - for destructors
   N - for C++ anonymous namespaces
   F - for DWARF unwind frame information.  */

tree
get_file_function_name (const char *type)

gcc/lto-streamer.cc: sprintf (post, "." HOST_WIDE_INT_PRINT_HEX_PURE, get_random_seed (false));

char *
lto_get_section_name (int section_type, const char *name,
		      int node_order, struct lto_file_decl_data *f)
{
[...]
  /* Make the section name unique so that ld -r combining sections
     doesn't confuse the reader with merged sections.

     For options don't add a ID, the option reader cannot deal with them
     and merging should be ok here. */

I am not sure which bad things happen if some items are not unique across the entire link.

For the coverage profiling, the -frandom-seed flag just results in "local_tick" being -1. The "local_tick" is only used to initialize the random seed and in coverage.cc for a file stamp for notes file.

Would it make sense to add a new option to just control "local_tick" for reproducible coverage instrumentation and don't touch the random seed stuff?

--
embedded brains GmbH & Co. KG
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.huber@xxxxxxxxxxxxxxxxxx
phone: +49-89-18 94 741 - 16
fax:   +49-89-18 94 741 - 08

Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux