Repository: conan-io/conan-center-index

Issue:
[package] boost/1.77.0: incorrect library-suffix on darwin with custom clang
when conan tries to build boost it fails with: 

```
ConanException: These libraries were built, but were not used in any boost module: {'boost_locale-clang-darwin12-mt-d-a64-1_77', 'boost_stacktrace_basic-clang-darwin12-mt-d-a64-1_77', [...]
```
which apparently fails because the recipe constructs what it thinks will be the library suffix but it does not match:

```
boost/1.77.0: Library layout suffix: '-clang12-mt-d-a64-1_77'
```
I am not using 'system' clang supplied by apple, I'm pulling the llvm repo from git and building latest. 

### Package and Environment Details
  * Package Name/Version: **boost/1.77.0**
  * Operating System+version: **MacOS/Darwin Monterey 12.0.1**
  * Compiler+version: **clang 12.0.0 e1eee4d**
  * Conan version: **conan 1.14.2**
  * Python version: **Python 3.8.9**


### Conan profile 
```
[settings]
os=Macos
os_build=Macos
arch=armv8
arch_build=armv8
compiler=clang
compiler.version=12
compiler.cppstd=20
compiler.libcxx=libc++
build_type=Debug
[options]
boost:asio_no_deprecated=True
boost:layout=versioned
boost:lzma=True
boost:python_version=3.8
boost:without_python=False
boost:without_test=True
[conf]
[build_requires]
[env]
CXX=/Users/jbj1/bin/clangbuild/clang++
CC=/Users/jbj1/bin/clangbuild/clang
```


### Steps to reproduce

conan install boost/1.77.0@ --build=missing

### Logs (Include/Attach if Applicable)
<details><summary>Click to expand log</summary>

