From 4e051c6c15f25b58ee67127a9e4bd5e7a8684fea Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Mon, 18 May 2020 18:58:23 -0600 Subject: [PATCH] Toolchain: Don't pre-build LibC and LibM, nor pre-install their headers We can do away with that shenanigans now that libstdc++ is gone. Also, simplify the toolchain dependency hash calculation to only depend on the toolchain build script(s) and the Patches files we use to modify the toolchain itself. --- Toolchain/BuildIt.sh | 14 ------- Toolchain/ComputeDependenciesHash.sh | 60 +--------------------------- 2 files changed, 2 insertions(+), 72 deletions(-) diff --git a/Toolchain/BuildIt.sh b/Toolchain/BuildIt.sh index b50ed23f22..f37704b96e 100755 --- a/Toolchain/BuildIt.sh +++ b/Toolchain/BuildIt.sh @@ -225,20 +225,6 @@ pushd "$DIR/Build/" echo "XXX install gcc and libgcc" "$MAKE" install-gcc install-target-libgcc || exit 1 - echo "XXX serenity libc and libm" - mkdir -p "$BUILD" - pushd "$BUILD" - cmake .. - "$MAKE" LibC - install -D Libraries/LibC/libc.a Libraries/LibM/libm.a Libraries/LibCxx/libstdc++.a Root/usr/lib/ - SRC_ROOT=$(realpath "$DIR"/..) - for header in "$SRC_ROOT"/Libraries/Lib{C,M}/**/*.h; do - target=$(echo "$header" | sed -e "s@$SRC_ROOT/Libraries/LibC@@" -e "s@$SRC_ROOT/Libraries/LibM@@") - install -D "$header" "Root/usr/include/$target" - done - unset SRC_ROOT - popd - if [ "$(uname -s)" = "OpenBSD" ]; then cd "$DIR/Local/libexec/gcc/i686-pc-serenity/$GCC_VERSION" && ln -sf liblto_plugin.so.0.0 liblto_plugin.so fi diff --git a/Toolchain/ComputeDependenciesHash.sh b/Toolchain/ComputeDependenciesHash.sh index 0da2cf2a76..c6cb714e2b 100755 --- a/Toolchain/ComputeDependenciesHash.sh +++ b/Toolchain/ComputeDependenciesHash.sh @@ -23,67 +23,11 @@ function finish { } trap finish EXIT -# libstdc++ depends on libc and libm, so we pessimistically assume it depends -# on *all* of their implementation and recursive dependencies. -# Scan all files for potential dependencies. -# Thinking in graphs, this computes the edge list: -cat <(find AK/ Libraries/ Services/ Kernel/ -name '*.h') \ - <(find Libraries/LibC/ Libraries/LibM/ -name '*.cpp' ! -name 'Test*.cpp' ) | \ - xargs grep -F '#include ' | \ - sed -r \ - -e 's,^(.*/)([^/]+:)#include "(.*)",\1\2\1\3,' \ - -e 's^#include <(Kernel/.*)>^\1^' \ - -e 's^#include <(AK/.*)>^\1^' \ - -e 's^#include <(Lib[A-Za-z]+/.*)>^Libraries/\1^' \ - -e 's^#include <((bits|netinet|sys|arpa|net)/.*)>^Libraries/LibC/\1^' \ - -e 's^#include ^Libraries/LibC/fd_set.h^' \ - -e 's^#include <([a-z]{3,10}(_numbers)?\.h)>^Libraries/LibC/\1^' \ - -e 's^#include <([A-Z][a-z]+Server/.*)>^Services/\1^' \ - -e 's^#include <(.*)>^UNRESOLVED_I/\1^' \ - -e 's^#include "(.*)"^UNRESOLVED_L/\1^' > "${DEPLIST_FILE}" -# Some #include's cannot be resolved, like . However, these are only -# a problem if they turn up as a transitive dependency of libc and libm. -# We will check for that when the time comes. - -# The initial guess is pessimistic: *all* of libc and libm. -FILE_LIST=$(find Libraries/LibC/ Libraries/LibM/ \( -name '*.cpp' -o -name '*.c' -o -name '*.h' \) ! -name 'Test*') -echo "$0: Exploring dependencies of libstdc++" >&2 -FILE_LIST_COMPLETE="n" -# In each iteration, we extend FILE_LIST by the dependencies not listed yet in -# FILE_LIST. Note that the results are always semantically the same, -# but the order depends on the initial `find` runs. -for _ in $(seq 10) ; do - FILE_REGEX=$(echo "${FILE_LIST}" | sed -zr -e 's,\n$,,' -e 's,\.,\\.,g' -e 's,\n,|,g') - FURTHER_FILE_LIST=$(grep -P "^(${FILE_REGEX}):" "${DEPLIST_FILE}" | grep -Pv ":(${FILE_REGEX})\$" | sed -re 's,^.*:(.*)$,\1,' | sort -u) - if [ -n "${FURTHER_FILE_LIST}" ] ; then - # FILE_LIST should grow to a maximum of "number of all .cpp and .c and .h files", - # i.e. roughly 700 lines. This should be managable, even as the project grows. - FILE_LIST="${FILE_LIST} -${FURTHER_FILE_LIST}" - else - FILE_LIST_COMPLETE="y" - break - fi -done -FURTHER_FILE_LIST="" -FILE_REGEX="" -if [ "${FILE_LIST_COMPLETE}" != "y" ] ; then - # Dependency chains might grow very long. Also, if for some reason we fail - # to filter out the already listed files, the FILE_LIST would grow - # exponentially. Both of these unpleasant cases are handled by capping the - # iteration count to 10 and giving up: - echo "$0: Dependencies don't seem to converge, giving up." >&2 - exit 1 -fi +# Patches and the scripts are the only things that affect the build of the toolchain +FILE_LIST=$(find Toolchain/Patches -name "*.patch") # Sort for reproducability, FILE_LIST=$(echo "${FILE_LIST}" | LC_ALL=C sort -u) -if grep -F 'UNRESOLVED' <&2 ; then -${FILE_LIST} -EOLIST - echo "$0: Unresolved dependency, giving up." - exit 1 -fi echo "$0: Computing hashes" >&2 # "$@" is the md5sum invocation. The piping might hide non-zero exit-codes,