Skip to content

Commit

Permalink
Cherry-pick 266322@main (8e28343). https://bugs.webkit.org/show_bug.c…
Browse files Browse the repository at this point in the history
…gi?id=258517

    Source/JavaScriptCore/CMakeLists.txt: ensure reproducibility of __TIMESTAMP__
    https://bugs.webkit.org/show_bug.cgi?id=258517

    Reviewed by Michael Catanzaro.

    __TIMESTAMP__ refers to mtime of the file that contains it, which is unstable
    and breaks binary reproducibility when the file is generated at build time. To ensure
    this does not happen, mtime should be set from the original file.

    * Source/JavaScriptCore/CMakeLists.txt:

    Canonical link: https://commits.webkit.org/266322@main
  • Loading branch information
Alexander Kanavin authored and mcatanzaro committed Jul 28, 2023
1 parent 988aef0 commit b2b9c98
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions Source/JavaScriptCore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,24 @@ list(APPEND JavaScriptCore_SOURCES
${JavaScriptCore_DERIVED_SOURCES_DIR}/JSCBuiltins.cpp
)

add_custom_command(
OUTPUT ${JavaScriptCore_DERIVED_SOURCES_DIR}/JSCBytecodeCacheVersion.cpp
MAIN_DEPENDENCY ${JAVASCRIPTCORE_DIR}/runtime/JSCBytecodeCacheVersion.cpp.in
COMMAND ${PERL_EXECUTABLE} -pe s/CACHED_TYPES_CKSUM/__TIMESTAMP__/ ${JAVASCRIPTCORE_DIR}/runtime/JSCBytecodeCacheVersion.cpp.in > ${JavaScriptCore_DERIVED_SOURCES_DIR}/JSCBytecodeCacheVersion.cpp
find_program(TOUCH_EXECUTABLE touch)
if (TOUCH_EXECUTABLE)
add_custom_command(
OUTPUT ${JavaScriptCore_DERIVED_SOURCES_DIR}/JSCBytecodeCacheVersion.cpp
MAIN_DEPENDENCY ${JAVASCRIPTCORE_DIR}/runtime/JSCBytecodeCacheVersion.cpp.in
COMMAND ${PERL_EXECUTABLE} -pe s/CACHED_TYPES_CKSUM/__TIMESTAMP__/ ${JAVASCRIPTCORE_DIR}/runtime/JSCBytecodeCacheVersion.cpp.in > ${JavaScriptCore_DERIVED_SOURCES_DIR}/JSCBytecodeCacheVersion.cpp
COMMAND ${TOUCH_EXECUTABLE} -r ${JAVASCRIPTCORE_DIR}/runtime/JSCBytecodeCacheVersion.cpp.in ${JavaScriptCore_DERIVED_SOURCES_DIR}/JSCBytecodeCacheVersion.cpp
VERBATIM
)

)
else ()
message(WARNING "Unable to find touch executable; ${JavaScriptCore_DERIVED_SOURCES_DIR}/JSCBytecodeCacheVersion.cpp is built non-reproducibly from ${JAVASCRIPTCORE_DIR}/runtime/JSCBytecodeCacheVersion.cpp.in")
add_custom_command(
OUTPUT ${JavaScriptCore_DERIVED_SOURCES_DIR}/JSCBytecodeCacheVersion.cpp
MAIN_DEPENDENCY ${JAVASCRIPTCORE_DIR}/runtime/JSCBytecodeCacheVersion.cpp.in
COMMAND ${PERL_EXECUTABLE} -pe s/CACHED_TYPES_CKSUM/__TIMESTAMP__/ ${JAVASCRIPTCORE_DIR}/runtime/JSCBytecodeCacheVersion.cpp.in > ${JavaScriptCore_DERIVED_SOURCES_DIR}/JSCBytecodeCacheVersion.cpp
VERBATIM
)
endif ()

set(JavaScriptCore_FRAMEWORKS
WTF
Expand Down

0 comments on commit b2b9c98

Please sign in to comment.