From e64a8751d1ec9fc90e9a14b532278bfc26c0eab2 Mon Sep 17 00:00:00 2001 From: Daniel Bertalan Date: Sat, 15 Jul 2023 13:38:57 +0200 Subject: [PATCH] LibJS: Do not use the `$` special character in file names The dollar sign is a special character in POSIX shells and in the Ninja build file format. If the file name contains a `$`, something goes wrong in the escaping/unescaping of this symbol, and CMake/GCC/Clang generate invalid dependency files where not all instances of `$` are escaped properly. Because of this, Ninja fails to rebuild `$262Object.cpp` if the headers included by it have changed. Stale `$262Object.cpp.o` files have been the cause of mysterious crashes multiple times which only go away after doing a clean build. Let's prevent these from happening again by removing the `$` from the filename. --- Meta/Lagom/Tools/LibJSGCVerifier/src/main.py | 5 +---- Meta/gn/secondary/Userland/Libraries/LibJS/BUILD.gn | 2 +- Userland/Libraries/LibJS/CMakeLists.txt | 2 +- .../LibJS/Contrib/Test262/{$262Object.cpp => 262Object.cpp} | 4 +++- .../LibJS/Contrib/Test262/{$262Object.h => 262Object.h} | 0 Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.cpp | 2 +- Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.h | 2 +- 7 files changed, 8 insertions(+), 9 deletions(-) rename Userland/Libraries/LibJS/Contrib/Test262/{$262Object.cpp => 262Object.cpp} (96%) rename Userland/Libraries/LibJS/Contrib/Test262/{$262Object.h => 262Object.h} (100%) diff --git a/Meta/Lagom/Tools/LibJSGCVerifier/src/main.py b/Meta/Lagom/Tools/LibJSGCVerifier/src/main.py index eb7af18657..e8d1fc2616 100755 --- a/Meta/Lagom/Tools/LibJSGCVerifier/src/main.py +++ b/Meta/Lagom/Tools/LibJSGCVerifier/src/main.py @@ -39,10 +39,7 @@ paths = [] for containing_path in PATHS_TO_SEARCH: for root, dirs, files in os.walk(userland_path / containing_path): for file in files: - # FIXME: The dollar sign in $262Object.cpp gets corrupted in compile_commands.json somehow, and - # ends up as "\\$$262Object.cpp". This results in a clang error, so we just ignore the - # file here - if file.endswith('.cpp') and not file.endswith('262Object.cpp'): + if file.endswith('.cpp'): paths.append(Path(root) / file) diff --git a/Meta/gn/secondary/Userland/Libraries/LibJS/BUILD.gn b/Meta/gn/secondary/Userland/Libraries/LibJS/BUILD.gn index c9c292f84e..51a36febf2 100644 --- a/Meta/gn/secondary/Userland/Libraries/LibJS/BUILD.gn +++ b/Meta/gn/secondary/Userland/Libraries/LibJS/BUILD.gn @@ -36,10 +36,10 @@ shared_library("LibJS") { "Bytecode/RegexTable.cpp", "Bytecode/StringTable.cpp", "Console.cpp", + "Contrib/Test262/262Object.cpp", "Contrib/Test262/AgentObject.cpp", "Contrib/Test262/GlobalObject.cpp", "Contrib/Test262/IsHTMLDDA.cpp", - "Contrib/Test262/\$262Object.cpp", "CyclicModule.cpp", "Heap/BlockAllocator.cpp", "Heap/Cell.cpp", diff --git a/Userland/Libraries/LibJS/CMakeLists.txt b/Userland/Libraries/LibJS/CMakeLists.txt index 0424c367f6..0f249e9f37 100644 --- a/Userland/Libraries/LibJS/CMakeLists.txt +++ b/Userland/Libraries/LibJS/CMakeLists.txt @@ -18,7 +18,7 @@ set(SOURCES Bytecode/RegexTable.cpp Bytecode/StringTable.cpp Console.cpp - Contrib/Test262/$262Object.cpp + Contrib/Test262/262Object.cpp Contrib/Test262/AgentObject.cpp Contrib/Test262/GlobalObject.cpp Contrib/Test262/IsHTMLDDA.cpp diff --git a/Userland/Libraries/LibJS/Contrib/Test262/$262Object.cpp b/Userland/Libraries/LibJS/Contrib/Test262/262Object.cpp similarity index 96% rename from Userland/Libraries/LibJS/Contrib/Test262/$262Object.cpp rename to Userland/Libraries/LibJS/Contrib/Test262/262Object.cpp index 80eaa14ad7..0a00b4e11e 100644 --- a/Userland/Libraries/LibJS/Contrib/Test262/$262Object.cpp +++ b/Userland/Libraries/LibJS/Contrib/Test262/262Object.cpp @@ -5,9 +5,11 @@ * SPDX-License-Identifier: BSD-2-Clause */ +// NOTE: This file is not named $262Object.cpp because dollar signs in file names cause issues with some build tools. + #include #include -#include +#include #include #include #include diff --git a/Userland/Libraries/LibJS/Contrib/Test262/$262Object.h b/Userland/Libraries/LibJS/Contrib/Test262/262Object.h similarity index 100% rename from Userland/Libraries/LibJS/Contrib/Test262/$262Object.h rename to Userland/Libraries/LibJS/Contrib/Test262/262Object.h diff --git a/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.cpp b/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.cpp index 6ea4172847..1e104bf8d8 100644 --- a/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.cpp +++ b/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.cpp @@ -5,7 +5,7 @@ */ #include -#include +#include #include #include #include diff --git a/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.h b/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.h index 80bbc3eb90..11112a7c9a 100644 --- a/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.h +++ b/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include namespace JS::Test262 {