Community
cancel
Showing results for 
Search instead for 
Did you mean: 
liu__peter
Beginner
248 Views

deterministic build problem

deterministic means when you compile for multiple times, the output produced should be identical. gcc supports option -frandom-seed, which is useful in making deterministic build. icc doesn't have such things? is there a way to make icc generate deterministic binary?
0 Kudos
4 Replies
MGRAV
New Contributor I
248 Views

Hi,

 

I suppose you have thousands of possibilities to do that. I don't know what -frandom-seed exactly do, but definitely it's much better to use c++11 random functions. And init the random generator with the seed of your choice.

To solve your situation you can (what I usually do) set the seed as a parameter at execution time.

If you still want to have it at compilation time, you can easily use MY_SEED in the code and add in the compilation command -DMY_SEED=your_favorite_seed_value.

liu__peter
Beginner
248 Views

@ Mathieu Gravey Take a look at https://reproducible-builds.org/ to see the problem background. The random seed is internally used in compiler to give a random name for functions in anonymous namespace. It has NOTING to do with my code logic. The below code is taken from gcc: /* Generate a name for a function unique to this translation unit. TYPE is some string to identify the purpose of this function to the linker or collect2. */ tree get_file_function_name_long (const char *type) { ... /* We don't have anything that we know to be unique to this translation unit, so use what we do have and throw in some randomness. */ ... sprintf (q + len, "_%08X_%08X", crc32_string (0, name), crc32_string (0, flag_random_seed)); So you have an idea how compiler mangle names. My problem is intel C++ compiler support such things that I can use to make a deterministic build?
jimdempseyatthecove
Black Belt
248 Views

Why not use a series of specific name spaces as opposed to letting the compiler generate one?

See responses in:
https://stackoverflow.com/questions/154469/unnamed-anonymous-namespaces-vs-static-functions

Jim Dempsey

liu__peter
Beginner
248 Views

@jimdempseyatthecove even there is no anonymous namespaces, there will still be some randomly generated mangled names (e.g. for intel compiler, templates, not a case for gcc). is there a way to tell interl compiler make it deterministic?
Reply