https://github.com/MaskRay updated https://github.com/llvm/llvm-project/pull/77537
>From 8bd31c3cdb6ce41194b063c9ac13e5e2fbfbcc02 Mon Sep 17 00:00:00 2001 From: Fangrui Song <i...@maskray.me> Date: Thu, 17 Aug 2023 14:01:02 -0700 Subject: [PATCH] [CMake] Deprecate GCC_INSTALL_PREFIX Part of https://reviews.llvm.org/D158218 GCC_INSTALL_PREFIX is a rarely-used legacy option inherited from pre-CMake build system and has configuration file replacement nowadays. Many `clang/test/Driver` tests specify `--gcc-toolchain=` to prevent failures when `GCC_INSTALL_PREFIX` is specified: some contributors add them to fix tests and some just do cargo culting. This is not healthy for contributors adding cross compilation support for this rarely used option. `DEFAULT_SYSROOT` should in spirit be deprecated as well, but a relative path doesn't have good replacement, so don't deprecate it for now. Link: https://discourse.llvm.org/t/add-gcc-install-dir-deprecate-gcc-toolchain-and-remove-gcc-install-prefix/65091 Link: https://discourse.llvm.org/t/correct-cmake-parameters-for-building-clang-and-lld-for-riscv/72833 --- With `GCC_INSTALL_PREFIX=/usr`, `clang a.c` behaves like `clang --gcc-toolchain=/usr a.c`. Here is a simplified version of GCC installation detection code. ``` if (OPT_gcc_install_dir_EQ) return OPT_gcc_install_dir_EQ; if (OPT_gcc_triple) candidate_gcc_triples = {OPT_gcc_triple}; else candidate_gcc_triples = collectCandidateTriples(); if (OPT_gcc_toolchain) prefixes = {OPT_gcc_toolchain}; else prefixes = {OPT_sysroot/usr, OPT_sysroot}; for (prefix : prefixes) if "$prefix/lib/gcc" exists // also tries $prefix/lib/gcc-cross for (triple : candidate_gcc_triples) if "$prefix/lib/gcc/$triple" exists return "$prefix/lib/gcc/$triple/$version"; // pick the largest version ``` `--gcc-toolchain=` specifies a directory where `lib/gcc{,-cross}/$triple/$version` can be found. If you actually want to use a specific version of GCC, specify something like `--gcc-install-dir=/usr/lib/gcc/x86_64-linux-gnu/11` in a configuration file. You can also specify `--gcc-triple=`. ``` clang --gcc-toolchain=/usr a.c clang --gcc-install-dir=/usr/lib/gcc/x86_64-linux-gnu/11 a.c # specific version clang --gcc-triple=x86_64-linux-gnu a.c ``` --- clang/CMakeLists.txt | 6 ++++++ clang/docs/ReleaseNotes.rst | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index 9f814478c45503..5f2b7f064da437 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -193,6 +193,12 @@ set(C_INCLUDE_DIRS "" CACHE STRING set(GCC_INSTALL_PREFIX "" CACHE PATH "Directory where gcc is installed." ) set(DEFAULT_SYSROOT "" CACHE STRING "Default <path> to all compiler invocations for --sysroot=<path>." ) +if(GCC_INSTALL_PREFIX) + message(WARNING "GCC_INSTALL_PREFIX is deprecated and will be removed. Use " + "configuration files (https://clang.llvm.org/docs/UsersManual.html#configuration-files)" + "to specify the default --gcc-install-dir= or --gcc-triple=. --gcc-toolchain= is discouraged. " + "See https://github.com/llvm/llvm-project/pull/77537 for detail.") +endif() set(ENABLE_LINKER_BUILD_ID OFF CACHE BOOL "pass --build-id to ld") diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index ddeb1186d65ac8..101e018d518845 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -37,6 +37,12 @@ These changes are ones which we think may surprise users when upgrading to Clang |release| because of the opportunity they pose for disruption to existing code bases. +- The CMake variable ``GCC_INSTALL_PREFIX`` (which sets the default + ``--gcc-toolchain=``) is deprecated and will be removed. Specify + ``--gcc-install-dir=`` or ``--gcc-triple=`` in a `configuration file + <https://clang.llvm.org/docs/UsersManual.html#configuration-files>` as a + replacement. + (`#77537 <https://github.com/llvm/llvm-project/pull/77537>`_) C/C++ Language Potentially Breaking Changes ------------------------------------------- _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits