This patch replaces absolute offsets into the input files block with offsets relative to the block start. This makes the whole section "relocatable". I confirmed all other uses of GetCurrentBitNo() are turned into relative offsets before being serialized into the AST file.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang/include/clang/Serialization/ModuleFile.h | ||
---|---|---|
249 | I think it does. We should be able to remove this and always call InputFilesCursor::GetCurrentBitNo() at the start. I implemented it this way because it's consistent with the existing pattern: SLocEntryCursor/SourceManagerBlockStartOffset, MacroCursor/MacroOffsetsBase, DeclsCursor/DeclsBlockStartOffset. LMK if you feel strongly about it and I can look into getting rid of the extra offset base members. | |
clang/lib/Serialization/ASTReader.cpp | ||
5334 | Good point, I'll do that along with initializing the member variable. |
clang/include/clang/Serialization/ModuleFile.h | ||
---|---|---|
249 | Since it's consistent with other uses I'm fine with keeping it as-is for this patch. Would be nice to clean them all up in a follow up, but not required. |
After this change, all libc++ clang_modules_include.gen.py tests started failing on our Linux builders:
Script: -- : 'COMPILED WITH'; /b/s/w/ir/x/w/llvm_build/./bin/clang++ /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/test/libcxx/clang_modules_include.gen.py/algorithm.compile.pass.cpp -pthread --target=aarch64-unknown-linux-gnu -nostdinc++ -I /b/s/w/ir/x/w/llvm_build/include/c++/v1 -I /b/s/w/ir/x/w/llvm_build/include/aarch64-unknown-linux-gnu/c++/v1 -I /b/s/w/ir/x/w/llvm-llvm-project/libcxx/test/support -std=c++26 -Werror -Wall -Wctad-maybe-unsupported -Wextra -Wshadow -Wundef -Wunused-template -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-noexcept-type -Wno-atomic-alignment -Wno-reserved-module-identifier -Wno-user-defined-literals -Wno-tautological-compare -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -Wno-local-type-template-args -Wno-c++11-extensions -Wno-unknown-pragmas -Wno-pass-failed -Wno-mismatched-new-delete -Wno-redundant-move -Wno-self-move -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCPP_ENABLE_EXPERIMENTAL -Werror=thread-safety -Wuser-defined-warnings -fsyntax-only : 'RUN: at line 2'; /b/s/w/ir/x/w/llvm_build/./bin/clang++ /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/test/libcxx/clang_modules_include.gen.py/algorithm.compile.pass.cpp -pthread --target=aarch64-unknown-linux-gnu -nostdinc++ -I /b/s/w/ir/x/w/llvm_build/include/c++/v1 -I /b/s/w/ir/x/w/llvm_build/include/aarch64-unknown-linux-gnu/c++/v1 -I /b/s/w/ir/x/w/llvm-llvm-project/libcxx/test/support -std=c++26 -Werror -Wall -Wctad-maybe-unsupported -Wextra -Wshadow -Wundef -Wunused-template -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-noexcept-type -Wno-atomic-alignment -Wno-reserved-module-identifier -Wno-user-defined-literals -Wno-tautological-compare -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -Wno-local-type-template-args -Wno-c++11-extensions -Wno-unknown-pragmas -Wno-pass-failed -Wno-mismatched-new-delete -Wno-redundant-move -Wno-self-move -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCPP_ENABLE_EXPERIMENTAL -Werror=thread-safety -Wuser-defined-warnings -fmodules -fcxx-modules -fmodules-cache-path=/b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/test/libcxx/clang_modules_include.gen.py/Output/algorithm.compile.pass.cpp.dir/t.tmp -fsyntax-only -- Exit Code: 1 Command Output (stdout): -- $ ":" "COMPILED WITH" $ "/b/s/w/ir/x/w/llvm_build/./bin/clang++" "/b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/test/libcxx/clang_modules_include.gen.py/algorithm.compile.pass.cpp" "-pthread" "--target=aarch64-unknown-linux-gnu" "-nostdinc++" "-I" "/b/s/w/ir/x/w/llvm_build/include/c++/v1" "-I" "/b/s/w/ir/x/w/llvm_build/include/aarch64-unknown-linux-gnu/c++/v1" "-I" "/b/s/w/ir/x/w/llvm-llvm-project/libcxx/test/support" "-std=c++26" "-Werror" "-Wall" "-Wctad-maybe-unsupported" "-Wextra" "-Wshadow" "-Wundef" "-Wunused-template" "-Wno-unused-command-line-argument" "-Wno-attributes" "-Wno-pessimizing-move" "-Wno-noexcept-type" "-Wno-atomic-alignment" "-Wno-reserved-module-identifier" "-Wno-user-defined-literals" "-Wno-tautological-compare" "-Wsign-compare" "-Wunused-variable" "-Wunused-parameter" "-Wunreachable-code" "-Wno-unused-local-typedef" "-Wno-local-type-template-args" "-Wno-c++11-extensions" "-Wno-unknown-pragmas" "-Wno-pass-failed" "-Wno-mismatched-new-delete" "-Wno-redundant-move" "-Wno-self-move" "-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER" "-D_LIBCPP_ENABLE_EXPERIMENTAL" "-Werror=thread-safety" "-Wuser-defined-warnings" "-fsyntax-only" $ ":" "RUN: at line 2" $ "/b/s/w/ir/x/w/llvm_build/./bin/clang++" "/b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/test/libcxx/clang_modules_include.gen.py/algorithm.compile.pass.cpp" "-pthread" "--target=aarch64-unknown-linux-gnu" "-nostdinc++" "-I" "/b/s/w/ir/x/w/llvm_build/include/c++/v1" "-I" "/b/s/w/ir/x/w/llvm_build/include/aarch64-unknown-linux-gnu/c++/v1" "-I" "/b/s/w/ir/x/w/llvm-llvm-project/libcxx/test/support" "-std=c++26" "-Werror" "-Wall" "-Wctad-maybe-unsupported" "-Wextra" "-Wshadow" "-Wundef" "-Wunused-template" "-Wno-unused-command-line-argument" "-Wno-attributes" "-Wno-pessimizing-move" "-Wno-noexcept-type" "-Wno-atomic-alignment" "-Wno-reserved-module-identifier" "-Wno-user-defined-literals" "-Wno-tautological-compare" "-Wsign-compare" "-Wunused-variable" "-Wunused-parameter" "-Wunreachable-code" "-Wno-unused-local-typedef" "-Wno-local-type-template-args" "-Wno-c++11-extensions" "-Wno-unknown-pragmas" "-Wno-pass-failed" "-Wno-mismatched-new-delete" "-Wno-redundant-move" "-Wno-self-move" "-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER" "-D_LIBCPP_ENABLE_EXPERIMENTAL" "-Werror=thread-safety" "-Wuser-defined-warnings" "-fmodules" "-fcxx-modules" "-fmodules-cache-path=/b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/test/libcxx/clang_modules_include.gen.py/Output/algorithm.compile.pass.cpp.dir/t.tmp" "-fsyntax-only" # command stderr: clang++: clang/lib/Serialization/ASTReader.cpp:6515: void clang::ASTReader::ReadPragmaDiagnosticMappings(DiagnosticsEngine &): Assertion `IDAndOffset.second == 0 && "not a start location for a FileID"' failed. While building module 'std_algorithm' imported from /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/test/libcxx/clang_modules_include.gen.py/algorithm.compile.pass.cpp:22: While building module 'std_private_algorithm_adjacent_find' imported from /b/s/w/ir/x/w/llvm_build/include/c++/v1/algorithm:1744: While building module 'std_private_algorithm_iterator_operations' imported from /b/s/w/ir/x/w/llvm_build/include/c++/v1/__algorithm/adjacent_find.h:14: While building module 'std_private_algorithm_ranges_iterator_concept' imported from /b/s/w/ir/x/w/llvm_build/include/c++/v1/__algorithm/iterator_operations.h:13: In file included from <module-includes>:1: /b/s/w/ir/x/w/llvm_build/include/c++/v1/__algorithm/ranges_iterator_concept.h:13:10: fatal error: could not build module 'std_private_iterator_concepts' 13 | #include <__iterator/concepts.h> | ~~~~~~~~^ ...
You can see the full output at https://luci-milo.appspot.com/ui/p/fuchsia/builders/toolchain.ci/clang-linux-arm64/b8771862804321535569/test-results. Would it be possible to revert this change?
Looks like it was D158573 so it should be safe to reland this, sorry about the confusion.
Doesn't InputFilesCursor already know where the input files block starts?