```
Configuration:
[settings]
arch=armv8
arch_build=armv8
build_type=Debug
compiler=clang
compiler.cppstd=20
compiler.libcxx=libc++
compiler.version=12
os=Macos
os_build=Macos
[options]
boost:asio_no_deprecated=True
boost:layout=versioned
boost:lzma=True
boost:python_version=3.8
boost:without_python=False
boost:without_test=True
[build_requires]
[env]
CC=/Users/jbj1/bin/clangbuild/clang
CXX=/Users/jbj1/bin/clangbuild/clang++
boost/1.77.0: running "/Applications/Xcode.app/Contents/Developer/usr/bin/python3" -c "from __future__ import print_function; import sys; print('{}.{}'.format(sys.version_info[0], sys.version_info[1]))"
Installing package: boost/1.77.0
Requirements
    boost/1.77.0 from 'conancenter' - Cache
    bzip2/1.0.8 from 'conancenter' - Cache
    libbacktrace/cci.20210118 from 'conancenter' - Cache
    libiconv/1.16 from 'conancenter' - Cache
    xz_utils/5.2.5 from 'conancenter' - Cache
    zlib/1.2.11 from 'conancenter' - Cache
Packages
    boost/1.77.0:7bdc90f1e00d04b47db68e5a82625661b38cf7cc - Cache
    bzip2/1.0.8:2c5f5b0f7470eecf370701f3491cd9488c42b4ce - Cache
    libbacktrace/cci.20210118:8bea6cb1bae86c6bb9d6c4d78c6f8cbe34a3992a - Cache
    libiconv/1.16:8bea6cb1bae86c6bb9d6c4d78c6f8cbe34a3992a - Cache
    xz_utils/5.2.5:8bea6cb1bae86c6bb9d6c4d78c6f8cbe34a3992a - Cache
    zlib/1.2.11:8bea6cb1bae86c6bb9d6c4d78c6f8cbe34a3992a - Cache

Installing (downloading, building) binaries...
bzip2/1.0.8: Already installed!
bzip2/1.0.8: Appending PATH environment variable: /Users/jbj1/.conan/data/bzip2/1.0.8/_/_/package/2c5f5b0f7470eecf370701f3491cd9488c42b4ce/bin
libbacktrace/cci.20210118: Already installed!
libiconv/1.16: Already installed!
libiconv/1.16: Appending PATH environment var: /Users/jbj1/.conan/data/libiconv/1.16/_/_/package/8bea6cb1bae86c6bb9d6c4d78c6f8cbe34a3992a/bin
xz_utils/5.2.5: Already installed!
zlib/1.2.11: Already installed!
boost/1.77.0: Already installed!
boost/1.77.0: Library layout suffix: '-clang12-mt-d-a64-1_77'
boost/1.77.0: running "/Applications/Xcode.app/Contents/Developer/usr/bin/python3" -c "from __future__ import print_function; import sys; print('{}.{}'.format(sys.version_info[0], sys.version_info[1]))"
boost/1.77.0: WARN: Boost component 'atomic' is missing libraries. Try building boost with '-o boost:without_atomic'. (Option is not guaranteed to exist)
boost/1.77.0: WARN: Boost component 'chrono' is missing libraries. Try building boost with '-o boost:without_chrono'. (Option is not guaranteed to exist)
boost/1.77.0: WARN: Boost component 'container' is missing libraries. Try building boost with '-o boost:without_container'. (Option is not guaranteed to exist)
boost/1.77.0: WARN: Boost component 'context' is missing libraries. Try building boost with '-o boost:without_context'. (Option is not guaranteed to exist)
boost/1.77.0: WARN: Boost component 'contract' is missing libraries. Try building boost with '-o boost:without_contract'. (Option is not guaranteed to exist)
boost/1.77.0: WARN: Boost component 'coroutine' is missing libraries. Try building boost with '-o boost:without_coroutine'. (Option is not guaranteed to exist)
boost/1.77.0: WARN: Boost component 'date_time' is missing libraries. Try building boost with '-o boost:without_date_time'. (Option is not guaranteed to exist)
boost/1.77.0: WARN: Boost component 'exception' is missing libraries. Try building boost with '-o boost:without_exception'. (Option is not guaranteed to exist)
boost/1.77.0: WARN: Boost component 'fiber' is missing libraries. Try building boost with '-o boost:without_fiber'. (Option is not guaranteed to exist)
boost/1.77.0: WARN: Boost component 'fiber_numa' is missing libraries. Try building boost with '-o boost:without_fiber_numa'. (Option is not guaranteed to exist)
boost/1.77.0: WARN: Boost component 'filesystem' is missing libraries. Try building boost with '-o boost:without_filesystem'. (Option is not guaranteed to exist)
boost/1.77.0: WARN: Boost component 'graph' is missing libraries. Try building boost with '-o boost:without_graph'. (Option is not guaranteed to exist)
boost/1.77.0: WARN: Boost component 'iostreams' is missing libraries. Try building boost with '-o boost:without_iostreams'. (Option is not guaranteed to exist)
boost/1.77.0: WARN: Boost component 'json' is missing libraries. Try building boost with '-o boost:without_json'. (Option is not guaranteed to exist)
boost/1.77.0: WARN: Boost component 'locale' is missing libraries. Try building boost with '-o boost:without_locale'. (Option is not guaranteed to exist)
boost/1.77.0: WARN: Boost component 'log' is missing libraries. Try building boost with '-o boost:without_log'. (Option is not guaranteed to exist)
boost/1.77.0: WARN: Boost component 'log_setup' is missing libraries. Try building boost with '-o boost:without_log_setup'. (Option is not guaranteed to exist)
boost/1.77.0: WARN: Boost component 'math_c99' is missing libraries. Try building boost with '-o boost:without_math_c99'. (Option is not guaranteed to exist)
boost/1.77.0: WARN: Boost component 'math_c99f' is missing libraries. Try building boost with '-o boost:without_math_c99f'. (Option is not guaranteed to exist)
boost/1.77.0: WARN: Boost component 'math_c99l' is missing libraries. Try building boost with '-o boost:without_math_c99l'. (Option is not guaranteed to exist)
boost/1.77.0: WARN: Boost component 'math_tr1' is missing libraries. Try building boost with '-o boost:without_math_tr1'. (Option is not guaranteed to exist)
boost/1.77.0: WARN: Boost component 'math_tr1f' is missing libraries. Try building boost with '-o boost:without_math_tr1f'. (Option is not guaranteed to exist)
boost/1.77.0: WARN: Boost component 'math_tr1l' is missing libraries. Try building boost with '-o boost:without_math_tr1l'. (Option is not guaranteed to exist)
boost/1.77.0: WARN: Boost component 'nowide' is missing libraries. Try building boost with '-o boost:without_nowide'. (Option is not guaranteed to exist)
boost/1.77.0: WARN: Boost component 'numpy' is missing libraries. Try building boost with '-o boost:without_numpy'. (Option is not guaranteed to exist)
boost/1.77.0: WARN: Boost component 'program_options' is missing libraries. Try building boost with '-o boost:without_program_options'. (Option is not guaranteed to exist)
boost/1.77.0: WARN: Boost component 'python' is missing libraries. Try building boost with '-o boost:without_python'. (Option is not guaranteed to exist)
boost/1.77.0: WARN: Boost component 'random' is missing libraries. Try building boost with '-o boost:without_random'. (Option is not guaranteed to exist)
boost/1.77.0: WARN: Boost component 'regex' is missing libraries. Try building boost with '-o boost:without_regex'. (Option is not guaranteed to exist)
boost/1.77.0: WARN: Boost component 'serialization' is missing libraries. Try building boost with '-o boost:without_serialization'. (Option is not guaranteed to exist)
boost/1.77.0: WARN: Boost component 'stacktrace_addr2line' is missing libraries. Try building boost with '-o boost:without_stacktrace_addr2line'. (Option is not guaranteed to exist)
boost/1.77.0: WARN: Boost component 'stacktrace_backtrace' is missing libraries. Try building boost with '-o boost:without_stacktrace_backtrace'. (Option is not guaranteed to exist)
boost/1.77.0: WARN: Boost component 'stacktrace_basic' is missing libraries. Try building boost with '-o boost:without_stacktrace_basic'. (Option is not guaranteed to exist)
boost/1.77.0: WARN: Boost component 'stacktrace_noop' is missing libraries. Try building boost with '-o boost:without_stacktrace_noop'. (Option is not guaranteed to exist)
boost/1.77.0: WARN: Boost component 'system' is missing libraries. Try building boost with '-o boost:without_system'. (Option is not guaranteed to exist)
boost/1.77.0: WARN: Boost component 'thread' is missing libraries. Try building boost with '-o boost:without_thread'. (Option is not guaranteed to exist)
boost/1.77.0: WARN: Boost component 'timer' is missing libraries. Try building boost with '-o boost:without_timer'. (Option is not guaranteed to exist)
boost/1.77.0: WARN: Boost component 'type_erasure' is missing libraries. Try building boost with '-o boost:without_type_erasure'. (Option is not guaranteed to exist)
boost/1.77.0: WARN: Boost component 'wave' is missing libraries. Try building boost with '-o boost:without_wave'. (Option is not guaranteed to exist)
boost/1.77.0: WARN: Boost component 'wserialization' is missing libraries. Try building boost with '-o boost:without_wserialization'. (Option is not guaranteed to exist)
ERROR: boost/1.77.0: Error in package_info() method, line 1555
	raise ConanException("These libraries were built, but were not used in any boost module: {}".format(non_used))
	ConanException: These libraries were built, but were not used in any boost module: {'boost_locale-clang-darwin12-mt-d-a64-1_77', 'boost_stacktrace_basic-clang-darwin12-mt-d-a64-1_77', 'boost_stacktrace_addr2line-clang-darwin12-mt-d-a64-1_77', 'boost_math_c99l-clang-darwin12-mt-d-a64-1_77', 'boost_chrono-clang-darwin12-mt-d-a64-1_77', 'boost_nowide-clang-darwin12-mt-d-a64-1_77', 'boost_wave-clang-darwin12-mt-d-a64-1_77', 'boost_regex-clang-darwin12-mt-d-a64-1_77', 'boost_container-clang-darwin12-mt-d-a64-1_77', 'boost_fiber-clang-darwin12-mt-d-a64-1_77', 'boost_log_setup-clang-darwin12-mt-d-a64-1_77', 'boost_math_tr1-clang-darwin12-mt-d-a64-1_77', 'boost_graph-clang-darwin12-mt-d-a64-1_77', 'boost_math_tr1l-clang-darwin12-mt-d-a64-1_77', 'boost_date_time-clang-darwin12-mt-d-a64-1_77', 'boost_timer-clang-darwin12-mt-d-a64-1_77', 'boost_contract-clang-darwin12-mt-d-a64-1_77', 'boost_stacktrace_noop-clang-darwin12-mt-d-a64-1_77', 'boost_exception-clang-darwin12-mt-d-a64-1_77', 'boost_coroutine-clang-darwin12-mt-d-a64-1_77', 'boost_math_c99f-clang-darwin12-mt-d-a64-1_77', 'boost_stacktrace_backtrace-clang-darwin12-mt-d-a64-1_77', 'boost_atomic-clang-darwin12-mt-d-a64-1_77', 'boost_random-clang-darwin12-mt-d-a64-1_77', 'boost_context-clang-darwin12-mt-d-a64-1_77', 'boost_thread-clang-darwin12-mt-d-a64-1_77', 'boost_iostreams-clang-darwin12-mt-d-a64-1_77', 'boost_json-clang-darwin12-mt-d-a64-1_77', 'boost_wserialization-clang-darwin12-mt-d-a64-1_77', 'boost_system-clang-darwin12-mt-d-a64-1_77', 'boost_log-clang-darwin12-mt-d-a64-1_77', 'boost_math_c99-clang-darwin12-mt-d-a64-1_77', 'boost_python38-clang-darwin12-mt-d-a64-1_77', 'boost_serialization-clang-darwin12-mt-d-a64-1_77', 'boost_math_tr1f-clang-darwin12-mt-d-a64-1_77', 'boost_fiber_numa-clang-darwin12-mt-d-a64-1_77', 'boost_filesystem-clang-darwin12-mt-d-a64-1_77', 'boost_type_erasure-clang-darwin12-mt-d-a64-1_77', 'boost_program_options-clang-darwin12-mt-d-a64-1_77'}
```

