-
-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Install clang-scan-deps tool #412
Conversation
Please don't mix unrelated changes in the same PR. Even if it seems safe, they can have entirely separate issues, warranting separate discussions with different conclusions. Re using a non-deprecated define for UWP - mingw-w64 headers don't have a single mention of This shows up in the test log, but apparently my smoke test suite didn't catch it properly. See https://github.com/mstorsjo/llvm-mingw/actions/runs/8257442431/job/22594726733?pr=412. The uwp-error testcase, which usually fails like this, https://github.com/mstorsjo/llvm-mingw/actions/runs/8257612173/job/22595195864:
Now failed like this:
The smoke testsuite does have a test for compiling an executable in UWP mode, which is supposed to work, but for that I only compiled the plain |
Also, re the libcxx modules, that change in itself looks ok, but if we're going to do that, we'll probably need to do a bit more. I tried playing with a little, but will need to look further into it later. The libc++ module files get installed into If we're going to use modules, I presume we should ship I'm looking at https://discourse.llvm.org/t/llvm-discussion-forums-libc-c-23-module-installation-support/77087/16 as standalone example of how to use the libcxx modules. (AFAIK CMake integration to use it doesn't quite exist yet.) I'm also looking at https://www.kitware.com/import-cmake-the-experiment-is-over/ as example for using C++20 modules in general. |
I will lower my head in shame. Yes, I somehow missed that mingw has vastly different headers, I previously was sure I checked both the WindowsSDK aswell as MingW. The modules seem more complex aswell, with I did read the CMake Article and planned to play with that, did appear to me that its "solved" with CMake. if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.20")
set(_prefix "${CMAKE_CURRENT_LIST_DIR}/../")
cmake_path(ABSOLUTE_PATH _prefix NORMALIZE)
set(_filename "${CMAKE_CURRENT_LIST_FILE}")
cmake_path(GET _filename FILENAME _filename)
else()
get_filename_component(_prefix "${CMAKE_CURRENT_LIST_DIR}/../" ABSOLUTE)
get_filename_component(_filename "${CMAKE_CURRENT_LIST_FILE}" NAME)
endif()
string(REGEX REPLACE "^llvm[_-]\(.*\)[_-]toolchain.*" "\\1" _arch "${_filename}")
string(REGEX REPLACE "^.*-mingw32\(.*\)" "\\1" _mingwtype "${_arch}")
string(REGEX REPLACE "-.*" "" _arch "${_arch}")
unset(_filename)
# set(_prefix /opt/llvm-mingw/)
# set(_mingwtype uwp)
set(CMAKE_SYSTEM_NAME Windows)
if(_arch)
set(CMAKE_SYSTEM_PROCESSOR ${_arch})
else()
set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_HOST_SYSTEM_PROCESSOR})
endif()
set(CMAKE_ASM_COMPILER "${_prefix}bin/clang")
set(CMAKE_C_COMPILER "${_prefix}bin/clang")
set(CMAKE_CXX_COMPILER "${_prefix}bin/clang++")
set(CMAKE_RC_COMPILER ${_prefix}bin/llvm-rc)
set(CMAKE_CXX_FLAGS_INIT "-stdlib=libc++")
foreach(_lang ASM C CXX)
set(CMAKE_${_lang}_COMPILER_TARGET ${CMAKE_SYSTEM_PROCESSOR}-w64-mingw32${_mingwtype})
if(_mingwtype STREQUAL "uwp")
set(CMAKE_${_lang}_FLAGS_INIT "${CMAKE_${_lang}_FLAGS_INIT} -D_WIN32_WINNT=0x0A00 -DWINVER=0x0A00 -DWINAPI_FAMILY=WINAPI_FAMILY_APP -DUNICODE -D_UCRT")
endif()
endforeach()
unset(_lang)
set(_linker lld)
# set(_linker_extra " -Wl,--undefined-version")
if(_mingwtype STREQUAL "uwp")
set(_linker_extra "${_linker_extra} -Wl,-lwindowsapp -Wl,-lucrtapp")
endif()
set(CMAKE_EXE_LINKER_FLAGS_INIT "--start-no-unused-arguments -stdlib=libc++ -fuse-ld=${_linker} -rtlib=compiler-rt -unwindlib=libunwind${_linker_extra} --end-no-unused-arguments")
set(CMAKE_MODULE_LINKER_FLAGS_INIT "${CMAKE_EXE_LINKER_FLAGS_INIT}")
set(CMAKE_SHARED_LINKER_FLAGS_INIT "${CMAKE_EXE_LINKER_FLAGS_INIT}")
set(CMAKE_LINKER ${_prefix}bin/ld.${_linker})
unset(_linker_extra)
unset(_linker)
set(CMAKE_SYSROOT "${_prefix}${CMAKE_SYSTEM_PROCESSOR}-w64-mingw32")
unset(_mingwtype)
unset(_prefix)
set(ENV{PKG_CONFIG_SYSROOT_DIR} "${CMAKE_SYSROOT}")
if($ENV{PKG_CONFIG_LIBDIR})
set(ENV{PKG_CONFIG_LIBDIR} "${CMAKE_SYSROOT}/usr/lib/pkgconfig:${CMAKE_SYSROOT}/usr/share/pkgconfig:$ENV{PKG_CONFIG_LIBDIR}")
else()
set(ENV{PKG_CONFIG_LIBDIR} "${CMAKE_SYSROOT}/usr/lib/pkgconfig:${CMAKE_SYSROOT}/usr/share/pkgconfig")
endif()
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) |
Well.... guess not.
https://cmake.org/cmake/help/latest/manual/cmake-cxxmodules.7.html#manual:cmake-cxxmodules(7) |
Yep, exactly. So until this is available in some form so we can test it, I think it's best to hold off of merging anything to master, before we've made sure that whatever layout we choose actually works with cmake somewhat out of the box. But until then we can certainly prepare things in a branch. General C++20 modules with one's own code, as in that linked CMake article, should kinda work though - the only thing it requires probably is that we'd keep the |
cffd8b5
to
e04f18a
Compare
Compilers and buildsystems have early support for c++ modules, see [1], [2]. `clang-scan-dep` is necessary for integration in CMake, potentially other buildsystems in the future. Using standard modules like from libc++ is still not solved thoroughly, and module support from libc++ is marked experimental, documentation how to use them is WIP [3]. [1]: https://www.kitware.com/import-cmake-the-experiment-is-over [2]: https://cmake.org/cmake/help/latest/manual/cmake-cxxmodules.7.html [3]: llvm/llvm-project#80601
e04f18a
to
16d7aca
Compare
@huangqinjin noted in mstorsjo/msvc-wine#126 that the upcoming CMake 3.30 should have support for this. I pushed a branch https://github.com/mstorsjo/llvm-mingw/commits/libcxx-modules which enables installing the libc++ module, and installing it into a directory that allows sharing the files across the architectures. (Since llvm/llvm-project@0cd4bab, since LLVM 18.1.3, specifying a custom |
I tested the toolchain, there are two problems.
The MinGW C headers need to be fixed to be exportable, i.e. use |
thanks for testing, for for 2., dropping static might give you some ABI issues. probably needs some c++ wrappers instead of |
Thanks, I see! Does the target triple play any role in the invocation of I'm wondering if plain symlinks are enough, or if we'd need to create a fullblown wrapper script/executable for this. Some tools, like regular clang itself, can infer the target triple implicitly, when invoked via a symlink as OTOH, if the
Oh, I see, thanks! This will indeed be a significant amount of work. There are a number of different patterns used for inline wrappers in the mingw-w64 headers, and they can be quite fiddly to get right, but I guess something like |
After testing
|
I think all options to |
Thanks for looking into this, and thanks for providing examples for how to use and investigate this. With this in mind, it does indeed look like we'll need to provide a wrapper script/executable for |
Should be pretty safe changes.
(did not want to make a separate PR for the macro update)