<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>252308</bug_id>
          
          <creation_ts>2023-02-15 03:02:37 -0800</creation_ts>
          <short_desc>REGRESSION(256816@main): [CMake] Build not reproducible due to __TIMESTAMP__ macro in generated file</short_desc>
          <delta_ts>2023-08-10 14:22:42 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>JavaScriptCore</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>258517</dup_id>
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=247622</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Alberto Garcia">berto</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>alex.kanavin</cc>
    
    <cc>bugs-noreply</cc>
    
    <cc>emw</cc>
    
    <cc>mcatanzaro</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1933771</commentid>
    <comment_count>0</comment_count>
    <who name="Alberto Garcia">berto</who>
    <bug_when>2023-02-15 03:02:37 -0800</bug_when>
    <thetext>The JSCBytecodeCacheVersion.cpp file contains the __TIMESTAMP__ macro
which is replaced by the timestamp of the source file. This macro was
already being used in 2.38.x and earlier versions, but at least
building always from the same source tarball would produce the same
timestamp so it would not affect the reproducibility of the build.

However this is now generated by Source/JavaScriptCore/CMakeLists.txt
so the timestamp varies every time WebKit is compiled from the same
sources, making the build non-reproducible.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1933791</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2023-02-15 06:53:28 -0800</bug_when>
    <thetext>Indeed, __TIMESTAMP__ is only deterministic when the source file is not generated, because it&apos;s based on last modification of the source file. The new comment in JSCBytecodeCacheVersion.h is also wrong except on Apple ports.

The solution here should be to do the same thing Apple does: cat JSCBuiltins.o with CachedTypes.o and then hash that. They also use build version, but I&apos;m not sure why and that can probably be ignored. This would likely be a good newcomers bug as it can be done entirely from CMake with no need to touch the source code files.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1934000</commentid>
    <comment_count>2</comment_count>
    <who name="Elliott Williams">emw</who>
    <bug_when>2023-02-15 16:25:21 -0800</bug_when>
    <thetext>(In reply to Michael Catanzaro from comment #1)
&gt; Indeed, __TIMESTAMP__ is only deterministic when the source file is not
&gt; generated, because it&apos;s based on last modification of the source file. The
&gt; new comment in JSCBytecodeCacheVersion.h is also wrong except on Apple ports.
&gt; 
&gt; The solution here should be to do the same thing Apple does: cat
&gt; JSCBuiltins.o with CachedTypes.o and then hash that.

&gt; They also use build version, but I&apos;m not sure why and that can probably be ignored. 

We did this for extra safety, in case our production build environment was using a cached JSCBuiltins.o and CachedTypes.o *and* there was some binary incompatibility elsewhere in JSC.

&gt; This would
&gt; likely be a good newcomers bug as it can be done entirely from CMake with no
&gt; need to touch the source code files.

FWIW, I tried to do the same change in CMake, and got stuck because the generated ninja build doesn&apos;t support inter-dependencies between object files in the same target. But I think we could make CMake hash the modification time relatively easy and restore the old semantics.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1963665</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2023-06-26 13:56:46 -0700</bug_when>
    <thetext>*** Bug 258517 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1963673</commentid>
    <comment_count>4</comment_count>
    <who name="Alexander Kanavin">alex.kanavin</who>
    <bug_when>2023-06-26 14:09:34 -0700</bug_when>
    <thetext>To at least restore the binary reproducibility I made a PR where mtime of the generated file is set to the one it is generated from using &apos;touch -r&apos;:

https://github.com/WebKit/WebKit/pull/15293</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1970579</commentid>
    <comment_count>5</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2023-08-10 14:22:42 -0700</bug_when>
    <thetext>

*** This bug has been marked as a duplicate of bug 258517 ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>