Skip to content

Update systemlib generation to support precompiled systemlibs #9619

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ install_manifest.txt
/hphp/hack/test/.mypy_cache
/hphp/util/generated-hhjs-babel-transform.txt

# Generated core systemlib
/hphp/runtime/ext/core/ext_core.php

# CPack
CPackConfig.cmake
CPackSourceConfig.cmake
Expand Down
36 changes: 27 additions & 9 deletions CMake/HPHPFunctions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,6 @@ function(append_systemlib TARGET SOURCE SECTNAME)
else()
set(${TARGET}_SLIBS ${${TARGET}_SLIBS} "--add-section" "${SECTNAME}=${SOURCE}" PARENT_SCOPE)
endif()
# Add the systemlib file to the "LINK_DEPENDS" for the systemlib, this will cause it
# to be relinked and the systemlib re-embedded
set_property(TARGET ${TARGET} APPEND PROPERTY LINK_DEPENDS ${SOURCE})
endif()
endfunction(append_systemlib)

Expand Down Expand Up @@ -186,10 +183,10 @@ function(embed_sections TARGET DEST)
endfunction(embed_sections)

macro(embed_systemlib_byname TARGET SLIB)
get_filename_component(SLIB_BN ${SLIB} "NAME_WE")
string(LENGTH ${SLIB_BN} SLIB_BN_LEN)
math(EXPR SLIB_BN_REL_LEN "${SLIB_BN_LEN} - 4")
string(SUBSTRING ${SLIB_BN} 4 ${SLIB_BN_REL_LEN} SLIB_EXTNAME)
get_filename_component(SLIB_FILENAME ${SLIB} "NAME")

set(SLIB_EXTNAME "/:${SLIB_FILENAME}")

string(MD5 SLIB_HASH_NAME ${SLIB_EXTNAME})
# Some platforms limit section names to 16 characters :(
string(SUBSTRING ${SLIB_HASH_NAME} 0 12 SLIB_HASH_NAME_SHORT)
Expand All @@ -204,10 +201,31 @@ endmacro()

function(embed_all_systemlibs TARGET ROOT DEST)
add_dependencies(${TARGET} systemlib)
append_systemlib(${TARGET} ${ROOT}/system/systemlib.php systemlib)

foreach(SLIB ${EXTENSION_SYSTEMLIB_SOURCES} ${EZC_SYSTEMLIB_SOURCES})
embed_systemlib_byname(${TARGET} ${SLIB})
get_filename_component(SLIB_FILENAME ${SLIB} NAME)
file(RELATIVE_PATH SLIB_RELATIVE_PATH ${CMAKE_SOURCE_DIR} ${SLIB})
list(APPEND SLIB_RELATIVE_PATHS ${SLIB_RELATIVE_PATH})
list(
APPEND PRECOMPILED_SYSTEMLIB_FILES
${CMAKE_CURRENT_BINARY_DIR}/slib/${SLIB_FILENAME}.decls
${CMAKE_CURRENT_BINARY_DIR}/slib/${SLIB_FILENAME}.ue
)
endforeach()

add_custom_command(
TARGET ${TARGET} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/slib
COMMAND $<TARGET_FILE:hhvm> --compile-systemlib --input-dir ${CMAKE_SOURCE_DIR} --output-dir ${CMAKE_CURRENT_BINARY_DIR}/slib ${SLIB_RELATIVE_PATHS}
DEPENDS ${EXTENSION_SYSTEMLIB_SOURCES} ${EZC_SYSTEMLIB_SOURCES}
COMMENT "Precompiling systemlib files"
VERBATIM)

foreach(PRECOMPILED_SLIB ${PRECOMPILED_SYSTEMLIB_FILES})
get_filename_component(PRECOMPILED_SLIB_FILENAME ${PRECOMPILED_SLIB} NAME)
embed_systemlib_byname(${TARGET} ${PRECOMPILED_SLIB})
endforeach()

