<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Thanks for the tip, I wish somebody told me earlier!</p>
<pre><code>$ (cd repro && gcc-6 -g hello.c -o hello && sha256sum hello)
9d41920af912b8d1810f75940489ee99b6e6712788b5a54e1d1829fe84e7ed96 hello
$ (cd repro-b && gcc-6 -g hello.c -o hello && sha256sum hello)
bb99335f4d2242506b75f1f8d437d9b85877cf42c4cbf734ed5eca0b73f7ace0 hello
$ (cd repro && gcc-6 -fdebug-prefix-map=$(pwd)=/ -g hello.c -o hello && sha256sum hello)
fbdf49c11b4b4138bff7fb2cacaa5304690bfa748d4455dc67585cf4325eed06 hello
$ (cd repro-b && gcc-6 -fdebug-prefix-map=$(pwd)=/ -g hello.c -o hello && sha256sum hello)
fbdf49c11b4b4138bff7fb2cacaa5304690bfa748d4455dc67585cf4325eed06 hello</code></pre>
<p>- Sylvain<br>
</p>
On 20/06/2018 15:05, Jeremie Dimino wrote:<br>
<blockquote type="cite"
cite="mid:CANhEzE7mxO_pd3nc5ku8KXaYmEM0hKSH9zDhDqbYJpPOmaSLxg@mail.gmail.com">
<pre wrap="">We just found -fdebug-prefix-map which seems to do what we want for
both gcc and clang.
On Wed, Jun 20, 2018 at 11:39 AM Jeremie Dimino <a class="moz-txt-link-rfc2396E" href="mailto:jdimino@janestreet.com"><jdimino@janestreet.com></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">We just started to look at reproducible builds at my company in order
to support cloud builds. We use OCaml extensively and we hit a few
cases where the artefacts produced by the OCaml compiler are not
reproducible, so we are working on fixing these.
We found a problem that is more related to C than OCaml, so I was
hopping that someone on this list already had a similar issue in the
past and could point us in the right direction.
The problem is the following: in some cases, the OCaml compiler
generates a temporary C file that is immediately compiled, linked into
the executable being produced and deleted. The C compilers keeps the
name of the C file in the object file and since this name is random
the build is not reproducible.
It seems that gcc only stores the basename in the object file, so we
could effectively use a temporary directory rather than a temporary
file to solve this issue. However it feels a bit fragile. In
particular other C compilers might store more that just the basename
and even gcc might change in the future.
Has anyone had a similar issue in the past?
Many thanks
</pre>
</blockquote>
</blockquote>
</body>
</html>