From a9123ea1ac4a3b90dcf3352e802c95e0982a285a Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Mon, 15 Nov 2021 15:34:15 +0100 Subject: [PATCH] buildflags.md: Move toolchain selection documentation from macros file --- buildflags.md | 27 +++++++++++++++++++++++++++ macros | 23 ----------------------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/buildflags.md b/buildflags.md index ef08e2e..72fa621 100644 --- a/buildflags.md +++ b/buildflags.md @@ -75,6 +75,33 @@ It is possible to set RPM macros to change some aspects of the compiler flags. Changing these flags should be used as a last recourse if other workarounds are not available. +### Toolchain selection + +The default toolchain uses GCC, and the `%toolchain` macro is defined +as `gcc`. + +It is enough to override `toolchain` macro and all relevant macro for C/C++ +compilers will be switched. Either in the spec or in the command-line. + + %global toolchain clang + +or: + + rpmbuild -D "toolchain clang" … + +Inside a spec file it is also possible to determine which toolchain is in use +by testing the same macro. For example: + + %if "%{toolchain}" == "gcc" + BuildRequires: gcc + %endif + +or: + + %if "%{toolchain}" == "clang" + BuildRequires: clang compiler-rt + %endif + ### Lazy binding If your package depends on the semantics of lazy binding (e.g., it has diff --git a/macros b/macros index a30a755..4ac8096 100644 --- a/macros +++ b/macros @@ -37,29 +37,6 @@ %__cpp_clang clang-cpp # Default to the GCC toolchain -# -# It is enough to override `toolchain` macro and all relevant macro for C/C++ -# compilers will be switched. Either in the spec or in the command-line. -# -# %global toolchain clang -# -# or: -# -# rpmbuild -D "toolchain clang" … -# -# Inside a spec file it is also possible to determine which toolchain is in use -# by testing the same macro. For example: -# -# %if "%{toolchain}" == "gcc" -# BuildRequires: gcc -# %endif -# -# or: -# -# %if "%{toolchain}" == "clang" -# BuildRequires: clang compiler-rt -# %endif -# %toolchain gcc %__cc %{expand:%%{__cc_%{toolchain}}}