File tree Expand file tree Collapse file tree 3 files changed +27
-5
lines changed Expand file tree Collapse file tree 3 files changed +27
-5
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,26 @@ load("//swift:rules.bzl", "swift_cc_library")
33swift_cc_library (
44 name = "file" ,
55 srcs = glob (["*.cpp" ]),
6- hdrs = glob (["*.h" ]),
6+ hdrs = glob (["*.h" ]) + [ ":path_hash_workaround" ] ,
77 visibility = ["//swift:__subpackages__" ],
88 deps = ["@picosha2" ],
99)
10+
11+ genrule (
12+ name = "path_hash_workaround" ,
13+ srcs = [
14+ "PathHash.h.workaround" ,
15+ "PathHash.h.fixed" ,
16+ ],
17+ outs = ["PathHash.h" ],
18+ # see if https://cplusplus.github.io/LWG/issue3657 is fixed with the current compiler or not
19+ # if fixed, PathHash.h.workaround will not compile
20+ cmd = "\n " .join ([
21+ "if clang -c -x c++ -std=c++17 -Wno-pragma-once-outside-header \\ " ,
22+ " $(rootpath PathHash.h.workaround) -o /dev/null &> /dev/null; then" ,
23+ " cp $(rootpath PathHash.h.workaround) $@" ,
24+ "else" ,
25+ " cp $(rootpath PathHash.h.fixed) $@" ,
26+ "fi" ,
27+ ]),
28+ )
Original file line number Diff line number Diff line change 1+ #pragma once
2+
3+ #include <filesystem>
4+ #include <functional>
Original file line number Diff line number Diff line change 88// but it works, and this is recognized as a defect of the standard.
99// Using a non-standard Hasher type would be a huge pain, as the automatic hash implementation of
1010// std::variant would not kick in (we use std::filesystem::path in a variant used as a map key).
11- // We can reconsider when the fix to the above issue hits clang, which might require a version check
12- // here
1311namespace std {
1412template <>
15- struct std :: hash<std:: filesystem::path> {
16- std:: size_t operator ()(const std:: filesystem::path& path) const { return hash_value (path); }
13+ struct hash<filesystem::path> {
14+ size_t operator()(const filesystem::path& path) const { return hash_value(path); }
1715};
16+
1817} // namespace std
You can’t perform that action at this time.
0 commit comments