llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.64k stars 11.37k forks source link

`libcxx-generate-files` has different behavior on Windows and other platforms. #57458

Open fsb4000 opened 1 year ago

fsb4000 commented 1 year ago

From https://libcxx.llvm.org/Contributing.html#pre-commit-check-list

Did you run the libcxx-generate-files target and verify its output?

First I build libc++ on Windows:

cmake -G Ninja -S runtimes -B build -DLLVM_ENABLE_RUNTIMES="libcxx" -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl

After that I run ninja -C build libcxx-generate-files

And I found some issues with libcxx-generate-files on Windows:

1) CMakeLists.txt is treated like a header file. new line appears in libcxx/test/libcxx/clang_tidy.sh.cpp

#include <CMakeLists.txt>

and new lines appear in libcxx/test/libcxx/transitive_includes.sh.cpp:

#if defined(TEST_0)
#include <CMakeLists.txt>
#endif

2) libcxx/test/libcxx/transitive_includes.sh.cpp uses different path separators.

#include <experimental\forward_list>

instead of

#include <experimental/forward_list>

3) Absent some #if __cplusplus in libcxx/test/libcxx/clang_tidy.sh.cpp

#include <experimental\algorithm>
#include <experimental\coroutine>
#include <experimental\deque>
#include <experimental\forward_list>
#include <experimental\functional>

instead of

#if __cplusplus >= 201103L
#   include <experimental/algorithm>
#endif
#if __cplusplus >= 201103L && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_COROUTINES)
#   include <experimental/coroutine>
#endif
#if __cplusplus >= 201103L
#   include <experimental/deque>
#endif
#if __cplusplus >= 201103L
#   include <experimental/forward_list>
#endif
#if __cplusplus >= 201103L
#   include <experimental/functional>
#endif
mordante commented 1 year ago

Thanks for the report! I'm working on some of these files, for other improvements. I can look at this afterwards. I might need some help to test the fixes since I don't have Windows, but then I'll reach out to you on Discord.