embed_sections(${TARGET} ${DEST})
endfunction(embed_all_systemlibs)

Expand Down
2 changes: 1 addition & 1 deletion hphp/compiler/compiler-systemlib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ bool process(CompilerOptions &po) {

for (auto extension : ExtensionRegistry::getExtensions()) {
for (auto file : extension->hackFiles()) {
if (!files.contains(file)) {
if (!files.contains("ext_" + file)) {
Logger::Error(
"Error while compiling stdlib: %s not found in input files - did you add an extension without any hack files? If so, override hackFiles to return an empty vector.", file.c_str());
}
Expand Down
2 changes: 1 addition & 1 deletion hphp/runtime/ext/core/make_systemlib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ OUTDIR=$1; shift
OUTFILE=$1; shift
SYSTEMLIB="${OUTDIR}/${OUTFILE}"

mkdir "${OUTDIR}"
mkdir -p "${OUTDIR}"

# If we put the line we're generating into this file, then the linter will think
# the generator itself is generated. Encode it into a variable for safe
Expand Down
296 changes: 148 additions & 148 deletions hphp/runtime/ext/core/php.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,158 +6,158 @@
# These restrictions may be lifted at some point in the future.

# Order matters here. Put parent classes in this list before child classes
hphp/system/php/lang/stdClass.php
hphp/system/php/lang/Closure.php
hphp/system/php/lang/pinitSentinel.php
hphp/system/php/lang/uninitSentinel.php
hphp/system/php/lang/string.php
hphp/system/php/lang/resource.php

hphp/system/php/lang/AsyncIterator.ns.php
hphp/system/php/lang/AsyncKeyedIterator.ns.php
hphp/system/php/lang/Traversable.ns.php
hphp/system/php/lang/Iterator.ns.php
hphp/system/php/lang/IteratorAggregate.ns.php
hphp/system/php/lang/KeyedIterator.ns.php
hphp/system/php/lang/KeyedIterable.ns.php
hphp/system/php/lang/Throwable.php
hphp/system/php/lang/BaseException.ns.php
hphp/system/php/lang/Error.php
hphp/system/php/lang/Exception.php
hphp/system/php/spl/exceptions/exceptions.php
hphp/system/php/spl/interfaces/Countable.php
hphp/system/php/spl/interfaces/RecursiveIterator.php

hphp/system/php/lang/Container.ns.php

hphp/system/php/spl/datastructures/SplHeap.php

hphp/system/php/spl/file_handling/SplFileInfo.php
hphp/system/php/spl/interfaces/SeekableIterator.php
hphp/system/php/spl/iterators/DirectoryIterator.php
hphp/system/php/spl/iterators/FilesystemIterator.php
hphp/system/php/spl/iterators/GlobIterator.php
hphp/system/php/spl/iterators/RecursiveDirectoryIterator.php
hphp/system/php/spl/file_handling/SplFileObject.php
hphp/system/php/spl/file_handling/SplTempFileObject.php

hphp/system/php/lang/ArrayAccess.php
hphp/system/php/lang/Serializeable.php
hphp/system/php/spl/datastructures/SplDoublyLinkedList.php
hphp/system/php/spl/datastructures/SplQueue.php
hphp/system/php/spl/datastructures/SplStack.php

hphp/system/php/spl/interfaces/OuterIterator.php
hphp/system/php/spl/iterators/IteratorIterator.php
hphp/system/php/spl/iterators/FilterIterator.php
hphp/system/php/spl/iterators/RecursiveFilterIterator.php
hphp/system/php/spl/iterators/RegexIterator.php
hphp/system/php/spl/iterators/RecursiveRegexIterator.php

hphp/system/php/spl/iterators/ArrayIterator.php

hphp/system/php/filter/filter_var_array.php

hphp/system/php/date/datetimeinterface.php
hphp/system/php/date/datetimeimmutable.php

hphp/system/php/collections/collection_interfaces.ns.php
hphp/system/php/collections/LazyConcatIterable.php
hphp/system/php/collections/LazyConcatIterator.php
hphp/system/php/collections/LazyFilterIterable.php
hphp/system/php/collections/LazyFilterIterator.php
hphp/system/php/collections/LazyFilterKeyedIterable.php
hphp/system/php/collections/LazyFilterKeyedIterator.php
hphp/system/php/collections/LazyFilterWithKeyIterable.php
hphp/system/php/collections/LazyFilterWithKeyIterator.php
hphp/system/php/collections/LazyIterable.php
hphp/system/php/collections/LazyIterableView.php
hphp/system/php/collections/LazyKVZipIterable.php
hphp/system/php/collections/LazyKVZipIterator.php
hphp/system/php/collections/LazyKeyedIterable.php
hphp/system/php/collections/LazyKeyedIterableView.php
hphp/system/php/collections/LazyKeysIterable.php
hphp/system/php/collections/LazyKeysIterator.php
hphp/system/php/collections/LazyMapIterable.php
hphp/system/php/collections/LazyMapIterator.php
hphp/system/php/collections/LazyMapKeyedIterable.php
hphp/system/php/collections/LazyMapKeyedIterator.php
hphp/system/php/collections/LazyMapWithKeyIterable.php
hphp/system/php/collections/LazyMapWithKeyIterator.php
hphp/system/php/collections/LazySkipIterable.php
hphp/system/php/collections/LazySkipIterator.php
hphp/system/php/collections/LazySkipKeyedIterable.php
hphp/system/php/collections/LazySkipKeyedIterator.php
hphp/system/php/collections/LazySkipWhileIterable.php
hphp/system/php/collections/LazySkipWhileIterator.php
hphp/system/php/collections/LazySkipWhileKeyedIterable.php
hphp/system/php/collections/LazySkipWhileKeyedIterator.php
hphp/system/php/collections/LazySliceIterable.php
hphp/system/php/collections/LazySliceIterator.php
hphp/system/php/collections/LazySliceKeyedIterable.php
hphp/system/php/collections/LazySliceKeyedIterator.php
hphp/system/php/collections/LazyTakeIterable.php
hphp/system/php/collections/LazyTakeIterator.php
hphp/system/php/collections/LazyTakeKeyedIterable.php
hphp/system/php/collections/LazyTakeKeyedIterator.php
hphp/system/php/collections/LazyTakeWhileIterable.php
hphp/system/php/collections/LazyTakeWhileIterator.php
hphp/system/php/collections/LazyTakeWhileKeyedIterable.php
hphp/system/php/collections/LazyTakeWhileKeyedIterator.php
hphp/system/php/collections/LazyValuesIterable.php
hphp/system/php/collections/LazyValuesIterator.php
hphp/system/php/collections/LazyZipIterable.php
hphp/system/php/collections/LazyZipIterator.php
hphp/system/php/collections/LazyZipKeyedIterable.php
hphp/system/php/collections/LazyZipKeyedIterator.php
hphp/system/php/collections/StrictIterable.php
hphp/system/php/collections/StrictKeyedIterable.php

hphp/system/php/async/ResultOrExceptionWrapper.ns.php
hphp/system/php/async/WrappedException.ns.php
hphp/system/php/async/WrappedResult.ns.php
hphp/system/php/async/convenience.ns.php

hphp/system/php/async/vm.ns.php
hphp/system/php/async/maps.ns.php
hphp/system/php/async/vectors.ns.php
hphp/runtime/ext/core/php/lang/stdClass.php
hphp/runtime/ext/core/php/lang/Closure.php
hphp/runtime/ext/core/php/lang/pinitSentinel.php
hphp/runtime/ext/core/php/lang/uninitSentinel.php
hphp/runtime/ext/core/php/lang/string.php
hphp/runtime/ext/core/php/lang/resource.php

hphp/runtime/ext/core/php/lang/AsyncIterator.ns.php
hphp/runtime/ext/core/php/lang/AsyncKeyedIterator.ns.php
hphp/runtime/ext/core/php/lang/Traversable.ns.php
hphp/runtime/ext/core/php/lang/Iterator.ns.php
hphp/runtime/ext/core/php/lang/IteratorAggregate.ns.php
hphp/runtime/ext/core/php/lang/KeyedIterator.ns.php
hphp/runtime/ext/core/php/lang/KeyedIterable.ns.php
hphp/runtime/ext/core/php/lang/Throwable.php
hphp/runtime/ext/core/php/lang/BaseException.ns.php
hphp/runtime/ext/core/php/lang/Error.php
hphp/runtime/ext/core/php/lang/Exception.php
hphp/runtime/ext/core/php/spl/exceptions/exceptions.php
hphp/runtime/ext/core/php/spl/interfaces/Countable.php
hphp/runtime/ext/core/php/spl/interfaces/RecursiveIterator.php

hphp/runtime/ext/core/php/lang/Container.ns.php

hphp/runtime/ext/core/php/spl/datastructures/SplHeap.php

hphp/runtime/ext/core/php/spl/file_handling/SplFileInfo.php
hphp/runtime/ext/core/php/spl/interfaces/SeekableIterator.php
hphp/runtime/ext/core/php/spl/iterators/DirectoryIterator.php
hphp/runtime/ext/core/php/spl/iterators/FilesystemIterator.php
hphp/runtime/ext/core/php/spl/iterators/GlobIterator.php
hphp/runtime/ext/core/php/spl/iterators/RecursiveDirectoryIterator.php
hphp/runtime/ext/core/php/spl/file_handling/SplFileObject.php
hphp/runtime/ext/core/php/spl/file_handling/SplTempFileObject.php

hphp/runtime/ext/core/php/lang/ArrayAccess.php
hphp/runtime/ext/core/php/lang/Serializeable.php
hphp/runtime/ext/core/php/spl/datastructures/SplDoublyLinkedList.php
hphp/runtime/ext/core/php/spl/datastructures/SplQueue.php
hphp/runtime/ext/core/php/spl/datastructures/SplStack.php

hphp/runtime/ext/core/php/spl/interfaces/OuterIterator.php
hphp/runtime/ext/core/php/spl/iterators/IteratorIterator.php
hphp/runtime/ext/core/php/spl/iterators/FilterIterator.php
hphp/runtime/ext/core/php/spl/iterators/RecursiveFilterIterator.php
hphp/runtime/ext/core/php/spl/iterators/RegexIterator.php
hphp/runtime/ext/core/php/spl/iterators/RecursiveRegexIterator.php

hphp/runtime/ext/core/php/spl/iterators/ArrayIterator.php

hphp/runtime/ext/core/php/filter/filter_var_array.php

hphp/runtime/ext/core/php/date/datetimeinterface.php
hphp/runtime/ext/core/php/date/datetimeimmutable.php

hphp/runtime/ext/core/php/collections/collection_interfaces.ns.php
hphp/runtime/ext/core/php/collections/LazyConcatIterable.php
hphp/runtime/ext/core/php/collections/LazyConcatIterator.php
hphp/runtime/ext/core/php/collections/LazyFilterIterable.php
hphp/runtime/ext/core/php/collections/LazyFilterIterator.php
hphp/runtime/ext/core/php/collections/LazyFilterKeyedIterable.php
hphp/runtime/ext/core/php/collections/LazyFilterKeyedIterator.php
hphp/runtime/ext/core/php/collections/LazyFilterWithKeyIterable.php
hphp/runtime/ext/core/php/collections/LazyFilterWithKeyIterator.php
hphp/runtime/ext/core/php/collections/LazyIterable.php
hphp/runtime/ext/core/php/collections/LazyIterableView.php
hphp/runtime/ext/core/php/collections/LazyKVZipIterable.php
hphp/runtime/ext/core/php/collections/LazyKVZipIterator.php
hphp/runtime/ext/core/php/collections/LazyKeyedIterable.php
hphp/runtime/ext/core/php/collections/LazyKeyedIterableView.php
hphp/runtime/ext/core/php/collections/LazyKeysIterable.php
hphp/runtime/ext/core/php/collections/LazyKeysIterator.php
hphp/runtime/ext/core/php/collections/LazyMapIterable.php
hphp/runtime/ext/core/php/collections/LazyMapIterator.php
hphp/runtime/ext/core/php/collections/LazyMapKeyedIterable.php
hphp/runtime/ext/core/php/collections/LazyMapKeyedIterator.php
hphp/runtime/ext/core/php/collections/LazyMapWithKeyIterable.php
hphp/runtime/ext/core/php/collections/LazyMapWithKeyIterator.php
hphp/runtime/ext/core/php/collections/LazySkipIterable.php
hphp/runtime/ext/core/php/collections/LazySkipIterator.php
hphp/runtime/ext/core/php/collections/LazySkipKeyedIterable.php
hphp/runtime/ext/core/php/collections/LazySkipKeyedIterator.php
hphp/runtime/ext/core/php/collections/LazySkipWhileIterable.php
hphp/runtime/ext/core/php/collections/LazySkipWhileIterator.php
hphp/runtime/ext/core/php/collections/LazySkipWhileKeyedIterable.php
hphp/runtime/ext/core/php/collections/LazySkipWhileKeyedIterator.php
hphp/runtime/ext/core/php/collections/LazySliceIterable.php
hphp/runtime/ext/core/php/collections/LazySliceIterator.php
hphp/runtime/ext/core/php/collections/LazySliceKeyedIterable.php
hphp/runtime/ext/core/php/collections/LazySliceKeyedIterator.php
hphp/runtime/ext/core/php/collections/LazyTakeIterable.php
hphp/runtime/ext/core/php/collections/LazyTakeIterator.php
hphp/runtime/ext/core/php/collections/LazyTakeKeyedIterable.php
hphp/runtime/ext/core/php/collections/LazyTakeKeyedIterator.php
hphp/runtime/ext/core/php/collections/LazyTakeWhileIterable.php
hphp/runtime/ext/core/php/collections/LazyTakeWhileIterator.php
hphp/runtime/ext/core/php/collections/LazyTakeWhileKeyedIterable.php
hphp/runtime/ext/core/php/collections/LazyTakeWhileKeyedIterator.php
hphp/runtime/ext/core/php/collections/LazyValuesIterable.php
hphp/runtime/ext/core/php/collections/LazyValuesIterator.php
hphp/runtime/ext/core/php/collections/LazyZipIterable.php
hphp/runtime/ext/core/php/collections/LazyZipIterator.php
hphp/runtime/ext/core/php/collections/LazyZipKeyedIterable.php
hphp/runtime/ext/core/php/collections/LazyZipKeyedIterator.php
hphp/runtime/ext/core/php/collections/StrictIterable.php
hphp/runtime/ext/core/php/collections/StrictKeyedIterable.php

hphp/runtime/ext/core/php/async/ResultOrExceptionWrapper.ns.php
hphp/runtime/ext/core/php/async/WrappedException.ns.php
hphp/runtime/ext/core/php/async/WrappedResult.ns.php
hphp/runtime/ext/core/php/async/convenience.ns.php

hphp/runtime/ext/core/php/async/vm.ns.php
hphp/runtime/ext/core/php/async/maps.ns.php
hphp/runtime/ext/core/php/async/vectors.ns.php

# If you have no inheritance relationship, go here in alphabetical order
hphp/system/php/array_filter.php
hphp/system/php/array_map.php
hphp/system/php/array_reduce.php
hphp/system/php/asio/InvalidOperationException.php
hphp/system/php/async/EntryPoint.ns.php
hphp/system/php/curl/CURLFile.php
hphp/system/php/date/dateperiod.php
hphp/system/php/date/datetime_funcs.php
hphp/system/php/dom/DOMException.php
hphp/system/php/file_system/Directory.php
hphp/system/php/lang/Disposable.php
hphp/system/php/lang/ErrorException.php
hphp/system/php/lang/fun.ns.php
hphp/system/php/lang/invariant.ns.php
hphp/system/php/lang/null.ns.php
hphp/system/php/lang/readonly.ns.php
hphp/system/php/misc/idx.php
hphp/system/php/pdo/PDOException.php
hphp/system/php/rx/mutable.php
hphp/system/php/shapes/ext_shapes.php
hphp/system/php/soap/SoapFault.php
hphp/system/php/spl/datastructures/SplPriorityQueue.php
hphp/system/php/spl/interfaces/SplObserver.php
hphp/system/php/spl/interfaces/SplSubject.php
hphp/system/php/spl/iterators/EmptyIterator.php
hphp/system/php/spl/iterators/InfiniteIterator.php
hphp/system/php/spl/iterators/NoRewindIterator.php
hphp/system/php/spl/iterators/RecursiveIteratorIterator.php
hphp/system/php/experimental_parser_utils.php
hphp/runtime/ext/core/php/array_filter.php
hphp/runtime/ext/core/php/array_map.php
hphp/runtime/ext/core/php/array_reduce.php
hphp/runtime/ext/core/php/asio/InvalidOperationException.php
hphp/runtime/ext/core/php/async/EntryPoint.ns.php
hphp/runtime/ext/core/php/curl/CURLFile.php
hphp/runtime/ext/core/php/date/dateperiod.php
hphp/runtime/ext/core/php/date/datetime_funcs.php
hphp/runtime/ext/core/php/dom/DOMException.php
hphp/runtime/ext/core/php/file_system/Directory.php
hphp/runtime/ext/core/php/lang/Disposable.php
hphp/runtime/ext/core/php/lang/ErrorException.php
hphp/runtime/ext/core/php/lang/fun.ns.php
hphp/runtime/ext/core/php/lang/invariant.ns.php
hphp/runtime/ext/core/php/lang/null.ns.php
hphp/runtime/ext/core/php/lang/readonly.ns.php
hphp/runtime/ext/core/php/misc/idx.php
hphp/runtime/ext/core/php/pdo/PDOException.php
hphp/runtime/ext/core/php/rx/mutable.php
hphp/runtime/ext/core/php/shapes/ext_shapes.php
hphp/runtime/ext/core/php/soap/SoapFault.php
hphp/runtime/ext/core/php/spl/datastructures/SplPriorityQueue.php
hphp/runtime/ext/core/php/spl/interfaces/SplObserver.php
hphp/runtime/ext/core/php/spl/interfaces/SplSubject.php
hphp/runtime/ext/core/php/spl/iterators/EmptyIterator.php
hphp/runtime/ext/core/php/spl/iterators/InfiniteIterator.php
hphp/runtime/ext/core/php/spl/iterators/NoRewindIterator.php
hphp/runtime/ext/core/php/spl/iterators/RecursiveIteratorIterator.php
hphp/runtime/ext/core/php/experimental_parser_utils.php

# This provides a temporary workaround for renamed lz4 methods
hphp/system/php/zlib/ext_zlib.php
hphp/runtime/ext/core/php/zlib/ext_zlib.php

hphp/system/php/member_of.ns.php
hphp/runtime/ext/core/php/member_of.ns.php

hphp/system/php/attributes.php
hphp/runtime/ext/core/php/attributes.php

hphp/system/php/password/password.php
hphp/runtime/ext/core/php/password/password.php
Loading