[rb-general] Compiling temporary files with gcc (OCaml compilation)

Sylvain beuc at beuc.net
Wed Jun 20 15:59:55 CEST 2018


Thanks for the tip, I wish somebody told me earlier!

|$ (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|

- Sylvain

On 20/06/2018 15:05, Jeremie Dimino wrote:
> 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 <jdimino at janestreet.com> wrote:
>> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.reproducible-builds.org/pipermail/rb-general/attachments/20180620/aea7f4e3/attachment.html>


More information about the rb-general mailing list