</details>



Discussion:

Resolving patch:
diff --git a/recipes/boost/all/conanfile.py b/recipes/boost/all/conanfile.py
--- a/recipes/boost/all/conanfile.py
+++ b/recipes/boost/all/conanfile.py
@@ -1241,7 +1241,7 @@ def _toolset_version(self):
             toolset = tools.msvs_toolset(self)
             match = re.match(r"v(\d+)(\d)$", toolset)
             if match:
-                return "%s.%s" % (match.group(1), match.group(2))
+                return "{}.{}".format(match.group(1), match.group(2))
         return ""
 
     @property
@@ -1273,14 +1273,30 @@ def _toolset(self):
 
     @property
     def _toolset_tag(self):
-        if self._is_msvc:
-            return "vc{}".format(self._toolset_version.replace(".",""))
-        else:
-            # FIXME: missing toolset tags for compilers (see self._toolset)
-            compiler = str(self.settings.compiler)
-            if self.settings.compiler == "apple-clang":
-                compiler = "darwin"
-            return "{}{}".format(compiler, self.settings.compiler.version)
+        # compiler       | compiler.version | os          | toolset_tag    | remark
+        # ---------------+------------------+-------------+----------------+-----------------------------
+        # apple-clang    | 12               | Macos       | darwin12       |
+        # clang          | 12               | Macos       | clang-darwin12 |
+        # gcc            | 11               | Linux       | gcc8           |
+        # gcc            | 8                | Windows     | mgw8           |
+        # Visual Studio  | 17               | Windows     | vc142          | depends on compiler.toolset
+        compiler = {
+            "apple-clang": "",
+            "msvc": "vc",
+            "Visual Studio": "vc",
+        }.get(str(self.settings.compiler), str(self.settings.compiler))
+        if (self.settings.compiler, self.settings.os) == ("gcc", "Windows"):
+            compiler = "mgw"
+        os_ = ""
+        if self.settings.os == "Macos":
+            os_ = "darwin"
+        toolset_version = str(tools.Version(self.settings.compiler.version).major)
+        if self.settings.compiler in ("msvc", "Visual Studio"):
+            toolset_version = self._toolset_version.replace(".", "")
+
+        toolset_parts = [compiler, os_]
+        toolset_tag = "-".join(part for part in toolset_parts if part) + toolset_version
+        return toolset_tag
 
     ####################################################################
 


Test patch: