[clang] [lldb] [llvm] Remove some `try_compile` CMake checks for compiler flags (PR #92953)
cjappl wrote: Thanks for your help! You were correct that cc was pointing to gcc. This is fixed when I updated my machine to use my known clang as the default compiler. For future archeologists, this meant (from [this answer](https://askubuntu.com/questions/1198087/how-to-set-clang-9-as-the-default-c-compiler-on-ubuntu-19-10)) ``` sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 60 sudo update-alternatives --install /usr/bin/cc cc /usr/bin/clang 60 ``` https://github.com/llvm/llvm-project/pull/92953 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [llvm] Remove some `try_compile` CMake checks for compiler flags (PR #92953)
Endilll wrote: Yes, some try_compile checks where replaced with a check for `CMAKE_CXX_COMPILER_ID`, so it's crucial for it to reflect the reality. https://github.com/llvm/llvm-project/pull/92953 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [llvm] Remove some `try_compile` CMake checks for compiler flags (PR #92953)
MaskRay wrote: > Hi @Endilll > > I did a git bisect that pointed to this change as the one blocking my > compilation on an Ubuntu docker image with clang 14.0 > > The error I see: > > ``` > CMake Error at > /test_radsan/llvm-project/compiler-rt/cmake/Modules/CheckSectionExists.cmake:72 > (message): > cc: error: unrecognized command-line option > '-Wcovered-switch-default'; did you mean > '-Wno-switch-default'? > > cc: error: unrecognized command-line option > '-Wstring-conversion'; did you mean > '-Wsign-conversion'? > > Call Stack (most recent call first): > /test_radsan/llvm-project/compiler-rt/lib/builtins/CMakeLists.txt:923 > (check_section_exists) > ``` > > My compiler info, printed from CMake: > > ``` > CMAKE_CXX_COMPILER_VERSION: 14.0.0 > CMAKE_CXX_COMPILER_ID: Clang > ``` > > More info from the command line: > > ``` > $ clang --version > Ubuntu clang version 14.0.0-1ubuntu1.1 > Target: aarch64-unknown-linux-gnu > Thread model: posix > InstalledDir: /usr/bin > $ uname -a > Linux 18728bf50582 6.5.11-linuxkit #1 SMP PREEMPT Mon Dec 4 11:30:00 UTC > 2023 aarch64 aarch64 aarch64 GNU/Linux > $ cmake --version > cmake version 3.22.1 > ``` > > Let me know what other information may be helpful, or if this is user error. > It seems from your godbolt links above, clang 5.0 and higher should work, so > I'm surprised that 14.0 is dying in this environment `unrecognized command-line option` is from GCC. Your build environment might conflate GCC with Clang (`CMAKE_CXX_COMPILER_ID: Clang`). ``` % gcc -Wx -c a.c gcc: error: unrecognized command-line option â-Wxâ % clang -Wx -c a.c warning: unknown warning option '-Wx' [-Wunknown-warning-option] 1 warning generated. ``` https://github.com/llvm/llvm-project/pull/92953 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [llvm] Remove some `try_compile` CMake checks for compiler flags (PR #92953)
cjappl wrote: Hi @Endilll I did a git bisect that pointed to this change as the one blocking my compilation on an Ubuntu docker image with clang 14.0 The error I see: ``` CMake Error at /test_radsan/llvm-project/compiler-rt/cmake/Modules/CheckSectionExists.cmake:72 (message): cc: error: unrecognized command-line option '-Wcovered-switch-default'; did you mean '-Wno-switch-default'? cc: error: unrecognized command-line option '-Wstring-conversion'; did you mean '-Wsign-conversion'? Call Stack (most recent call first): /test_radsan/llvm-project/compiler-rt/lib/builtins/CMakeLists.txt:923 (check_section_exists) ``` My compiler info, printed from CMake: ``` CMAKE_CXX_COMPILER_VERSION: 14.0.0 CMAKE_CXX_COMPILER_ID: Clang ``` More info from the command line: ``` $ clang --version Ubuntu clang version 14.0.0-1ubuntu1.1 Target: aarch64-unknown-linux-gnu Thread model: posix InstalledDir: /usr/bin $ uname -a Linux 18728bf50582 6.5.11-linuxkit #1 SMP PREEMPT Mon Dec 4 11:30:00 UTC 2023 aarch64 aarch64 aarch64 GNU/Linux $ cmake --version cmake version 3.22.1 ``` Let me know what other information may be helpful, or if this is user error. It seems from your godbolt links above, clang 5.0 and higher should work, so I'm surprised that 14.0 is dying in this environment https://github.com/llvm/llvm-project/pull/92953 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [llvm] Remove some `try_compile` CMake checks for compiler flags (PR #92953)
Endilll wrote: @vvereschaka Thank you for letting me know! I wonder how this got past our pre- and post-commit CI, because we do build lldb with MSVC there. You fix makes total sense, so I applied it. https://github.com/llvm/llvm-project/pull/92953 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [llvm] Remove some `try_compile` CMake checks for compiler flags (PR #92953)
vvereschaka wrote: Hi @Endilll , these changes break MSVC build of the projects including LLDB. The `cl` compiler gets unsupported gcc/clang options, such as `-Wno-deprecated-declarations`, `-Wno-unknown-pragmas` and `-Wno-strict-aliasing`, and gets failed because of it. Here is the command line: ``` [267/5832] Building CXX object tools\lldb\utils\TableGen\CMakeFiles\lldb-tblgen.dir\LLDBOptionDefEmitter.cpp.obj FAILED: tools/lldb/utils/TableGen/CMakeFiles/lldb-tblgen.dir/LLDBOptionDefEmitter.cpp.obj ccache C:\PROGRA~1\MICROS~3\2022\COMMUN~1\VC\Tools\MSVC\1439~1.335\bin\Hostx64\x64\cl.exe /nologo /TP -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_ENABLE_EXTENDED_ALIGNED_STORAGE -D_GLIBCXX_ASSERTIONS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -IC:\path-to-build-dir\build-lldb\tools\lldb\utils\TableGen -IC:\path-to-build-dir\lldb\utils\TableGen -IC:\path-to-build-dir\lldb\include -IC:\path-to-build-dir\build-lldb\tools\lldb\include -IC:\path-to-build-dir\build-lldb\include -IC:\path-to-build-dir\llvm\include -IC:\Python312\include -IC:\path-to-build-dir\llvm\..\clang\include -IC:\path-to-build-dir\build-lldb\tools\lldb\..\clang\include -D__OPTIMIZE__ /Zc:inline /Zc:preprocessor /Zc:__cplusplus /Oi /bigobj /permissive- /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd5105 -wd4324 -w14062 -we4238 /Gw -Wno-deprecated-declarations -Wno-unknown-pragmas -Wno-strict-aliasing /O2 /Ob2 -MD -wd4018 -wd4068 -wd4150 -wd4201 -wd4251 -wd4521 -wd4530 -wd4589 /EHs-c- /GR- -UNDEBUG -std:c++17 /showIncludes /Fotools\lldb\utils\TableGen\CMakeFiles\lldb-tblgen.dir\LLDBOptionDefEmitter.cpp.obj /Fdtools\lldb\utils\TableGen\CMakeFiles\lldb-tblgen.dir\ /FS -c C:\path-to-build-dir\lldb\utils\TableGen\LLDBOptionDefEmitter.cpp ``` This is the cl error: ``` cl : Command line error D8021 : invalid numeric argument '/Wno-deprecated-declarations' ``` https://github.com/llvm/llvm-project/pull/92953 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [llvm] Remove some `try_compile` CMake checks for compiler flags (PR #92953)
Endilll wrote: I think the issue is that we no longer passed `-fno-lifetime-dse` to GCC due to incorrect condition (my fault), which caused some downstream LTO crashes as reported by @mveriksson in https://github.com/llvm/llvm-project/commit/4feae05c6abda364a9295aecfa600d7d4e7dfeb6#r142466703 (thank you very much!). Regressions from fixing it align with the unexpected improvements reporter earlier https://llvm-compile-time-tracker.com/compare.php?from=4bce270157f9a81bd7e38dc589a2970a445d1e96=b7f95171c8bf8e5a12a9e185c063ed85cd9dc8ee=instructions:u https://github.com/llvm/llvm-project/pull/92953 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [llvm] Remove some `try_compile` CMake checks for compiler flags (PR #92953)
nikic wrote: > > FYI this causes a minor compile-time improvement in stage1 builds using > > gcc: > > https://llvm-compile-time-tracker.com/compare.php?from=32c3561d44aa792ef08d72b5a4c342c9965bc4c2=4feae05c6abda364a9295aecfa600d7d4e7dfeb6=instructions:u > > While that's nice, it does suggest that the flags are not the same as > > before. > > @nikic Can you elaborate on those numbers? Do you say that Clang (compiled > with GCC) which compiles those tests works faster now? Yes, exactly. Clang compiled with GCC is faster. Clang compiled with Clang is not. So it seems like something changed in the options for GCC. https://github.com/llvm/llvm-project/pull/92953 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [llvm] Remove some `try_compile` CMake checks for compiler flags (PR #92953)
Endilll wrote: > FYI this causes a minor compile-time improvement in stage1 builds using gcc: > https://llvm-compile-time-tracker.com/compare.php?from=32c3561d44aa792ef08d72b5a4c342c9965bc4c2=4feae05c6abda364a9295aecfa600d7d4e7dfeb6=instructions:u > While that's nice, it does suggest that the flags are not the same as before. @nikic Can you elaborate on those numbers? Do you say that Clang (compiled with GCC) which compiles those tests works faster now? https://github.com/llvm/llvm-project/pull/92953 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [llvm] Remove some `try_compile` CMake checks for compiler flags (PR #92953)
felipepiovezan wrote: These types of changes touching a lot of projects at once can benefit from multiple PRs, one per project, as it makes partial reverts a lot easier and doesn't cause as much churn downstream (plus we can get more targeted comments from individual project owners) https://github.com/llvm/llvm-project/pull/92953 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [llvm] Remove some `try_compile` CMake checks for compiler flags (PR #92953)
nikic wrote: FYI this causes a minor compile-time improvement in stage1 builds using gcc: https://llvm-compile-time-tracker.com/compare.php?from=32c3561d44aa792ef08d72b5a4c342c9965bc4c2=4feae05c6abda364a9295aecfa600d7d4e7dfeb6=instructions:u While that's nice, it does suggest that the flags are not the same as before. https://github.com/llvm/llvm-project/pull/92953 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [llvm] Remove some `try_compile` CMake checks for compiler flags (PR #92953)
Endilll wrote: Quite expectedly, I see buildbot failures. Working on them. https://lab.llvm.org/buildbot/#/builders/36/builds/45836 https://lab.llvm.org/buildbot/#/builders/57/builds/35200 https://github.com/llvm/llvm-project/pull/92953 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [llvm] Remove some `try_compile` CMake checks for compiler flags (PR #92953)
https://github.com/Endilll closed https://github.com/llvm/llvm-project/pull/92953 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [llvm] Remove some `try_compile` CMake checks for compiler flags (PR #92953)
https://github.com/Endilll updated https://github.com/llvm/llvm-project/pull/92953 >From 66e05ac24613435dbe774d49684d8ff9d119c4c3 Mon Sep 17 00:00:00 2001 From: Vlad Serebrennikov Date: Tue, 21 May 2024 21:41:24 +0300 Subject: [PATCH 1/3] Remove some `try_compile` CMake checks for compiler flags This patch remove 36 checks for compiler flags that are done via invoking the compiler across LLVM, Clang, and LLDB. It's was made possible by raising the bar for supported compilers that has been happening over the years since the checks were added. This is going to improve CMake configuration times. This topic was highlighted in https://discourse.llvm.org/t/cmake-compiler-flag-checks-are-really-slow-ideas-to-speed-them-up/78882. --- clang/CMakeLists.txt | 5 +- .../tests/functional/exec/CMakeLists.txt | 6 +- lldb/cmake/modules/LLDBConfig.cmake | 20 +-- llvm/cmake/config-ix.cmake| 19 +-- llvm/cmake/modules/AddLLVM.cmake | 4 +- llvm/cmake/modules/HandleLLVMOptions.cmake| 142 -- third-party/unittest/CMakeLists.txt | 4 +- 7 files changed, 80 insertions(+), 120 deletions(-) diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index c20ce47a12abb..a6bcb853a464c 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -349,10 +349,7 @@ if (LLVM_COMPILER_IS_GCC_COMPATIBLE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wno-long-long") endif () - check_cxx_compiler_flag("-Werror -Wnested-anon-types" CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG) - if( CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG ) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-nested-anon-types" ) - endif() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-nested-anon-types" ) endif () # Determine HOST_LINK_VERSION on Darwin. diff --git a/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt b/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt index 95c6fdb610e0f..cb6ebda183725 100644 --- a/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt +++ b/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt @@ -2,11 +2,7 @@ project(exec C) cmake_minimum_required(VERSION 3.20.0) -include(CheckCCompilerFlag) -check_c_compiler_flag("-std=c99" C99_SUPPORTED) -if (C99_SUPPORTED) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") -endif() +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") include(CheckFunctionExists) include(CheckSymbolExists) diff --git a/lldb/cmake/modules/LLDBConfig.cmake b/lldb/cmake/modules/LLDBConfig.cmake index 3c6223b015bb1..6458f2e174643 100644 --- a/lldb/cmake/modules/LLDBConfig.cmake +++ b/lldb/cmake/modules/LLDBConfig.cmake @@ -187,24 +187,18 @@ include_directories("${CMAKE_CURRENT_BINARY_DIR}/../clang/include") # form -W, and if supported, add the corresponding -Wno- option. # Disable GCC warnings -check_cxx_compiler_flag("-Wdeprecated-declarations" CXX_SUPPORTS_DEPRECATED_DECLARATIONS) -append_if(CXX_SUPPORTS_DEPRECATED_DECLARATIONS "-Wno-deprecated-declarations" CMAKE_CXX_FLAGS) - -check_cxx_compiler_flag("-Wunknown-pragmas" CXX_SUPPORTS_UNKNOWN_PRAGMAS) -append_if(CXX_SUPPORTS_UNKNOWN_PRAGMAS "-Wno-unknown-pragmas" CMAKE_CXX_FLAGS) - -check_cxx_compiler_flag("-Wstrict-aliasing" CXX_SUPPORTS_STRICT_ALIASING) -append_if(CXX_SUPPORTS_STRICT_ALIASING "-Wno-strict-aliasing" CMAKE_CXX_FLAGS) +append("-Wno-deprecated-declarations" CMAKE_CXX_FLAGS) +append("-Wno-unknown-pragmas" CMAKE_CXX_FLAGS) +append("-Wno-strict-aliasing" CMAKE_CXX_FLAGS) check_cxx_compiler_flag("-Wstringop-truncation" CXX_SUPPORTS_STRINGOP_TRUNCATION) append_if(CXX_SUPPORTS_STRINGOP_TRUNCATION "-Wno-stringop-truncation" CMAKE_CXX_FLAGS) # Disable Clang warnings -check_cxx_compiler_flag("-Wdeprecated-register" CXX_SUPPORTS_DEPRECATED_REGISTER) -append_if(CXX_SUPPORTS_DEPRECATED_REGISTER "-Wno-deprecated-register" CMAKE_CXX_FLAGS) - -check_cxx_compiler_flag("-Wvla-extension" CXX_SUPPORTS_VLA_EXTENSION) -append_if(CXX_SUPPORTS_VLA_EXTENSION "-Wno-vla-extension" CMAKE_CXX_FLAGS) +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + append("-Wno-deprecated-register" CMAKE_CXX_FLAGS) + append("-Wno-vla-extension" CMAKE_CXX_FLAGS) +endif() # Disable MSVC warnings if( MSVC ) diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake index bf1b110245bb2..0900e1107076e 100644 --- a/llvm/cmake/config-ix.cmake +++ b/llvm/cmake/config-ix.cmake @@ -415,15 +415,14 @@ if( LLVM_ENABLE_PIC ) set(ENABLE_PIC 1) else() set(ENABLE_PIC 0) - check_cxx_compiler_flag("-fno-pie" SUPPORTS_NO_PIE_FLAG) - if(SUPPORTS_NO_PIE_FLAG) -set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fno-pie") - endif() + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fno-pie") endif() -check_cxx_compiler_flag("-Wvariadic-macros" SUPPORTS_VARIADIC_MACROS_FLAG) -check_cxx_compiler_flag("-Wgnu-zero-variadic-macro-arguments" -
[clang] [lldb] [llvm] Remove some `try_compile` CMake checks for compiler flags (PR #92953)
https://github.com/Endilll updated https://github.com/llvm/llvm-project/pull/92953 >From 66e05ac24613435dbe774d49684d8ff9d119c4c3 Mon Sep 17 00:00:00 2001 From: Vlad Serebrennikov Date: Tue, 21 May 2024 21:41:24 +0300 Subject: [PATCH 1/2] Remove some `try_compile` CMake checks for compiler flags This patch remove 36 checks for compiler flags that are done via invoking the compiler across LLVM, Clang, and LLDB. It's was made possible by raising the bar for supported compilers that has been happening over the years since the checks were added. This is going to improve CMake configuration times. This topic was highlighted in https://discourse.llvm.org/t/cmake-compiler-flag-checks-are-really-slow-ideas-to-speed-them-up/78882. --- clang/CMakeLists.txt | 5 +- .../tests/functional/exec/CMakeLists.txt | 6 +- lldb/cmake/modules/LLDBConfig.cmake | 20 +-- llvm/cmake/config-ix.cmake| 19 +-- llvm/cmake/modules/AddLLVM.cmake | 4 +- llvm/cmake/modules/HandleLLVMOptions.cmake| 142 -- third-party/unittest/CMakeLists.txt | 4 +- 7 files changed, 80 insertions(+), 120 deletions(-) diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index c20ce47a12abb..a6bcb853a464c 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -349,10 +349,7 @@ if (LLVM_COMPILER_IS_GCC_COMPATIBLE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wno-long-long") endif () - check_cxx_compiler_flag("-Werror -Wnested-anon-types" CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG) - if( CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG ) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-nested-anon-types" ) - endif() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-nested-anon-types" ) endif () # Determine HOST_LINK_VERSION on Darwin. diff --git a/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt b/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt index 95c6fdb610e0f..cb6ebda183725 100644 --- a/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt +++ b/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt @@ -2,11 +2,7 @@ project(exec C) cmake_minimum_required(VERSION 3.20.0) -include(CheckCCompilerFlag) -check_c_compiler_flag("-std=c99" C99_SUPPORTED) -if (C99_SUPPORTED) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") -endif() +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") include(CheckFunctionExists) include(CheckSymbolExists) diff --git a/lldb/cmake/modules/LLDBConfig.cmake b/lldb/cmake/modules/LLDBConfig.cmake index 3c6223b015bb1..6458f2e174643 100644 --- a/lldb/cmake/modules/LLDBConfig.cmake +++ b/lldb/cmake/modules/LLDBConfig.cmake @@ -187,24 +187,18 @@ include_directories("${CMAKE_CURRENT_BINARY_DIR}/../clang/include") # form -W, and if supported, add the corresponding -Wno- option. # Disable GCC warnings -check_cxx_compiler_flag("-Wdeprecated-declarations" CXX_SUPPORTS_DEPRECATED_DECLARATIONS) -append_if(CXX_SUPPORTS_DEPRECATED_DECLARATIONS "-Wno-deprecated-declarations" CMAKE_CXX_FLAGS) - -check_cxx_compiler_flag("-Wunknown-pragmas" CXX_SUPPORTS_UNKNOWN_PRAGMAS) -append_if(CXX_SUPPORTS_UNKNOWN_PRAGMAS "-Wno-unknown-pragmas" CMAKE_CXX_FLAGS) - -check_cxx_compiler_flag("-Wstrict-aliasing" CXX_SUPPORTS_STRICT_ALIASING) -append_if(CXX_SUPPORTS_STRICT_ALIASING "-Wno-strict-aliasing" CMAKE_CXX_FLAGS) +append("-Wno-deprecated-declarations" CMAKE_CXX_FLAGS) +append("-Wno-unknown-pragmas" CMAKE_CXX_FLAGS) +append("-Wno-strict-aliasing" CMAKE_CXX_FLAGS) check_cxx_compiler_flag("-Wstringop-truncation" CXX_SUPPORTS_STRINGOP_TRUNCATION) append_if(CXX_SUPPORTS_STRINGOP_TRUNCATION "-Wno-stringop-truncation" CMAKE_CXX_FLAGS) # Disable Clang warnings -check_cxx_compiler_flag("-Wdeprecated-register" CXX_SUPPORTS_DEPRECATED_REGISTER) -append_if(CXX_SUPPORTS_DEPRECATED_REGISTER "-Wno-deprecated-register" CMAKE_CXX_FLAGS) - -check_cxx_compiler_flag("-Wvla-extension" CXX_SUPPORTS_VLA_EXTENSION) -append_if(CXX_SUPPORTS_VLA_EXTENSION "-Wno-vla-extension" CMAKE_CXX_FLAGS) +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + append("-Wno-deprecated-register" CMAKE_CXX_FLAGS) + append("-Wno-vla-extension" CMAKE_CXX_FLAGS) +endif() # Disable MSVC warnings if( MSVC ) diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake index bf1b110245bb2..0900e1107076e 100644 --- a/llvm/cmake/config-ix.cmake +++ b/llvm/cmake/config-ix.cmake @@ -415,15 +415,14 @@ if( LLVM_ENABLE_PIC ) set(ENABLE_PIC 1) else() set(ENABLE_PIC 0) - check_cxx_compiler_flag("-fno-pie" SUPPORTS_NO_PIE_FLAG) - if(SUPPORTS_NO_PIE_FLAG) -set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fno-pie") - endif() + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fno-pie") endif() -check_cxx_compiler_flag("-Wvariadic-macros" SUPPORTS_VARIADIC_MACROS_FLAG) -check_cxx_compiler_flag("-Wgnu-zero-variadic-macro-arguments" -
[clang] [lldb] [llvm] Remove some `try_compile` CMake checks for compiler flags (PR #92953)
https://github.com/JDevlieghere approved this pull request. https://github.com/llvm/llvm-project/pull/92953 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [llvm] Remove some `try_compile` CMake checks for compiler flags (PR #92953)
https://github.com/aeubanks approved this pull request. awesome, thanks! https://github.com/llvm/llvm-project/pull/92953 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [llvm] Remove some `try_compile` CMake checks for compiler flags (PR #92953)
https://github.com/cor3ntin approved this pull request. https://github.com/llvm/llvm-project/pull/92953 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [llvm] Remove some `try_compile` CMake checks for compiler flags (PR #92953)
https://github.com/MaskRay approved this pull request. Great ï https://github.com/llvm/llvm-project/pull/92953 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [llvm] Remove some `try_compile` CMake checks for compiler flags (PR #92953)
Endilll wrote: Here are CE links with the set of minimum required compilers that should cover almost all the changes I made: https://godbolt.org/z/j98xzhrGa https://godbolt.org/z/errv4WhfP https://godbolt.org/z/vnoh8YqEP Windows-targeted flags were tested both on MSVC on CE, and on clang-cl 5.0 locally. https://github.com/llvm/llvm-project/pull/92953 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [llvm] Remove some `try_compile` CMake checks for compiler flags (PR #92953)
Endilll wrote: On my setup, this patch improves CMake configuration times (from a clean state) from 51 seconds down to 46 seconds (average of 3 measurements). My setup: ancient x86 hardware, Debian Sid, nightly Clang, build directory on a RAM disk. CMake invocation: `cmake -DLLVM_ENABLE_PROJECTS="clang;lldb" -DLLVM_ENABLE_RUNTIMES="libunwind;libcxx;libcxxabi" -DCMAKE_BUILD_TYPE=Debug -DLLVM_OPTIMIZED_TABLEGEN=ON -DLLVM_TARGETS_TO_BUILD="X86" -DLLVM_ENABLE_DOXYGEN=ON -DLLVM_ENABLE_LIBCXX=ON -DBUILD_SHARED_LIBS=ON -DLLDB_ENABLE_PYTHON=ON ~/endill/llvm-project/llvm`. https://github.com/llvm/llvm-project/pull/92953 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [llvm] Remove some `try_compile` CMake checks for compiler flags (PR #92953)
llvmbot wrote: @llvm/pr-subscribers-lldb @llvm/pr-subscribers-clang Author: Vlad Serebrennikov (Endilll) Changes This patch remove 36 checks for compiler flags that are done via invoking the compiler across LLVM, Clang, and LLDB. It's was made possible by raising the bar for supported compilers that has been happening over the years since the checks were added. This is going to improve CMake configuration times. This topic was highlighted in https://discourse.llvm.org/t/cmake-compiler-flag-checks-are-really-slow-ideas-to-speed-them-up/78882. --- Full diff: https://github.com/llvm/llvm-project/pull/92953.diff 7 Files Affected: - (modified) clang/CMakeLists.txt (+1-4) - (modified) clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt (+1-5) - (modified) lldb/cmake/modules/LLDBConfig.cmake (+7-13) - (modified) llvm/cmake/config-ix.cmake (+8-11) - (modified) llvm/cmake/modules/AddLLVM.cmake (+1-3) - (modified) llvm/cmake/modules/HandleLLVMOptions.cmake (+61-81) - (modified) third-party/unittest/CMakeLists.txt (+1-3) ``diff diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index c20ce47a12abb..a6bcb853a464c 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -349,10 +349,7 @@ if (LLVM_COMPILER_IS_GCC_COMPATIBLE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wno-long-long") endif () - check_cxx_compiler_flag("-Werror -Wnested-anon-types" CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG) - if( CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG ) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-nested-anon-types" ) - endif() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-nested-anon-types" ) endif () # Determine HOST_LINK_VERSION on Darwin. diff --git a/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt b/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt index 95c6fdb610e0f..cb6ebda183725 100644 --- a/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt +++ b/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt @@ -2,11 +2,7 @@ project(exec C) cmake_minimum_required(VERSION 3.20.0) -include(CheckCCompilerFlag) -check_c_compiler_flag("-std=c99" C99_SUPPORTED) -if (C99_SUPPORTED) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") -endif() +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") include(CheckFunctionExists) include(CheckSymbolExists) diff --git a/lldb/cmake/modules/LLDBConfig.cmake b/lldb/cmake/modules/LLDBConfig.cmake index 3c6223b015bb1..6458f2e174643 100644 --- a/lldb/cmake/modules/LLDBConfig.cmake +++ b/lldb/cmake/modules/LLDBConfig.cmake @@ -187,24 +187,18 @@ include_directories("${CMAKE_CURRENT_BINARY_DIR}/../clang/include") # form -W, and if supported, add the corresponding -Wno- option. # Disable GCC warnings -check_cxx_compiler_flag("-Wdeprecated-declarations" CXX_SUPPORTS_DEPRECATED_DECLARATIONS) -append_if(CXX_SUPPORTS_DEPRECATED_DECLARATIONS "-Wno-deprecated-declarations" CMAKE_CXX_FLAGS) - -check_cxx_compiler_flag("-Wunknown-pragmas" CXX_SUPPORTS_UNKNOWN_PRAGMAS) -append_if(CXX_SUPPORTS_UNKNOWN_PRAGMAS "-Wno-unknown-pragmas" CMAKE_CXX_FLAGS) - -check_cxx_compiler_flag("-Wstrict-aliasing" CXX_SUPPORTS_STRICT_ALIASING) -append_if(CXX_SUPPORTS_STRICT_ALIASING "-Wno-strict-aliasing" CMAKE_CXX_FLAGS) +append("-Wno-deprecated-declarations" CMAKE_CXX_FLAGS) +append("-Wno-unknown-pragmas" CMAKE_CXX_FLAGS) +append("-Wno-strict-aliasing" CMAKE_CXX_FLAGS) check_cxx_compiler_flag("-Wstringop-truncation" CXX_SUPPORTS_STRINGOP_TRUNCATION) append_if(CXX_SUPPORTS_STRINGOP_TRUNCATION "-Wno-stringop-truncation" CMAKE_CXX_FLAGS) # Disable Clang warnings -check_cxx_compiler_flag("-Wdeprecated-register" CXX_SUPPORTS_DEPRECATED_REGISTER) -append_if(CXX_SUPPORTS_DEPRECATED_REGISTER "-Wno-deprecated-register" CMAKE_CXX_FLAGS) - -check_cxx_compiler_flag("-Wvla-extension" CXX_SUPPORTS_VLA_EXTENSION) -append_if(CXX_SUPPORTS_VLA_EXTENSION "-Wno-vla-extension" CMAKE_CXX_FLAGS) +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + append("-Wno-deprecated-register" CMAKE_CXX_FLAGS) + append("-Wno-vla-extension" CMAKE_CXX_FLAGS) +endif() # Disable MSVC warnings if( MSVC ) diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake index bf1b110245bb2..0900e1107076e 100644 --- a/llvm/cmake/config-ix.cmake +++ b/llvm/cmake/config-ix.cmake @@ -415,15 +415,14 @@ if( LLVM_ENABLE_PIC ) set(ENABLE_PIC 1) else() set(ENABLE_PIC 0) - check_cxx_compiler_flag("-fno-pie" SUPPORTS_NO_PIE_FLAG) - if(SUPPORTS_NO_PIE_FLAG) -set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fno-pie") - endif() + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fno-pie") endif() -check_cxx_compiler_flag("-Wvariadic-macros" SUPPORTS_VARIADIC_MACROS_FLAG) -check_cxx_compiler_flag("-Wgnu-zero-variadic-macro-arguments" -SUPPORTS_GNU_ZERO_VARIADIC_MACRO_ARGUMENTS_FLAG) +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + set(SUPPORTS_GNU_ZERO_VARIADIC_MACRO_ARGUMENTS_FLAG
[clang] [lldb] [llvm] Remove some `try_compile` CMake checks for compiler flags (PR #92953)
https://github.com/Endilll created https://github.com/llvm/llvm-project/pull/92953 This patch remove 36 checks for compiler flags that are done via invoking the compiler across LLVM, Clang, and LLDB. It's was made possible by raising the bar for supported compilers that has been happening over the years since the checks were added. This is going to improve CMake configuration times. This topic was highlighted in https://discourse.llvm.org/t/cmake-compiler-flag-checks-are-really-slow-ideas-to-speed-them-up/78882. >From 66e05ac24613435dbe774d49684d8ff9d119c4c3 Mon Sep 17 00:00:00 2001 From: Vlad Serebrennikov Date: Tue, 21 May 2024 21:41:24 +0300 Subject: [PATCH] Remove some `try_compile` CMake checks for compiler flags This patch remove 36 checks for compiler flags that are done via invoking the compiler across LLVM, Clang, and LLDB. It's was made possible by raising the bar for supported compilers that has been happening over the years since the checks were added. This is going to improve CMake configuration times. This topic was highlighted in https://discourse.llvm.org/t/cmake-compiler-flag-checks-are-really-slow-ideas-to-speed-them-up/78882. --- clang/CMakeLists.txt | 5 +- .../tests/functional/exec/CMakeLists.txt | 6 +- lldb/cmake/modules/LLDBConfig.cmake | 20 +-- llvm/cmake/config-ix.cmake| 19 +-- llvm/cmake/modules/AddLLVM.cmake | 4 +- llvm/cmake/modules/HandleLLVMOptions.cmake| 142 -- third-party/unittest/CMakeLists.txt | 4 +- 7 files changed, 80 insertions(+), 120 deletions(-) diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index c20ce47a12abb..a6bcb853a464c 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -349,10 +349,7 @@ if (LLVM_COMPILER_IS_GCC_COMPATIBLE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wno-long-long") endif () - check_cxx_compiler_flag("-Werror -Wnested-anon-types" CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG) - if( CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG ) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-nested-anon-types" ) - endif() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-nested-anon-types" ) endif () # Determine HOST_LINK_VERSION on Darwin. diff --git a/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt b/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt index 95c6fdb610e0f..cb6ebda183725 100644 --- a/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt +++ b/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt @@ -2,11 +2,7 @@ project(exec C) cmake_minimum_required(VERSION 3.20.0) -include(CheckCCompilerFlag) -check_c_compiler_flag("-std=c99" C99_SUPPORTED) -if (C99_SUPPORTED) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") -endif() +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") include(CheckFunctionExists) include(CheckSymbolExists) diff --git a/lldb/cmake/modules/LLDBConfig.cmake b/lldb/cmake/modules/LLDBConfig.cmake index 3c6223b015bb1..6458f2e174643 100644 --- a/lldb/cmake/modules/LLDBConfig.cmake +++ b/lldb/cmake/modules/LLDBConfig.cmake @@ -187,24 +187,18 @@ include_directories("${CMAKE_CURRENT_BINARY_DIR}/../clang/include") # form -W, and if supported, add the corresponding -Wno- option. # Disable GCC warnings -check_cxx_compiler_flag("-Wdeprecated-declarations" CXX_SUPPORTS_DEPRECATED_DECLARATIONS) -append_if(CXX_SUPPORTS_DEPRECATED_DECLARATIONS "-Wno-deprecated-declarations" CMAKE_CXX_FLAGS) - -check_cxx_compiler_flag("-Wunknown-pragmas" CXX_SUPPORTS_UNKNOWN_PRAGMAS) -append_if(CXX_SUPPORTS_UNKNOWN_PRAGMAS "-Wno-unknown-pragmas" CMAKE_CXX_FLAGS) - -check_cxx_compiler_flag("-Wstrict-aliasing" CXX_SUPPORTS_STRICT_ALIASING) -append_if(CXX_SUPPORTS_STRICT_ALIASING "-Wno-strict-aliasing" CMAKE_CXX_FLAGS) +append("-Wno-deprecated-declarations" CMAKE_CXX_FLAGS) +append("-Wno-unknown-pragmas" CMAKE_CXX_FLAGS) +append("-Wno-strict-aliasing" CMAKE_CXX_FLAGS) check_cxx_compiler_flag("-Wstringop-truncation" CXX_SUPPORTS_STRINGOP_TRUNCATION) append_if(CXX_SUPPORTS_STRINGOP_TRUNCATION "-Wno-stringop-truncation" CMAKE_CXX_FLAGS) # Disable Clang warnings -check_cxx_compiler_flag("-Wdeprecated-register" CXX_SUPPORTS_DEPRECATED_REGISTER) -append_if(CXX_SUPPORTS_DEPRECATED_REGISTER "-Wno-deprecated-register" CMAKE_CXX_FLAGS) - -check_cxx_compiler_flag("-Wvla-extension" CXX_SUPPORTS_VLA_EXTENSION) -append_if(CXX_SUPPORTS_VLA_EXTENSION "-Wno-vla-extension" CMAKE_CXX_FLAGS) +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + append("-Wno-deprecated-register" CMAKE_CXX_FLAGS) + append("-Wno-vla-extension" CMAKE_CXX_FLAGS) +endif() # Disable MSVC warnings if( MSVC ) diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake index bf1b110245bb2..0900e1107076e 100644 --- a/llvm/cmake/config-ix.cmake +++ b/llvm/cmake/config-ix.cmake @@ -415,15 +415,14 @@ if( LLVM_ENABLE_PIC ) set(ENABLE_PIC 1) else()