Repository: conan-io/conan
Pull request #12178 (2022-09-22 16:52:58)

initial new proposal for win_bash_run
Changelog: Feature: New ``conanfile.win_bash_run`` and ``tools.microsoft.bash:active`` config for better Windows bash management
Docs: https://github.com/conan-io/docs/pull/XXXX

Close https://github.com/conan-io/conan/issues/10900
Close https://github.com/conan-io/conan/issues/12192


Patch:
diff --git a/README.rst b/README.rst
index fb5ea23ce..91b3c398c 100644
--- a/README.rst
+++ b/README.rst
@@ -8,7 +8,7 @@ Decentralized, open-source (MIT), C/C++ package manager.
 - Homepage: https://conan.io/
 - Github: https://github.com/conan-io/conan
 - Docs: https://docs.conan.io/en/latest/
-- Slack: https://cpplang-inviter.cppalliance.org/ (#conan channel)
+- Slack: https://cppalliance.org/slack/ (#conan channel)
 - Twitter: https://twitter.com/conan_io
 
 
diff --git a/conan/tools/_compilers.py b/conan/tools/_compilers.py
index 8379b5b4d..a3ab6bc86 100644
--- a/conan/tools/_compilers.py
+++ b/conan/tools/_compilers.py
@@ -18,7 +18,15 @@ def architecture_flag(settings):
     if the_os == "Android":
         return ""
 
-    if str(compiler) in ['gcc', 'apple-clang', 'clang', 'sun-cc']:
+    if compiler == "clang" and the_os == "Windows":
+        # LLVM/Clang and VS/Clang must define runtime. msys2 clang won't
+        runtime = settings.get_safe("compiler.runtime")  # runtime is Windows only
+        if runtime is not None:
+            return ""
+        # TODO: Maybe Clang-Mingw runtime does, but with C++ is impossible to test
+        return {"x86_64": "-m64",
+                "x86": "-m32"}.get(arch, "")
+    elif str(compiler) in ['gcc', 'apple-clang', 'clang', 'sun-cc']:
         if str(the_os) == 'Macos' and str(subsystem) == 'catalyst':
             # FIXME: This might be conflicting with Autotools --target cli arg
             apple_arch = to_apple_arch(arch)
diff --git a/conan/tools/apple/apple.py b/conan/tools/apple/apple.py
index a68b5d355..b2efefd48 100644
--- a/conan/tools/apple/apple.py
+++ b/conan/tools/apple/apple.py
@@ -4,6 +4,7 @@ import os
 
 from conans.util.runners import check_output_runner
 from conans.client.tools.apple import to_apple_arch as _to_apple_arch
+from conans.errors import ConanException
 
 
 def is_apple_os(conanfile):
@@ -79,11 +80,18 @@ def apple_sdk_path(conanfile):
 
 class XCRun(object):
 
-    def __init__(self, conanfile, sdk=None):
+    def __init__(self, conanfile, sdk=None, use_settings_target=False):
         """sdk=False will skip the flag
-           sdk=None will try to adjust it automatically"""
-        if sdk is None and conanfile.settings:
-            sdk = apple_sdk_name(conanfile.settings)
+           sdk=None will try to adjust it automatically
+           target_settings=True try to use settings_target in case they exist"""
+
+        # FIXME: 2.0: remove "hasattr()" condition
+        settings = conanfile.settings
+        if use_settings_target and hasattr(conanfile, "settings_target") and conanfile.settings_target is not None:
+            settings = conanfile.settings_target
+
+        if sdk is None and settings:
+            sdk = apple_sdk_name(settings)
         self.sdk = sdk
 
     def _invoke(self, args):
@@ -158,8 +166,8 @@ def fix_apple_shared_install_name(conanfile):
         install_name = check_output_runner(command).strip().split(":")[1].strip()
         return install_name
 
-    def _osx_collect_dylibs(lib_folder):
-        return [os.path.join(full_folder, f) for f in os.listdir(lib_folder) if f.endswith(".dylib")
+    def _darwin_collect_dylibs(lib_folder):
+        return [os.path.join(lib_folder, f) for f in os.listdir(lib_folder) if f.endswith(".dylib")
                 and not os.path.islink(os.path.join(lib_folder, f))]
 
     def _fix_install_name(dylib_path, new_name):
@@ -170,16 +178,48 @@ def fix_apple_shared_install_name(conanfile):
         command = f"install_name_tool {dylib_path} -change {old_name} {new_name}"
         conanfile.run(command)
 
-    substitutions = {}
-
-    if is_apple_os(conanfile) and conanfile.options.get_safe("shared", False):
+    def _darwin_collect_executables(bin_folder):
+        ret = []
+        for f in os.listdir(bin_folder):
+            full_path = os.path.join(bin_folder, f)
+
+            # Run "otool -hv" to verify it is an executable
+            check_bin = "otool -hv {}".format(full_path)
+            if "EXECUTE" in check_output_runner(check_bin):
+                ret.append(full_path)
+        return ret
+
+    def _get_rpath_entries(binary_file):
+        entries = []
+        command = "otool -l {}".format(binary_file)
+        otool_output = check_output_runner(command).splitlines()
+        for count, text in enumerate(otool_output):
+            pass
+            if "LC_RPATH" in text:
+                rpath_entry = otool_output[count+2].split("path ")[1].split(" ")[0]
+                entries.append(rpath_entry)
+        return entries
+
+    def _get_shared_dependencies(binary_file):
+        command = "otool -L {}".format(binary_file)
+        all_shared = check_output_runner(command).strip().split(":")[1].strip()
+        ret = [s.split("(")[0].strip() for s in all_shared.splitlines()]
+        return ret
+
+    def _fix_dylib_files(conanfile):
+        substitutions = {}
         libdirs = getattr(conanfile.cpp.package, "libdirs")
         for libdir in libdirs:
             full_folder = os.path.join(conanfile.package_folder, libdir)
-            shared_libs = _osx_collect_dylibs(full_folder)
+            if not os.path.exists(full_folder):
+                raise ConanException(f"Trying to locate shared libraries, but `{libdir}` "
+                                     f" not found inside package folder {conanfile.package_folder}")
+            shared_libs = _darwin_collect_dylibs(full_folder)
             # fix LC_ID_DYLIB in first pass
             for shared_lib in shared_libs:
                 install_name = _get_install_name(shared_lib)
+                #TODO: we probably only want to fix the install the name if
+                # it starts with `/`.
                 rpath_name = f"@rpath/{os.path.basename(install_name)}"
                 _fix_install_name(shared_lib, rpath_name)
                 substitutions[install_name] = rpath_name
@@ -188,3 +228,45 @@ def fix_apple_shared_install_name(conanfile):
             for shared_lib in shared_libs:
                 for old, new in substitutions.items():
                     _fix_dep_name(shared_lib, old, new)
+
+        return substitutions
+
+    def _fix_executables(conanfile, substitutions):
+        # Fix the install name for executables inside the package
+        # that reference libraries we just patched
+        bindirs = getattr(conanfile.cpp.package, "bindirs")
+        for bindir in bindirs:
+            full_folder = os.path.join(conanfile.package_folder, bindir)
+            if not os.path.exists(full_folder):
+                # Skip if the folder does not exist inside the package
+                # (e.g. package does not contain executables but bindirs is defined)
+                continue
+            executables = _darwin_collect_executables(full_folder)
+            for executable in executables:
+
+                # Fix install names of libraries from within the same package
+                deps = _get_shared_dependencies(executable)
+                for dep in deps:
+                    dep_base = os.path.join(os.path.dirname(dep), os.path.basename(dep).split('.')[0])
+                    match = [k for k in substitutions.keys() if k.startswith(dep_base)]
+                    if match:
+                        _fix_dep_name(executable, dep, substitutions[match[0]])
+
+                # Add relative rpath to library directories, avoiding possible
+                # existing duplicates
+                libdirs = getattr(conanfile.cpp.package, "libdirs")
+                libdirs = [os.path.join(conanfile.package_folder, dir) for dir in libdirs]
+                rel_paths = [f"@executable_path/{os.path.relpath(dir, full_folder)}" for dir in libdirs]
+                existing_rpaths = _get_rpath_entries(executable)
+                rpaths_to_add = list(set(rel_paths) - set(existing_rpaths))
+                for entry in rpaths_to_add:
+                    command = f"install_name_tool {executable} -add_rpath {entry}"
+                    conanfile.run(command)
+
+    if is_apple_os(conanfile) and conanfile.options.get_safe("shared", False):
+        substitutions = _fix_dylib_files(conanfile)
+
+        # Only "fix" executables if dylib files were patched, otherwise 
+        # there is nothing to do.
+        if substitutions:
+            _fix_executables(conanfile, substitutions)
diff --git a/conan/tools/build/__init__.py b/conan/tools/build/__init__.py
index c7a2e667b..829886a8d 100644
--- a/conan/tools/build/__init__.py
+++ b/conan/tools/build/__init__.py
@@ -2,3 +2,4 @@ from conan.tools.build.cpu import build_jobs
 from conan.tools.build.cross_building import cross_building, can_run
 from conan.tools.build.cppstd import check_min_cppstd, valid_min_cppstd, default_cppstd, \
     supported_cppstd
+from conan.tools.build.stdcpp_library import stdcpp_library
diff --git a/conan/tools/build/stdcpp_library.py b/conan/tools/build/stdcpp_library.py
new file mode 100644
index 000000000..646f1cfc0
--- /dev/null
+++ b/conan/tools/build/stdcpp_library.py
@@ -0,0 +1,16 @@
+
+def stdcpp_library(conanfile):
+    """ Returns the name of the C++ standard library that can be passed
+    to the linker, based on the current settings. Returs None if the name 
+    of the C++ standard library file is not known.
+    """
+    libcxx = conanfile.settings.get_safe("compiler.libcxx")
+    if libcxx in ["libstdc++", "libstdc++11"]:
+        return "stdc++"
+    elif libcxx in ["libc++"]:
+        return "c++"
+    elif libcxx in ["c++_shared"]:
+        return "c++_shared"
+    elif libcxx in ["c++_static"]:
+        return "c++_static"
+    return None
diff --git a/conan/tools/cmake/toolchain/blocks.py b/conan/tools/cmake/toolchain/blocks.py
index 74b274727..eda75b0d6 100644
--- a/conan/tools/cmake/toolchain/blocks.py
+++ b/conan/tools/cmake/toolchain/blocks.py
@@ -102,8 +102,15 @@ class VSRuntimeBlock(Block):
     def context(self):
         # Parsing existing toolchain file to get existing configured runtimes
         settings = self._conanfile.settings
+        if settings.get_safe("os") != "Windows":
+            return
+
         compiler = settings.get_safe("compiler")
-        if compiler not in ("Visual Studio", "msvc", "intel-cc"):
+        if compiler not in ("Visual Studio", "msvc", "clang", "intel-cc"):
+            return
+
+        runtime = settings.get_safe("compiler.runtime")
+        if runtime is None:
             return
 
         config_dict = {}
@@ -119,18 +126,26 @@ class VSRuntimeBlock(Block):
         build_type = settings.get_safe("build_type")  # FIXME: change for configuration
         if build_type is None:
             return None
-        runtime = settings.get_safe("compiler.runtime")
+
         if compiler == "Visual Studio":
             config_dict[build_type] = {"MT": "MultiThreaded",
                                        "MTd": "MultiThreadedDebug",
                                        "MD": "MultiThreadedDLL",
                                        "MDd": "MultiThreadedDebugDLL"}[runtime]
-        if compiler == "msvc" or compiler == "intel-cc":
+        elif compiler == "msvc" or compiler == "intel-cc" or compiler == "clang":
             runtime_type = settings.get_safe("compiler.runtime_type")
             rt = "MultiThreadedDebug" if runtime_type == "Debug" else "MultiThreaded"
             if runtime != "static":
                 rt += "DLL"
             config_dict[build_type] = rt
+
+            # If clang is being used the CMake check of compiler will try to create a simple
+            # test application, and will fail because the Debug runtime is not there
+            if compiler == "clang":
+                if config_dict.get("Debug") is None:
+                    clang_rt = "MultiThreadedDebug" + ("DLL" if runtime != "static" else "")
+                    config_dict["Debug"] = clang_rt
+
         return {"vs_runtimes": config_dict}
 
 
@@ -138,7 +153,7 @@ class FPicBlock(Block):
     template = textwrap.dedent("""
         {% if fpic %}
         message(STATUS "Conan toolchain: Setting CMAKE_POSITION_INDEPENDENT_CODE={{ fpic }} (options.fPIC)")
-        set(CMAKE_POSITION_INDEPENDENT_CODE {{ fpic }})
+        set(CMAKE_POSITION_INDEPENDENT_CODE {{ fpic }} CACHE BOOL "Position independent code") 
         {% endif %}
         """)
 
@@ -224,7 +239,7 @@ class CppStdBlock(Block):
 class SharedLibBock(Block):
     template = textwrap.dedent("""
         message(STATUS "Conan toolchain: Setting BUILD_SHARED_LIBS = {{ shared_libs }}")
-        set(BUILD_SHARED_LIBS {{ shared_libs }})
+        set(BUILD_SHARED_LIBS {{ shared_libs }} CACHE BOOL "Build shared libraries")
         """)
 
     def context(self):
@@ -693,10 +708,11 @@ class GenericSystemBlock(Block):
                     toolset = msvc_version_to_toolset_version(compiler_version)
         elif compiler == "clang":
             if generator and "Visual" in generator:
-                if "Visual Studio 16" in generator:
+                if "Visual Studio 16" in generator or "Visual Studio 17" in generator:
                     toolset = "ClangCL"
                 else:
-                    raise ConanException("CMakeToolchain compiler=clang only supported VS 16")
+                    raise ConanException("CMakeToolchain with compiler=clang and a CMake "
+                                         "'Visual Studio' generator requires VS16 or VS17")
         toolset_arch = self._conanfile.conf.get("tools.cmake.cmaketoolchain:toolset_arch")
         if toolset_arch is not None:
             toolset_arch = "host={}".format(toolset_arch)
@@ -713,7 +729,7 @@ class GenericSystemBlock(Block):
         if settings.get_safe("os") == "WindowsCE":
             return settings.get_safe("os.platform")
 
-        if (compiler in ("Visual Studio", "msvc") or compiler_base == "Visual Studio") and \
+        if (compiler in ("Visual Studio", "msvc", "clang") or compiler_base == "Visual Studio") and \
                 generator and "Visual" in generator:
             return {"x86": "Win32",
                     "x86_64": "x64",
@@ -730,7 +746,8 @@ class GenericSystemBlock(Block):
         # TODO: Check if really necessary now that conanvcvars is used
         if "Ninja" in str(generator) and is_msvc(self._conanfile):
             compiler_c = compiler_cpp = "cl"
-        elif os_ == "Windows" and compiler == "clang" and "Visual" not in str(generator):
+        elif os_ == "Windows" and compiler == "clang" and "Visual" not in generator:
+            # definition of compiler only if not using the VS Clang toolset
             compiler_rc = "clang"
             compiler_c = "clang"
             compiler_cpp = "clang++"
diff --git a/conan/tools/env/environment.py b/conan/tools/env/environment.py
index 18c5de0b7..4d43ed19a 100644
--- a/conan/tools/env/environment.py
+++ b/conan/tools/env/environment.py
@@ -350,7 +350,7 @@ class EnvVars:
         filepath, filename = os.path.split(file_location)
         deactivate_file = os.path.join(filepath, "deactivate_{}".format(filename))
         deactivate = textwrap.dedent("""\
-           echo "echo Restoring environment" >> "{deactivate_file}"
+           echo "echo Restoring environment" > "{deactivate_file}"
            for v in {vars}
            do
                is_defined="true"
diff --git a/conan/tools/env/virtualbuildenv.py b/conan/tools/env/virtualbuildenv.py
index edb1c6777..35be4f311 100644
--- a/conan/tools/env/virtualbuildenv.py
+++ b/conan/tools/env/virtualbuildenv.py
@@ -23,9 +23,9 @@ class VirtualBuildEnv:
     def _filename(self):
         f = self.basename
         if self.configuration:
-            f += "-" + self.configuration
+            f += "-" + self.configuration.replace(".", "_")
         if self.arch:
-            f += "-" + self.arch
+            f += "-" + self.arch.replace(".", "_")
         return f
 
     def environment(self):
diff --git a/conan/tools/env/virtualrunenv.py b/conan/tools/env/virtualrunenv.py
index af342e16d..4a22da6e8 100644
--- a/conan/tools/env/virtualrunenv.py
+++ b/conan/tools/env/virtualrunenv.py
@@ -45,9 +45,9 @@ class VirtualRunEnv:
     def _filename(self):
         f = self.basename
         if self.configuration:
-            f += "-" + self.configuration
+            f += "-" + self.configuration.replace(".", "_")
         if self.arch:
-            f += "-" + self.arch
+            f += "-" + self.arch.replace(".", "_")
         return f
 
     def environment(self):
@@ -55,7 +55,10 @@ class VirtualRunEnv:
         very occasional
         """
         runenv = Environment()
-        # FIXME: Missing profile info
+
+        # Top priority: profile
+        profile_env = self._conanfile.runenv
+        runenv.compose_env(profile_env)
         # FIXME: Cache value?
 
         host_req = self._conanfile.dependencies.host
diff --git a/conan/tools/gnu/autotools.py b/conan/tools/gnu/autotools.py
index 0db4bd302..e99735e98 100644
--- a/conan/tools/gnu/autotools.py
+++ b/conan/tools/gnu/autotools.py
@@ -6,7 +6,6 @@ from conans.client.subsystems import subsystem_path, deduce_subsystem
 from conans.client.build import join_arguments
 from conans.tools import args_to_string
 from conan.tools.files import chdir
-from conans.util.runners import check_output_runner
 
 
 class Autotools(object):
diff --git a/conan/tools/gnu/autotoolstoolchain.py b/conan/tools/gnu/autotoolstoolchain.py
index 7269fa2f7..7b0f735df 100644
--- a/conan/tools/gnu/autotoolstoolchain.py
+++ b/conan/tools/gnu/autotoolstoolchain.py
@@ -43,8 +43,8 @@ class AutotoolsToolchain:
         self.fpic = self._conanfile.options.get_safe("fPIC")
         self.msvc_runtime_flag = self._get_msvc_runtime_flag()
 
-        # Cross build
-        self._host = None
+        # Cross build triplets
+        self._host = self._conanfile.conf.get("tools.gnu:host_triplet")
         self._build = None
         self._target = None
 
@@ -56,7 +56,8 @@ class AutotoolsToolchain:
         if cross_building(self._conanfile):
             os_build, arch_build, os_host, arch_host = get_cross_building_settings(self._conanfile)
             compiler = self._conanfile.settings.get_safe("compiler")
-            self._host = _get_gnu_triplet(os_host, arch_host, compiler=compiler)
+            if not self._host:
+                self._host = _get_gnu_triplet(os_host, arch_host, compiler=compiler)
             self._build = _get_gnu_triplet(os_build, arch_build, compiler=compiler)
 
             # Apple Stuff
diff --git a/conan/tools/meson/toolchain.py b/conan/tools/meson/toolchain.py
index d97116943..b75fec4bd 100644
--- a/conan/tools/meson/toolchain.py
+++ b/conan/tools/meson/toolchain.py
@@ -317,6 +317,7 @@ class MesonToolchain(object):
 
         if self.libcxx:
             self.cpp_args.append(self.libcxx)
+            self.cpp_link_args.append(self.libcxx)
         if self.gcc_cxx11_abi:
             self.cpp_args.append("-D{}".format(self.gcc_cxx11_abi))
 
diff --git a/conan/tools/microsoft/msbuilddeps.py b/conan/tools/microsoft/msbuilddeps.py
index 52353f433..3c3d2739c 100644
--- a/conan/tools/microsoft/msbuilddeps.py
+++ b/conan/tools/microsoft/msbuilddeps.py
@@ -25,7 +25,6 @@ class MSBuildDeps(object):
           <PropertyGroup Label="ConanVariables">
             <Conan{{name}}RootFolder>{{root_folder}}</Conan{{name}}RootFolder>
             <Conan{{name}}BinaryDirectories>{{bin_dirs}}</Conan{{name}}BinaryDirectories>
-            <Conan{{name}}Dependencies>{{dependencies}}</Conan{{name}}Dependencies>
             {% if host_context %}
             <Conan{{name}}CompilerFlags>{{compiler_flags}}</Conan{{name}}CompilerFlags>
             <Conan{{name}}LinkerFlags>{{linker_flags}}</Conan{{name}}LinkerFlags>
@@ -134,7 +133,7 @@ class MSBuildDeps(object):
     def _get_valid_xml_format(name):
         return re.compile(r"[.+]").sub("_", name)
 
-    def _vars_props_file(self, dep, name, cpp_info, deps, build):
+    def _vars_props_file(self, dep, name, cpp_info, build):
         """
         content for conan_vars_poco_x86_release.props, containing the variables for 1 config
         This will be for 1 package or for one component of a package
@@ -180,7 +179,6 @@ class MSBuildDeps(object):
             'definitions': "".join("%s;" % d for d in cpp_info.defines),
             'compiler_flags': " ".join(cpp_info.cxxflags + cpp_info.cflags),
             'linker_flags': " ".join(cpp_info.sharedlinkflags + cpp_info.exelinkflags),
-            'dependencies': ";".join(deps),
             'host_context': not build
         }
         formatted_template = Template(self._vars_props, trim_blocks=True,
@@ -291,15 +289,16 @@ class MSBuildDeps(object):
                 comp_filename = "conan_%s.props" % full_comp_name
                 pkg_filename = "conan_%s.props" % dep_name
 
-                public_deps = []
+                public_deps = []  # To store the xml dependencies/file names
                 for r in comp_info.requires:
                     if "::" in r:  # Points to a component of a different package
                         pkg, cmp_name = r.split("::")
                         public_deps.append(pkg if pkg == cmp_name else "{}_{}".format(pkg, cmp_name))
                     else:  # Points to a component of same package
                         public_deps.append("{}_{}".format(dep_name, r))
+                public_deps = [self._get_valid_xml_format(d) for d in public_deps]
                 result[vars_filename] = self._vars_props_file(dep, full_comp_name, comp_info,
-                                                              public_deps, build=build)
+                                                              build=build)
                 result[activate_filename] = self._activate_props_file(full_comp_name, vars_filename,
                                                                       public_deps, build=build)
                 result[comp_filename] = self._dep_props_file(full_comp_name, comp_filename,
@@ -317,7 +316,7 @@ class MSBuildDeps(object):
             public_deps = [self._dep_name(d, build)
                            for r, d in dep.dependencies.direct_host.items() if r.visible]
             result[vars_filename] = self._vars_props_file(dep, dep_name, cpp_info,
-                                                          public_deps, build=build)
+                                                          build=build)
             result[activate_filename] = self._activate_props_file(dep_name, vars_filename,
                                                                   public_deps, build=build)
             result[pkg_filename] = self._dep_props_file(dep_name, pkg_filename, activate_filename,
diff --git a/conan/tools/microsoft/subsystems.py b/conan/tools/microsoft/subsystems.py
index 651b9cb69..55789e8ea 100644
--- a/conan/tools/microsoft/subsystems.py
+++ b/conan/tools/microsoft/subsystems.py
@@ -1,8 +1,6 @@
 from conans.client.subsystems import deduce_subsystem, subsystem_path
 
 
-def unix_path(conanfile, path):
-    if not conanfile.win_bash:
-        return path
-    subsystem = deduce_subsystem(conanfile, scope="build")
+def unix_path(conanfile, path, scope="build"):
+    subsystem = deduce_subsystem(conanfile, scope=scope)
     return subsystem_path(subsystem, path)
diff --git a/conan/tools/microsoft/visual.py b/conan/tools/microsoft/visual.py
index 961e72460..882b867e5 100644
--- a/conan/tools/microsoft/visual.py
+++ b/conan/tools/microsoft/visual.py
@@ -69,12 +69,29 @@ class VCVars:
             return
 
         compiler = conanfile.settings.get_safe("compiler")
-        if compiler != "Visual Studio" and compiler != "msvc":
+        if compiler not in ("Visual Studio", "msvc", "clang"):
             return
 
-        vs_version = vs_ide_version(conanfile)
+        if compiler == "clang":
+            # The vcvars only needed for LLVM/Clang and VS ClangCL, who define runtime
+            if not conanfile.settings.get_safe("compiler.runtime"):
+                # NMake Makefiles will need vcvars activated, for VS target, defined with runtime
+                return
+            toolset_version = conanfile.settings.get_safe("compiler.runtime_version")
+            vs_version = {"v140": "14",
+                          "v141": "15",
+                          "v142": "16",
+                          "v143": "17"}.get(toolset_version)
+            if vs_version is None:
+                raise ConanException("Visual Studio Runtime version (v140-v143) not defined")
+            vcvars_ver = {"v140": "14.0",
+                          "v141": "14.1",
+                          "v142": "14.2",
+                          "v143": "14.3"}.get(toolset_version)
+        else:
+            vs_version = vs_ide_version(conanfile)
+            vcvars_ver = _vcvars_vers(conanfile, compiler, vs_version)
         vcvarsarch = vcvars_arch(conanfile)
-        vcvars_ver = _vcvars_vers(conanfile, compiler, vs_version)
 
         vs_install_path = conanfile.conf.get("tools.microsoft.msbuild:installation_path")
         # The vs_install_path is like
diff --git a/conan/tools/scm/git.py b/conan/tools/scm/git.py
index 4a5c8194e..1032d5b69 100644
--- a/conan/tools/scm/git.py
+++ b/conan/tools/scm/git.py
@@ -87,3 +87,8 @@ class Git(object):
     def checkout(self, commit):
         self._conanfile.output.info("Checkout: {}".format(commit))
         self.run('checkout {}'.format(commit))
+
+    def included_files(self):
+        files = self.run("ls-files --full-name --others --cached --exclude-standard")
+        files = files.splitlines()
+        return files
diff --git a/conan/tools/system/package_manager.py b/conan/tools/system/package_manager.py
index ef281980f..927e8ecd1 100644
--- a/conan/tools/system/package_manager.py
+++ b/conan/tools/system/package_manager.py
@@ -1,5 +1,6 @@
 import platform
 
+from conan.tools.build import cross_building
 from conans.client.graph.graph import CONTEXT_BUILD
 from conans.errors import ConanException
 
@@ -57,7 +58,7 @@ class _SystemPackageManagerTool(object):
 
     def get_package_name(self, package):
         # TODO: should we only add the arch if cross-building?
-        if self._arch in self._arch_names:
+        if self._arch in self._arch_names and cross_building(self._conanfile):
             return "{}{}{}".format(package, self._arch_separator,
                                    self._arch_names.get(self._arch))
         return package
diff --git a/conans/__init__.py b/conans/__init__.py
index 683fbf0a5..dbca8e060 100644
--- a/conans/__init__.py
+++ b/conans/__init__.py
@@ -20,4 +20,4 @@ OAUTH_TOKEN = "oauth_token"
 SERVER_CAPABILITIES = [COMPLEX_SEARCH_CAPABILITY, REVISIONS]  # Server is always with revisions
 DEFAULT_REVISION_V1 = "0"
 
-__version__ = '1.53.0-dev'
+__version__ = '1.54.0-dev'
diff --git a/conans/client/cache/cache.py b/conans/client/cache/cache.py
index a35d2a406..b827edb16 100644
--- a/conans/client/cache/cache.py
+++ b/conans/client/cache/cache.py
@@ -170,7 +170,10 @@ class ClientCache(object):
             self._new_config = ConfDefinition()
             if os.path.exists(self.new_config_path):
                 text = load(self.new_config_path)
-                content = Template(text).render({"platform": platform, "os": os})
+                distro = None
+                if platform.system() in ["Linux", "FreeBSD"]:
+                    import distro
+                content = Template(text).render({"platform": platform, "os": os, "distro": distro})
                 self._new_config.loads(content)
         return self._new_config
 
diff --git a/conans/client/cmd/uploader.py b/conans/client/cmd/uploader.py
index f4e02f9cf..cf1f91024 100644
--- a/conans/client/cmd/uploader.py
+++ b/conans/client/cmd/uploader.py
@@ -109,7 +109,14 @@ class _UploadCollecter(object):
 
                 # TODO: This search of binary packages has to be improved, more robust
                 # So only real packages are retrieved
-                if all_packages or query:
+                if conanfile.upload_policy == "skip":
+                    # TODO: This build_policy CANNOT be conditional, so all binaries will be skipped
+                    #   this could be a future feature, but will require annotating/metadata of the
+                    #   binaries created with this policy value for each binary
+                    self._output.info("{}: Skipping upload of binaries, because "
+                                      "upload_policy='skip'".format(ref))
+                    packages_ids = []
+                elif all_packages or query:
                     if all_packages:
                         query = None
                     # better to do a search, that will retrieve real packages with ConanInfo
diff --git a/conans/client/command.py b/conans/client/command.py
index 9c1469ac8..5b548b805 100644
--- a/conans/client/command.py
+++ b/conans/client/command.py
@@ -1575,7 +1575,7 @@ class Command(object):
         parser_add.add_argument('remote', help='Name of the remote')
         parser_add.add_argument('url', help='URL of the remote')
         parser_add.add_argument('verify_ssl', nargs="?", default="True",
-                                help='Verify SSL certificated. Default True')
+                                help='Verify SSL certificate. Defaulted to True')
         parser_add.add_argument("-i", "--insert", nargs="?", const=0, type=int, action=OnceArgument,
                                 help="insert remote at specific index")
         parser_add.add_argument("-f", "--force", default=False, action='store_true',
@@ -1587,7 +1587,7 @@ class Command(object):
 
         parser_upd.add_argument('url', help='URL')
         parser_upd.add_argument('verify_ssl', nargs="?", default="True",
-                                help='Verify SSL certificated. Default True')
+                                help='Verify SSL certificate. Defaulted to True')
         parser_upd.add_argument("-i", "--insert", nargs="?", const=0, type=int, action=OnceArgument,
                                 help="Insert remote at specific index")
         parser_rename = subparsers.add_parser('rename', help='Update the remote name')
diff --git a/conans/client/conf/__init__.py b/conans/client/conf/__init__.py
index 7bba496bb..c7f6c8bd6 100644
--- a/conans/client/conf/__init__.py
+++ b/conans/client/conf/__init__.py
@@ -93,7 +93,7 @@ _t_default_settings_yml = Template(textwrap.dedent("""
                       "8", "8.1", "8.2", "8.3", "8.4",
                       "9", "9.1", "9.2", "9.3", "9.4",
                       "10", "10.1", "10.2", "10.3",
-                      "11", "11.1", "11.2",
+                      "11", "11.1", "11.2", "11.3",
                       "12"]
             libcxx: [libstdc++, libstdc++11]
             threads: [None, posix, win32]  # Windows MinGW
@@ -123,6 +123,7 @@ _t_default_settings_yml = Template(textwrap.dedent("""
             cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20, 23, gnu23]
             runtime: [None, MD, MT, MTd, MDd, static, dynamic]
             runtime_type: [None, Debug, Release]
+            runtime_version: [None, v140, v141, v142, v143]
         apple-clang: &apple_clang
             version: ["5.0", "5.1", "6.0", "6.1", "7.0", "7.3", "8.0", "8.1", "9.0", "9.1", "10.0", "11.0", "12.0", "13", "13.0", "13.1", "14", "14.0"]
             libcxx: [libstdc++, libc++]
diff --git a/conans/client/generators/__init__.py b/conans/client/generators/__init__.py
index 246af0a51..86d19ae10 100644
--- a/conans/client/generators/__init__.py
+++ b/conans/client/generators/__init__.py
@@ -254,6 +254,7 @@ def write_toolchain(conanfile, path, output):
 
     # tools.env.virtualenv:auto_use will be always True in Conan 2.0
     if conanfile.conf["tools.env.virtualenv:auto_use"]:
+        mkdir(path)
         with chdir(path):
             if conanfile.virtualbuildenv:
                 from conan.tools.env.virtualbuildenv import VirtualBuildEnv
diff --git a/conans/client/installer.py b/conans/client/installer.py
index 5f9faddde..8b2627829 100644
--- a/conans/client/installer.py
+++ b/conans/client/installer.py
@@ -368,13 +368,15 @@ class BinaryInstaller(object):
         else:
             build_str = " ".join(["--build=%s" % pref.ref.name for pref in missing_prefs])
 
+        search_ref = str(ref)
+        search_ref = search_ref + "@" if "@" not in search_ref else search_ref
         raise ConanException(textwrap.dedent('''\
             Missing prebuilt package for '%s'
             Use 'conan search %s --table=table.html -r=remote' and open the table.html file to see available packages
             Or try to build locally from sources with '%s'
 
             More Info at 'https://docs.conan.io/en/latest/faq/troubleshooting.html#error-missing-prebuilt-package'
-            ''' % (missing_pkgs, ref, build_str)))
+            ''' % (missing_pkgs, search_ref, build_str)))
 
     def _download(self, downloads, processed_package_refs):
         """ executes the download of packages (both download and update), only once for a given
diff --git a/conans/client/loader.py b/conans/client/loader.py
index 804d73b50..73d798e49 100644
--- a/conans/client/loader.py
+++ b/conans/client/loader.py
@@ -207,7 +207,7 @@ class ConanFileLoader(object):
             if pkg_settings:
                 tmp_settings.update_values(pkg_settings)
 
-        conanfile.initialize(tmp_settings, profile.env_values, profile.buildenv)
+        conanfile.initialize(tmp_settings, profile.env_values, profile.buildenv, profile.runenv)
         conanfile.conf = profile.conf.get_conanfile_conf(ref_str)
 
     def load_consumer(self, conanfile_path, profile_host, name=None, version=None, user=None,
@@ -293,7 +293,7 @@ class ConanFileLoader(object):
             pkg_settings = package_settings_values.get("&")
             if pkg_settings:
                 tmp_settings.update_values(pkg_settings)
-        conanfile.initialize(Settings(), profile.env_values, profile.buildenv)
+        conanfile.initialize(Settings(), profile.env_values, profile.buildenv, profile.runenv)
         conanfile.conf = profile.conf.get_conanfile_conf(None)
         # It is necessary to copy the settings, because the above is only a constraint of
         # conanfile settings, and a txt doesn't define settings. Necessary for generators,
@@ -344,7 +344,7 @@ class ConanFileLoader(object):
         # for the reference (keep compatibility)
         conanfile = ConanFile(self._output, self._runner, display_name="virtual")
         conanfile.initialize(profile_host.processed_settings.copy(),
-                             profile_host.env_values, profile_host.buildenv)
+                             profile_host.env_values, profile_host.buildenv, profile_host.runenv)
         conanfile.conf = profile_host.conf.get_conanfile_conf(None)
         conanfile.settings = profile_host.processed_settings.copy_values()
 
diff --git a/conans/client/manager.py b/conans/client/manager.py
index ae53663c7..aae89735e 100644
--- a/conans/client/manager.py
+++ b/conans/client/manager.py
@@ -84,6 +84,7 @@ def deps_install(app, ref_or_path, install_folder, base_folder, graph_info, remo
         conanfile.folders.set_base_imports(install_folder)
         conanfile.folders.set_base_generators(base_folder)
         conanfile.folders.set_base_source(base_folder)
+        conanfile.folders.set_base_build(base_folder)
 
     if hasattr(conanfile, "layout") and test:
         install_folder = conanfile.generators_folder
diff --git a/conans/client/migrations_settings.py b/conans/client/migrations_settings.py
index 129714c2a..47713239f 100644
--- a/conans/client/migrations_settings.py
+++ b/conans/client/migrations_settings.py
@@ -3955,7 +3955,7 @@ compiler:
                   "8", "8.1", "8.2", "8.3", "8.4",
                   "9", "9.1", "9.2", "9.3", "9.4",
                   "10", "10.1", "10.2", "10.3",
-                  "11", "11.1", "11.2",
+                  "11", "11.1", "11.2", "11.3",
                   "12"]
         libcxx: [libstdc++, libstdc++11]
         threads: [None, posix, win32]  # Windows MinGW
@@ -3985,6 +3985,7 @@ compiler:
         cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20, 23, gnu23]
         runtime: [None, MD, MT, MTd, MDd, static, dynamic]
         runtime_type: [None, Debug, Release]
+        runtime_version: [None, v140, v141, v142, v143]
     apple-clang: &apple_clang
         version: ["5.0", "5.1", "6.0", "6.1", "7.0", "7.3", "8.0", "8.1", "9.0", "9.1", "10.0", "11.0", "12.0", "13", "13.0", "13.1", "14", "14.0"]
         libcxx: [libstdc++, libc++]
@@ -4026,3 +4027,5 @@ build_type: [None, Debug, Release, RelWithDebInfo, MinSizeRel]
 
 cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20, 23, gnu23]  # Deprecated, use compiler.cppstd
 """
+
+settings_1_54_0 = settings_1_53_0
diff --git a/conans/client/profile_loader.py b/conans/client/profile_loader.py
index 74c0dca15..b484f68af 100644
--- a/conans/client/profile_loader.py
+++ b/conans/client/profile_loader.py
@@ -162,7 +162,7 @@ def _load_profile(text, profile_path, default_folder):
         # Current profile before update with parents (but parent variables already applied)
         doc = ConfigParser(profile_parser.profile_text,
                            allowed_fields=["build_requires", "tool_requires", "settings", "env",
-                                           "options", "conf", "buildenv"])
+                                           "options", "conf", "buildenv", "runenv"])
 
         # Merge the inherited profile with the readed from current profile
         _apply_inner_profile(doc, inherited_profile)
@@ -245,6 +245,10 @@ def _apply_inner_profile(doc, base_profile):
         buildenv = ProfileEnvironment.loads(doc.buildenv)
         base_profile.buildenv.update_profile_env(buildenv)
 
+    if doc.runenv:
+        runenv = ProfileEnvironment.loads(doc.runenv)
+        base_profile.runenv.update_profile_env(runenv)
+
 
 def profile_from_args(profiles, settings, options, env, conf, cwd, cache, build_profile=False):
     """ Return a Profile object, as the result of merging a potentially existing Profile
diff --git a/conans/client/subsystems.py b/conans/client/subsystems.py
index 30cf824b1..7b961d815 100644
--- a/conans/client/subsystems.py
+++ b/conans/client/subsystems.py
@@ -34,10 +34,27 @@ WSL = 'wsl'  # Windows Subsystem for Linux
 SFU = 'sfu'  # Windows Services for UNIX
 
 
-def command_env_wrapper(conanfile, command, envfiles, envfiles_folder):
+def command_env_wrapper(conanfile, command, envfiles, envfiles_folder, scope="build"):
     from conan.tools.env.environment import environment_wrap_command
-    if platform.system() == "Windows" and conanfile.win_bash:  # New, Conan 2.0
-        wrapped_cmd = _windows_bash_wrapper(conanfile, command, envfiles, envfiles_folder)
+    if getattr(conanfile, "conf", None) is None:
+        # TODO: No conf, no profile defined!! This happens at ``export()`` time
+        #  Is it possible to run a self.run() in export() in bash?
+        #  Is it necessary? Shouldn't be
+        return command
+
+    active = conanfile.conf.get("tools.microsoft.bash:active", check_type=bool)
+    subsystem = conanfile.conf.get("tools.microsoft.bash:subsystem")
+
+    if platform.system() == "Windows" and (
+            (conanfile.win_bash and scope == "build") or
+            (conanfile.win_bash_run and scope == "run")):
+        if subsystem is None:
+            raise ConanException("win_bash/win_bash_run defined but no "
+                                 "tools.microsoft.bash:subsystem")
+        if active:
+            wrapped_cmd = environment_wrap_command(envfiles, envfiles_folder, command)
+        else:
+            wrapped_cmd = _windows_bash_wrapper(conanfile, command, envfiles, envfiles_folder)
     else:
         wrapped_cmd = environment_wrap_command(envfiles, envfiles_folder, command)
     return wrapped_cmd
@@ -50,9 +67,8 @@ def _windows_bash_wrapper(conanfile, command, env, envfiles_folder):
 
     subsystem = conanfile.conf.get("tools.microsoft.bash:subsystem")
     shell_path = conanfile.conf.get("tools.microsoft.bash:path")
-    if not subsystem or not shell_path:
-        raise ConanException("The config 'tools.microsoft.bash:subsystem' and "
-                             "'tools.microsoft.bash:path' are "
+    if not shell_path:
+        raise ConanException("The config 'tools.microsoft.bash:path' is "
                              "needed to run commands in a Windows subsystem")
     env = env or []
     if subsystem == MSYS2:
@@ -102,29 +118,35 @@ def deduce_subsystem(conanfile, scope):
     if scope.startswith("build"):
         if hasattr(conanfile, "settings_build"):
             the_os = conanfile.settings_build.get_safe("os")
-            subsystem = conanfile.settings_build.get_safe("os.subsystem")
         else:
             the_os = platform.system()  # FIXME: Temporary fallback until 2.0
-            subsystem = None
     else:
         the_os = conanfile.settings.get_safe("os")
-        subsystem = conanfile.settings.get_safe("os.subsystem")
 
     if not str(the_os).startswith("Windows"):
         return None
 
-    if subsystem is None and not scope.startswith("build"):  # "run" scope do not follow win_bash
+    subsystem = conanfile.conf.get("tools.microsoft.bash:subsystem")
+    if not subsystem:
+        if conanfile.win_bash:
+            raise ConanException("win_bash=True but tools.microsoft.bash:subsystem "
+                                 "configuration not defined")
+        if conanfile.win_bash_run:
+            raise ConanException("win_bash_run=True but tools.microsoft.bash:subsystem "
+                                 "configuration not defined")
         return WINDOWS
-
-    if subsystem is None:  # Not defined by settings, so native windows
-        if not conanfile.win_bash:
-            return WINDOWS
-
-        subsystem = conanfile.conf.get("tools.microsoft.bash:subsystem")
-        if not subsystem:
-            raise ConanException("The config 'tools.microsoft.bash:subsystem' is "
-                                 "needed to run commands in a Windows subsystem")
-    return subsystem
+    active = conanfile.conf.get("tools.microsoft.bash:active", check_type=bool)
+    if active:
+        return subsystem
+
+    if scope.startswith("build"):  # "run" scope do not follow win_bash
+        if conanfile.win_bash:
+            return subsystem
+    elif scope.startswith("run"):
+        if conanfile.win_bash_run:
+            return subsystem
+
+    return WINDOWS
 
 
 def subsystem_path(subsystem, path):
diff --git a/conans/model/conan_file.py b/conans/model/conan_file.py
index 69fe57e1a..b3737b516 100644
--- a/conans/model/conan_file.py
+++ b/conans/model/conan_file.py
@@ -110,6 +110,7 @@ class ConanFile(object):
     topics = None
     homepage = None
     build_policy = None
+    upload_policy = None
     short_paths = False
     apply_env = True  # Apply environment variables from requires deps_env_info and profiles
     exports = None
@@ -143,6 +144,7 @@ class ConanFile(object):
 
     # Run in windows bash
     win_bash = None
+    win_bash_run = None  # For run scope
     tested_reference_str = None
 
     def __init__(self, output, runner, display_name="", user=None, channel=None):
@@ -163,6 +165,7 @@ class ConanFile(object):
         # At the moment only for build_requires, others will be ignored
         self.conf_info = Conf()
         self._conan_buildenv = None  # The profile buildenv, will be assigned initialize()
+        self._conan_runenv = None
         self._conan_node = None  # access to container Node object, to access info, context, deps...
         self._conan_new_cpp_info = None   # Will be calculated lazy in the getter
         self._conan_dependencies = None
@@ -209,8 +212,19 @@ class ConanFile(object):
             self._conan_buildenv = self._conan_buildenv.get_profile_env(ref_str)
         return self._conan_buildenv
 
-    def initialize(self, settings, env, buildenv=None):
+    @property
+    def runenv(self):
+        # Lazy computation of the package runenv based on the profile one
+        from conan.tools.env import Environment
+        if not isinstance(self._conan_runenv, Environment):
+            # TODO: missing user/channel
+            ref_str = "{}/{}".format(self.name, self.version)
+            self._conan_runenv = self._conan_runenv.get_profile_env(ref_str)
+        return self._conan_runenv
+
+    def initialize(self, settings, env, buildenv=None, runenv=None):
         self._conan_buildenv = buildenv
+        self._conan_runenv = runenv
         if isinstance(self.generators, str):
             self.generators = [self.generators]
         # User defined options
@@ -410,9 +424,13 @@ class ConanFile(object):
         """
 
     def run(self, command, output=True, cwd=None, win_bash=False, subsystem=None, msys_mingw=True,
-            ignore_errors=False, run_environment=False, with_login=True, env="conanbuild"):
+            ignore_errors=False, run_environment=False, with_login=True, env="", scope="build"):
         # NOTE: "self.win_bash" is the new parameter "win_bash" for Conan 2.0
 
+        if env == "":  # This default allows not breaking for users with ``env=None`` indicating
+            # they don't want any env-file applied
+            env = "conanbuild" if scope == "build" else "conanrun"
+
         def _run(cmd, _env):
             # FIXME: run in windows bash is not using output
             if platform.system() == "Windows":
@@ -421,7 +439,8 @@ class ConanFile(object):
                                                      msys_mingw=msys_mingw, with_login=with_login)
             envfiles_folder = self.generators_folder or os.getcwd()
             _env = [_env] if _env and isinstance(_env, str) else []
-            wrapped_cmd = command_env_wrapper(self, cmd, _env, envfiles_folder=envfiles_folder)
+            wrapped_cmd = command_env_wrapper(self, cmd, _env, envfiles_folder=envfiles_folder,
+                                              scope=scope)
             return self._conan_runner(wrapped_cmd, output, os.path.abspath(RUN_LOG_NAME), cwd)
 
         if run_environment:
diff --git a/conans/model/conf.py b/conans/model/conf.py
index 4df28790e..b7044625b 100644
--- a/conans/model/conf.py
+++ b/conans/model/conf.py
@@ -28,6 +28,7 @@ BUILT_IN_CONFS = {
     "tools.files.download:retry_wait": "Seconds to wait between download attempts",
     "tools.gnu:make_program": "Indicate path to make program",
     "tools.gnu:define_libcxx11_abi": "Force definition of GLIBCXX_USE_CXX11_ABI=1 for libstdc++11",
+    "tools.gnu:host_triplet": "Custom host triplet to pass to Autotools scripts",
     "tools.google.bazel:configs": "Define Bazel config file",
     "tools.google.bazel:bazelrc_path": "Defines Bazel rc-path",
     "tools.microsoft.msbuild:verbosity": "Verbosity level for MSBuild: 'Quiet', 'Minimal', 'Normal', 'Detailed', 'Diagnostic'",
diff --git a/conans/model/profile.py b/conans/model/profile.py
index f5112a41e..b27714bd5 100644
--- a/conans/model/profile.py
+++ b/conans/model/profile.py
@@ -24,6 +24,7 @@ class Profile(object):
         self.build_requires = OrderedDict()  # ref pattern: list of ref
         self.conf = ConfDefinition()
         self.buildenv = ProfileEnvironment()
+        self.runenv = ProfileEnvironment()
 
         # Cached processed values
         self.processed_settings = None  # Settings with values, and smart completion
@@ -94,6 +95,10 @@ class Profile(object):
             result.append("[buildenv]")
             result.append(self.buildenv.dumps())
 
+        if self.runenv:
+            result.append("[runenv]")
+            result.append(self.runenv.dumps())
+
         return "\n".join(result).replace("\n\n", "\n")
 
     def compose_profile(self, other):
@@ -121,6 +126,7 @@ class Profile(object):
 
         self.conf.update_conf_definition(other.conf)
         self.buildenv.update_profile_env(other.buildenv)  # Profile composition, last has priority
+        self.runenv.update_profile_env(other.runenv)
 
     def update_settings(self, new_settings):
         """Mix the specified settings with the current profile.


Test patch:
diff --git a/conans/test/assets/sources.py b/conans/test/assets/sources.py
index 91e386870..3c27468fc 100644
--- a/conans/test/assets/sources.py
+++ b/conans/test/assets/sources.py
@@ -38,7 +38,7 @@ int {{name}}(){
     #if __x86_64__
     std::cout << "  {{ msg or name }} __x86_64__ defined\n";
     #endif
-  
+
     #if __aarch64__
     std::cout << "  {{ msg or name }} __aarch64__ defined\n";
     #endif
@@ -120,6 +120,130 @@ def gen_function_cpp(**context):
     return t.render(**context)
 
 
+_function_c = r"""
+
+#define STRINGIFY_(x) #x
+#define STRINGIFY(y) STRINGIFY_(y)
+
+{% if name != "main" %}
+#include "{{name}}.h"
+{% endif %}
+
+#include <stdio.h>
+
+{% for it in includes -%}
+#include "{{it}}.h"
+{% endfor %}
+
+int {{name}}(){
+    #ifdef NDEBUG
+    printf("{{ msg or name }}: Release!\n");
+    #else
+    printf("{{ msg or name }}: Debug!\n");
+    #endif
+
+    // ARCHITECTURES
+    #ifdef _M_X64
+    printf("  {{ msg or name }} _M_X64 defined\n");
+    #endif
+
+    #ifdef _M_IX86
+    printf("  {{ msg or name }} _M_IX86 defined\n");
+    #endif
+
+    #ifdef _M_ARM64
+    printf("  {{ msg or name }} _M_ARM64 defined\n");
+    #endif
+
+    #if __i386__
+    printf("  {{ msg or name }} __i386__ defined\n");
+    #endif
+
+    #if __x86_64__
+    printf("  {{ msg or name }} __x86_64__ defined\n");
+    #endif
+
+    #if __aarch64__
+    printf("  {{ msg or name }} __aarch64__ defined\n");
+    #endif
+
+    // Libstdc++
+    #if defined _GLIBCXX_USE_CXX11_ABI
+    printf("  {{ msg or name }} _GLIBCXX_USE_CXX11_ABI %s\n",  STRINGIFY(_GLIBCXX_USE_CXX11_ABI));
+    #endif
+
+    // COMPILER VERSIONS
+    #if _MSC_VER
+    printf("  {{ msg or name }} _MSC_VER%s\n", STRINGIFY(_MSC_VER));
+    #endif
+
+    #if _MSVC_LANG
+    printf("  {{ msg or name }} _MSVC_LANG%s\n", STRINGIFY(_MSVC_LANG));
+    #endif
+
+    #if __cplusplus
+    printf("  {{ msg or name }} __cplusplus%s\n", STRINGIFY(__cplusplus));
+    #endif
+
+    #if __INTEL_COMPILER
+    printf("  {{ msg or name }} __INTEL_COMPILER%s\n", STRINGIFY(__INTEL_COMPILER));
+    #endif
+
+    #if __GNUC__
+    printf("  {{ msg or name }} __GNUC__%s\n", STRINGIFY(__GNUC__));
+    #endif
+
+    #if __GNUC_MINOR__
+    printf("  {{ msg or name }} __GNUC_MINOR__%s\n", STRINGIFY(__GNUC_MINOR__));
+    #endif
+
+    #if __clang_major__
+    printf("  {{ msg or name }} __clang_major__%s\n", STRINGIFY(__clang_major__));
+    #endif
+
+    #if __clang_minor__
+    printf("  {{ msg or name }} __clang_minor__%s\n", STRINGIFY(__clang_minor__));
+    #endif
+
+    #if __apple_build_version__
+    printf("  {{ msg or name }} __apple_build_version__%s\n", STRINGIFY(__apple_build_version__));
+    #endif
+
+    // SUBSYSTEMS
+
+    #if __MSYS__
+    printf("  {{ msg or name }} __MSYS__%s\n", STRINGIFY(__MSYS__));
+    #endif
+
+    #if __MINGW32__
+    printf("  {{ msg or name }} __MINGW32__%s\n", STRINGIFY(__MINGW32__));
+    #endif
+
+    #if __MINGW64__
+    printf("  {{ msg or name }} __MINGW64__%s\n", STRINGIFY(__MINGW64__));
+    #endif
+
+    #if __CYGWIN__
+    printf("  {{ msg or name }} __CYGWIN__%s\n", STRINGIFY(__CYGWIN__));
+    #endif
+
+    {% for it in preprocessor -%}
+    printf("  {{msg}} {{it}}:  %s\n",   {{it}} );
+    {%- endfor %}
+
+    {% for it in calls -%}
+    {{it}}();
+    {% endfor %}
+    return 0;
+}
+"""
+
+
+def gen_function_c(**context):
+    t = Template(_function_c)
+    return t.render(**context)
+
+
 _function_h = """
 #pragma once
 
diff --git a/conans/test/conftest.py b/conans/test/conftest.py
index 80681e1d7..e70221448 100644
--- a/conans/test/conftest.py
+++ b/conans/test/conftest.py
@@ -136,14 +136,14 @@ tools_locations = {
         "disabled": True,
         "platform": "Windows",
         "default": "system",
-        "exe": "mingw32-make",
+        "exe": "clang",
         "system": {"path": {'Windows': "C:/msys64/clang64/bin"}},
     },
     'msys2_mingw64_clang64': {
         "disabled": True,
         "platform": "Windows",
         "default": "system",
-        "exe": "mingw32-make",
+        "exe": "clang",
         "system": {"path": {'Windows': "C:/msys64/mingw64/bin"}},
     },
     'cygwin': {
diff --git a/conans/test/functional/layout/test_editables_layout.py b/conans/test/functional/layout/test_editables_layout.py
index d81dad552..277798608 100644
--- a/conans/test/functional/layout/test_editables_layout.py
+++ b/conans/test/functional/layout/test_editables_layout.py
@@ -253,3 +253,30 @@ def test_cpp_info_components_editable():
     assert "**VAR libs:['hello_var']**" in out
     assert "**VAR cxxflags:['my_cxx_flag_var']**" in out
     assert "**VAR cflags:['my_c_flag_var']**" in out
+
+
+def test_editable_package_folder():
+    """ This test checks the behavior that self.package_folder is NOT defined (i.e = None)
+    for editable packages, so it cannot be used in ``package_info()`` method
+    """
+    c = TestClient()
+    conanfile = textwrap.dedent("""
+        import os
+        from conan import ConanFile
+        from conan.tools.cmake import cmake_layout
+        class Pkg(ConanFile):
+            name = "pkg"
+            version = "0.1"
+            settings = "os", "compiler", "arch", "build_type"
+
+            def package_info(self):
+                self.output.info("PKG FOLDER={}!!!".format(self.package_folder))
+
+            def layout(self):
+                cmake_layout(self)
+        """)
+    c.save({"conanfile.py": conanfile})
+    c.run("create .")
+    c.run("editable add . pkg/0.1")
+    c.run("install pkg/0.1@")
+    assert "pkg/0.1: PKG FOLDER=None!!!"
diff --git a/conans/test/functional/only_source_test.py b/conans/test/functional/only_source_test.py
index a3d64afd0..8a769cbcd 100644
--- a/conans/test/functional/only_source_test.py
+++ b/conans/test/functional/only_source_test.py
@@ -163,3 +163,23 @@ class MyPackage(ConanFile):
 
         other_client.run("install %s" % str(ref))
         self.assertNotIn("Copying sources to build folder", other_client.out)
+
+
+def test_build_policy_installer():
+    c = TestClient(default_server_user=True)
+    conanfile = GenConanfile("pkg", "1.0").with_class_attribute('build_policy = "missing"')\
+                                          .with_class_attribute('upload_policy = "skip"')
+    c.save({"conanfile.py": conanfile})
+    c.run("export .")
+    c.run("install pkg/1.0@")
+    assert "pkg/1.0: Calling build()" in c.out
+    assert "pkg/1.0: Building package from source as defined by build_policy='missing'" in c.out
+
+    # If binary already there it should do nothing
+    c.run("install pkg/1.0@")
+    assert "pkg/1.0: Calling build()" not in c.out
+    assert "pkg/1.0: Building package from source" not in c.out
+
+    c.run("upload * -r=default -c --all")
+    assert "Uploading package" not in c.out
+    assert "pkg/1.0: Skipping upload of binaries, because upload_policy='skip'" in c.out
diff --git a/conans/test/functional/toolchains/cmake/test_cmake.py b/conans/test/functional/toolchains/cmake/test_cmake.py
index 7b5fde432..5451a7fbb 100644
--- a/conans/test/functional/toolchains/cmake/test_cmake.py
+++ b/conans/test/functional/toolchains/cmake/test_cmake.py
@@ -31,13 +31,17 @@ def test_simple_cmake_mingw():
         compiler.libcxx=libstdc++11
         compiler.threads=win32
         compiler.version=11.2
-        cppstd=17
+        compiler.cppstd=17
         """})
     client.run("create . --profile=mingw")
     # FIXME: Note that CI contains 10.X, so it uses another version rather than the profile one
     #  and no one notices. It would be good to have some details in confuser.py to be consistent
-    assert "hello/1.0: __GNUC__" in client.out
-    assert "hello/1.0: __MINGW" in client.out
+    check_exe_run(client.out, "hello/1.0:", "gcc", None, "Release", "x86_64", "17",
+                  subsystem="mingw64", extra_msg="Hello World", cxx11_abi="1")
+    check_vs_runtime("test_package/build/Release/example.exe", client, "15", build_type="Release",
+                     static_runtime=False, subsystem="mingw64")
+
+# TODO: How to link with mingw statically?
 
 
 @pytest.mark.tool_cmake
diff --git a/conans/test/functional/toolchains/cmake/test_cmake_toolchain.py b/conans/test/functional/toolchains/cmake/test_cmake_toolchain.py
index 01453c25b..4e1e9593f 100644
--- a/conans/test/functional/toolchains/cmake/test_cmake_toolchain.py
+++ b/conans/test/functional/toolchains/cmake/test_cmake_toolchain.py
@@ -69,7 +69,8 @@ def test_cmake_toolchain_custom_toolchain():
     assert not os.path.exists(os.path.join(client.current_folder, "conan_toolchain.cmake"))
     presets = load_cmake_presets(client.current_folder)
     assert "mytoolchain.cmake" in presets["configurePresets"][0]["toolchainFile"]
-    assert "binaryDir" not in presets["configurePresets"][0]
+    # Now that we define the build_folder even if not layout() binaryDir is defined
+    assert "binaryDir" in presets["configurePresets"][0]
 
 
 @pytest.mark.skipif(platform.system() != "Darwin",
@@ -1061,3 +1062,71 @@ def test_resdirs_none_cmake_install():
     client.save({"conanfile.py": conanfile, "CMakeLists.txt": cmake, "my_license": "MIT"})
     client.run("create .", assert_error=True)
     assert "Cannot install stuff" in client.out
+
+
+def test_cmake_toolchain_vars_when_option_declared():
+    t = TestClient()
+
+    cmakelists = textwrap.dedent("""
+    cmake_minimum_required(VERSION 2.8) # <---- set this to an old version for old policies
+    cmake_policy(SET CMP0091 NEW) # <-- Needed on Windows
+    project(mylib CXX)
+
+    message("CMake version: ${CMAKE_VERSION}")
+
+    # Set the options AFTER the call to project, that is, after toolchain is loaded
+    option(BUILD_SHARED_LIBS "" ON)
+    option(CMAKE_POSITION_INDEPENDENT_CODE "" OFF)
+
+    add_library(mylib src/mylib.cpp)
+    target_include_directories(mylib PUBLIC include)
+
+    get_target_property(MYLIB_TARGET_TYPE mylib TYPE)
+    get_target_property(MYLIB_PIC mylib POSITION_INDEPENDENT_CODE)
+    message("mylib target type: ${MYLIB_TARGET_TYPE}")
+    message("MYLIB_PIC value: ${MYLIB_PIC}")
+    if(MYLIB_PIC)
+        #Note: the value is "True"/"False" if set by cmake,
+        #       and "ON"/"OFF" if set by Conan
+        message("mylib position independent code: ON")
+    else()
+        message("mylib position independent code: OFF")
+    endif()
+
+    set_target_properties(mylib PROPERTIES PUBLIC_HEADER "include/mylib.h")
+    install(TARGETS mylib)
+    """)
+
+    t.run("new mylib/1.0 --template cmake_lib")
+    t.save({"CMakeLists.txt": cmakelists})
+    
+    # The generated toolchain should set `BUILD_SHARED_LIBS` to `OFF`,
+    # and `CMAKE_POSITION_INDEPENDENT_CODE` to `ON` and the calls to
+    # `option()` in the CMakeLists.txt should respect the existing values.
+    # Note: on *WINDOWS* `fPIC` is not an option for this recipe, so it's invalid
+    #       to pass it to Conan, in which case the value in CMakeLists.txt
+    #       takes precedence.
+    fpic_option = "-o mylib:fPIC=True" if platform.system() != "Windows" else ""
+    fpic_cmake_value = "ON" if platform.system() != "Windows" else "OFF"
+    t.run(f"create . -o mylib:shared=False {fpic_option} --test-folder=None")
+    assert "mylib target type: STATIC_LIBRARY" in t.out
+    assert f"mylib position independent code: {fpic_cmake_value}" in t.out
+
+    # When building manually, ensure the value passed by the toolchain overrides the ones in 
+    # the CMakeLists
+    fpic_option = "-o mylib:fPIC=False" if platform.system() != "Windows" else ""
+    t.run(f"install . -o mylib:shared=False {fpic_option}")
+    t.run_command("cmake -S . -B build/ -DCMAKE_TOOLCHAIN_FILE=build/generators/conan_toolchain.cmake")
+    assert "mylib target type: STATIC_LIBRARY" in t.out
+    assert f"mylib position independent code: OFF" in t.out
+
+    # Note: from this point forward, the CMakeCache is already initialised.
+    # When explicitly overriding `CMAKE_POSITION_INDEPENDENT_CODE` via command line, ensure
+    # this takes precedence to the value defined by the toolchain
+    t.run_command("cmake -S . -B build/ -DCMAKE_POSITION_INDEPENDENT_CODE=ON")
+    assert "mylib target type: STATIC_LIBRARY" in t.out
+    assert "mylib position independent code: ON" in t.out
+
+    t.run_command("cmake -S . -B build/ -DBUILD_SHARED_LIBS=ON")
+    assert "mylib target type: SHARED_LIBRARY" in t.out
+    assert "mylib position independent code: ON" in t.out
diff --git a/conans/test/functional/toolchains/cmake/test_cmake_toolchain_win_clang.py b/conans/test/functional/toolchains/cmake/test_cmake_toolchain_win_clang.py
index 28d12841f..368645491 100644
--- a/conans/test/functional/toolchains/cmake/test_cmake_toolchain_win_clang.py
+++ b/conans/test/functional/toolchains/cmake/test_cmake_toolchain_win_clang.py
@@ -1,18 +1,24 @@
 import platform
+import re
+import tempfile
 import textwrap
 
 import pytest
 
 from conans.client.tools import environment_append
 from conans.test.assets.cmake import gen_cmakelists
-from conans.test.assets.sources import gen_function_cpp
+from conans.test.assets.sources import gen_function_cpp, gen_function_c
+from conans.test.functional.utils import check_vs_runtime, check_exe_run
 from conans.test.utils.tools import TestClient
 from conans.util.files import save
 
 
 @pytest.fixture
 def client():
-    c = TestClient()
+    # IMPORTANT: This cannot use the default tests location, if in Windows, it can be another unit
+    # like F and Visual WONT FIND ClangCL
+    t = tempfile.mkdtemp(suffix='conans')
+    c = TestClient(cache_folder=t)
     save(c.cache.new_config_path, "tools.env.virtualenv:auto_use=True")
     clang_profile = textwrap.dedent("""
         [settings]
@@ -40,7 +46,8 @@ def client():
                 cmake.configure()
                 cmake.build()
                 cmd = os.path.join(self.cpp.build.bindirs[0], "my_app")
-                self.run(cmd, env=["conanrunenv"])
+                self.output.info("MYCMD={}!".format(os.path.abspath(cmd)))
+                self.run(cmd)
         """)
     c.save({"conanfile.py": conanfile,
             "clang": clang_profile,
@@ -50,35 +57,204 @@ def client():
 
 
 @pytest.mark.tool_cmake
-@pytest.mark.tool_mingw64
-@pytest.mark.tool_clang(version="12")
+@pytest.mark.tool_clang(version="13")
+@pytest.mark.skipif(platform.system() != "Windows", reason="requires Win")
+class TestLLVMClang:
+    """ External LLVM/clang, with different CMake generators
+    This links always with the VS runtime, it is built-in
+    """
+
+    @pytest.mark.tool_mingw64
+    @pytest.mark.tool_visual_studio(version="17")
+    @pytest.mark.tool_clang(version="13")  # repeated, for priority over the mingw64 clang
+    @pytest.mark.parametrize("runtime", ["static", "dynamic"])
+    def test_clang_mingw(self, client, runtime):
+        """ compiling with an LLVM-clang installed, which uses by default the
+        VS runtime
+        """
+        client.run("create . pkg/0.1@ -pr=clang "
+                   "-s compiler.runtime_version=v143 "
+                   "-s compiler.runtime={}".format(runtime))
+        # clang compilations in Windows will use MinGW Makefiles by default
+        assert 'cmake -G "MinGW Makefiles"' in client.out
+        assert "GNU-like command-line" in client.out
+        assert "main __clang_major__13" in client.out
+        assert "main _MSC_VER193" in client.out
+        assert "main _MSVC_LANG2014" in client.out
+        assert "main _M_X64 defined" in client.out
+        assert "main __x86_64__ defined" in client.out
+
+        check_exe_run(client.out, "main", "clang", None, "Release", "x86_64", "14")
+        cmd = re.search(r"MYCMD=(.*)!", str(client.out)).group(1)
+        cmd = cmd + ".exe"
+        static_runtime = (runtime == "static")
+        check_vs_runtime(cmd, client, "17", build_type="Release", static_runtime=static_runtime)
+
+    @pytest.mark.tool_visual_studio(version="17")
+    @pytest.mark.parametrize("generator", ["Ninja", "NMake Makefiles"])
+    def test_clang_cmake_ninja_nmake(self, client, generator):
+        client.run("create . pkg/0.1@ -pr=clang -s compiler.runtime=dynamic "
+                   "-s compiler.runtime_version=v143 "
+                   '-c tools.cmake.cmaketoolchain:generator="{}"'.format(generator))
+
+        assert 'cmake -G "{}"'.format(generator) in client.out
+        assert "GNU-like command-line" in client.out
+        assert "main __clang_major__13" in client.out
+        assert "main _MSC_VER193" in client.out
+        assert "main _MSVC_LANG2014" in client.out
+        assert "main _M_X64 defined" in client.out
+        assert "main __x86_64__ defined" in client.out
+        cmd = re.search(r"MYCMD=(.*)!", str(client.out)).group(1)
+        cmd = cmd + ".exe"
+        check_vs_runtime(cmd, client, "17", build_type="Release", static_runtime=False)
+
+    @pytest.mark.tool_visual_studio(version="16")
+    @pytest.mark.tool_clang(version="12")  # repeated, for priority over the mingw64 clang
+    def test_clang_cmake_runtime_version(self, client):
+        generator = "Ninja"
+        # Make sure that normal CMakeLists with verify=False works
+        client.save({"CMakeLists.txt": gen_cmakelists(verify=False, appname="my_app",
+                                                      appsources=["src/main.cpp"])})
+        client.run("create . pkg/0.1@ -pr=clang -s compiler.runtime=dynamic -s compiler.cppstd=17 "
+                   "-s compiler.runtime_version=v142 "
+                   '-c tools.cmake.cmaketoolchain:generator="{}"'.format(generator))
+
+        assert 'cmake -G "{}"'.format(generator) in client.out
+        assert "GNU-like command-line" in client.out
+        assert "main __clang_major__12" in client.out
+        # Check this! Clang compiler in Windows is reporting MSC_VER and MSVC_LANG!
+        assert "main _MSC_VER192" in client.out
+        assert "main _MSVC_LANG2017" in client.out
+        assert "main _M_X64 defined" in client.out
+        assert "main __x86_64__ defined" in client.out
+        cmd = re.search(r"MYCMD=(.*)!", str(client.out)).group(1)
+        cmd = cmd + ".exe"
+        check_vs_runtime(cmd, client, "16", build_type="Release", static_runtime=False)
+
+
 @pytest.mark.skipif(platform.system() != "Windows", reason="requires Win")
-def test_clang(client):
-    client.run("create . pkg/0.1@ -pr=clang")
-    # clang compilations in Windows will use MinGW Makefiles by default
-    assert 'cmake -G "MinGW Makefiles"' in client.out
-    assert "main __clang_major__12" in client.out
-    # Check this! Clang compiler in Windows is reporting MSC_VER and MSVC_LANG!
-    assert "main _MSC_VER19" in client.out
-    assert "main _MSVC_LANG2014" in client.out
+class TestVSClangCL:
+    """
+    This is also LLVM/Clang, but distributed with the VS installation
+    """
+    @pytest.mark.tool_cmake(version="3.23")
+    @pytest.mark.tool_visual_studio(version="17")
+    def test_clang_visual_studio_generator(self, client):
+        """ This is using the embedded ClangCL compiler, not the external one"""
+        generator = "Visual Studio 17"
+        client.run("create . pkg/0.1@ -pr=clang -s compiler.runtime=dynamic "
+                   "-s compiler.cppstd=17 -s compiler.runtime_version=v143 "
+                   '-c tools.cmake.cmaketoolchain:generator="{}"'.format(generator))
+        assert 'cmake -G "{}"'.format(generator) in client.out
+        assert "MSVC-like command-line" in client.out
+        assert "main __clang_major__14" in client.out
+        # Check this! Clang compiler in Windows is reporting MSC_VER and MSVC_LANG!
+        assert "main _MSC_VER193" in client.out
+        assert "main _MSVC_LANG2017" in client.out
+        assert "main _M_X64 defined" in client.out
+        assert "main __x86_64__ defined" in client.out
+        assert "-m64" not in client.out
+        cmd = re.search(r"MYCMD=(.*)!", str(client.out)).group(1)
+        cmd = cmd + ".exe"
+        check_vs_runtime(cmd, client, "16", build_type="Release", static_runtime=False)
 
 
 @pytest.mark.tool_cmake
-@pytest.mark.tool_clang(version="12")
 @pytest.mark.skipif(platform.system() != "Windows", reason="requires Win")
-def test_clang_cmake_ninja(client):
-    client.run("create . pkg/0.1@ -pr=clang -c tools.cmake.cmaketoolchain:generator=Ninja")
-    assert 'cmake -G "Ninja"' in client.out
-    assert "main __clang_major__12" in client.out
-    # Check this! Clang compiler in Windows is reporting MSC_VER and MSVC_LANG!
-    assert "main _MSC_VER19" in client.out
-    assert "main _MSVC_LANG2014" in client.out
+class TestMsysClang:
+    @pytest.mark.tool_msys2_clang64
+    def test_msys2_clang(self, client):
+        """ Using the msys2 clang64 subsystem
+        We are not really injecting the msys2 root with make, so using
+        MinGW Makefiles
+        """
+        client.run('create . pkg/0.1@ -pr=clang -s os.subsystem=msys2 '
+                   '-s compiler.libcxx=libc++ '
+                   '-c tools.cmake.cmaketoolchain:generator="MinGW Makefiles"')
+        # clang compilations in Windows will use MinGW Makefiles by default
+        assert 'cmake -G "MinGW Makefiles"' in client.out
+        # TODO: Version is still not controlled
+        assert "main __clang_major__14" in client.out
+        # Not using libstdc++
+        assert "_GLIBCXX_USE_CXX11_ABI" not in client.out
+        assert "main __cplusplus2014" in client.out
+        assert "main __GNUC__" in client.out
+        assert "main __MINGW32__1" in client.out
+        assert "main __MINGW64__1" in client.out
+        assert "main _MSC_" not in client.out
+        assert "main _MSVC_" not in client.out
+        assert "main _M_X64 defined" in client.out
+        assert "main __x86_64__ defined" in client.out
+
+        cmd = re.search(r"MYCMD=(.*)!", str(client.out)).group(1)
+        cmd = cmd + ".exe"
+        check_vs_runtime(cmd, client, "16", build_type="Release",
+                         static_runtime=False, subsystem="clang64")
+
+    @pytest.mark.tool_msys2_mingw64_clang64
+    def test_msys2_clang_mingw(self, client):
+        """ compiling with the clang INSIDE mingw, which uses the
+        MinGW runtime, not the MSVC one
+        For 32 bits, it doesn't seem possible to install the toolchain
+        For 64 bits require "pacman -S mingw-w64-x86-clang++"
+        """
+        # TODO: This should probably go to the ``os.subsystem=ming64" but lets do it in other PR
+        client.run('create . pkg/0.1@ -pr=clang '
+                   '-s compiler.libcxx=libstdc++')
+        # clang compilations in Windows will use MinGW Makefiles by default
+        assert 'cmake -G "MinGW Makefiles"' in client.out
+        # TODO: Version is still not controlled
+        assert "main __clang_major__14" in client.out
+        assert "main _GLIBCXX_USE_CXX11_ABI 0" in client.out
+        assert "main __cplusplus2014" in client.out
+        assert "main __GNUC__" in client.out
+        assert "main __MINGW32__1" in client.out
+        assert "main __MINGW64__1" in client.out
+        assert "main _MSC_" not in client.out
+        assert "main _MSVC_" not in client.out
+        assert "main _M_X64 defined" in client.out
+        assert "main __x86_64__ defined" in client.out
+
+        cmd = re.search(r"MYCMD=(.*)!", str(client.out)).group(1)
+        cmd = cmd + ".exe"
+        check_vs_runtime(cmd, client, "16", build_type="Release",
+                         static_runtime=False, subsystem="mingw64")
+
+    @pytest.mark.tool_msys2_clang64
+    def test_clang_pure_c(self, client):
+        """ compiling with the clang INSIDE mingw, which uses the
+        MinGW runtime, not the MSVC one
+        For 32 bits, it doesn't seem possible to install the toolchain
+        For 64 bits require "pacman -S mingw-w64-x86-clang++"
+        """
+        client.save({"CMakeLists.txt": gen_cmakelists(verify=False, language="C", appname="my_app",
+                                                      appsources=["src/main.c"]),
+                     "src/main.c": gen_function_c(name="main")})
+        client.run(f"create . pkg/0.1@ -pr=clang")
+        # clang compilations in Windows will use MinGW Makefiles by default
+        assert 'cmake -G "MinGW Makefiles"' in client.out
+        assert "main __clang_major__14" in client.out
+        assert "GLIBCXX" not in client.out
+        assert "cplusplus" not in client.out
+        assert "main __GNUC__" in client.out
+        assert "main __MINGW32__1" in client.out
+        assert "main __MINGW64__1" in client.out
+        assert "main _MSC_" not in client.out
+        assert "main _MSVC_" not in client.out
+        assert "main _M_X64 defined" in client.out
+        assert "main __x86_64__ defined" in client.out
+
+        cmd = re.search(r"MYCMD=(.*)!", str(client.out)).group(1)
+        cmd = cmd + ".exe"
+        # static_runtime equivalent to C, for checking, no dep on libc++
+        check_vs_runtime(cmd, client, "16", build_type="Release", static_runtime=True,
+                         subsystem="clang64")
 
 
 @pytest.mark.tool_cmake
 @pytest.mark.tool_clang(version="12")
 @pytest.mark.skipif(platform.system() != "Windows", reason="requires Win")
-def test_clang_cmake_ninja_custom_cxx(client):
+def test_error_clang_cmake_ninja_custom_cxx(client):
     with environment_append({"CXX": "/no/exist/clang++"}):
         client.run("create . pkg/0.1@ -pr=clang -c tools.cmake.cmaketoolchain:generator=Ninja",
                    assert_error=True)
@@ -100,26 +276,3 @@ def test_clang_cmake_ninja_custom_cxx(client):
                assert_error=True)
     assert 'Could not find compiler' in client.out
     assert '/no/exist/clang++' in client.out
-
-
-@pytest.mark.tool_cmake
-@pytest.mark.tool_visual_studio(version="16")  # With Clang distributed in VS!
-@pytest.mark.skipif(platform.system() != "Windows", reason="requires Win")
-def test_clang_cmake_visual(client):
-    clang_profile = textwrap.dedent("""
-        [settings]
-        os=Windows
-        arch=x86_64
-        build_type=Release
-        compiler=clang
-        compiler.version=11
-        """)
-    # TODO: Clang version is unused, it can change, still 11 from inside VS is used
-    client.save({"clang": clang_profile})
-    client.run("create . pkg/0.1@ -pr=clang "
-               '-c tools.cmake.cmaketoolchain:generator="Visual Studio 16"')
-    assert 'cmake -G "Visual Studio 16"' in client.out
-    assert "main __clang_major__11" in client.out
-    # Check this! Clang compiler in Windows is reporting MSC_VER and MSVC_LANG!
-    assert "main _MSC_VER19" in client.out
-    assert "main _MSVC_LANG2014" in client.out
diff --git a/conans/test/functional/toolchains/gnu/autotools/test_crossbuild_triplet.py b/conans/test/functional/toolchains/gnu/autotools/test_crossbuild_triplet.py
new file mode 100644
index 000000000..d379b17b4
--- /dev/null
+++ b/conans/test/functional/toolchains/gnu/autotools/test_crossbuild_triplet.py
@@ -0,0 +1,53 @@
+import platform
+import pytest
+import textwrap
+
+from conans.test.utils.tools import TestClient
+
+@pytest.mark.skipif(platform.system() not in  ["Darwin", "Linux"], reason="Autotools on Linux or macOS")
+def test_crossbuild_triplet_from_conf():
+
+    settings_yml = textwrap.dedent("""
+        os:
+            Linux:
+            Windows:
+        arch: [x86_64, hexagon]
+        compiler:
+            gcc:
+                version: ["10", "11"]
+                libcxx: [libstdc++11]
+        build_type: [None, Debug, Release]
+        """)
+    
+    host_profile = textwrap.dedent("""
+        [settings]
+        os=Linux
+        arch=hexagon
+        compiler=gcc
+        compiler.version=10
+        compiler.libcxx=libstdc++11
+        build_type=Release
+        [conf]
+        tools.gnu:host_triplet=hexagon-acme-linux-gnu
+    """)
+
+    build_profile = textwrap.dedent("""
+        [settings]
+        os=Linux
+        arch=x86_64
+        compiler=gcc
+        compiler.version=11
+        compiler.libcxx=libstdc++11
+        build_type=Release   
+    """)
+
+    client = TestClient(path_with_spaces=False)
+    client.save({client.cache.settings_path: settings_yml})
+    client.save({"host_profile": host_profile})
+    client.save({"build_profile": build_profile})
+
+    client.run("new hello/0.1 --template=autotools_lib")
+    client.run("create . --profile:build=build_profile --profile:host=host_profile -tf None")
+
+    assert "--host=hexagon-acme-linux-gnu" in client.out
+    assert "checking host system type... hexagon-acme-linux-gnu" in client.out
diff --git a/conans/test/functional/toolchains/gnu/test_v2_autotools_template.py b/conans/test/functional/toolchains/gnu/test_v2_autotools_template.py
index 81685594a..240f3213b 100644
--- a/conans/test/functional/toolchains/gnu/test_v2_autotools_template.py
+++ b/conans/test/functional/toolchains/gnu/test_v2_autotools_template.py
@@ -26,6 +26,23 @@ def test_autotools_lib_template():
     package_folder = client.cache.package_layout(pref.ref).package(pref)
     assert os.path.exists(os.path.join(package_folder, "include", "hello.h"))
 
+    # Local flow for shared library works
+    client.save({}, clean_first=True)
+    client.run("new hello/0.1 --template=autotools_lib")
+    client.run("install . -if install_shared -o hello:shared=True")
+    client.run("build . -if=install_shared")
+    client.run("export-pkg . hello/0.1@ -if=install_shared -o hello:shared=True")
+    package_id = re.search(r"Packaging to (\S+)", str(client.out)).group(1)
+    pref = PackageReference(ConanFileReference.loads("hello/0.1"), package_id)
+    package_folder = client.cache.package_layout(pref.ref).package(pref)
+
+    if platform.system() == "Darwin":
+        # Ensure that install name of dylib is patched
+        client.run_command(f"otool -L {package_folder}/lib/libhello.0.dylib")
+        assert "@rpath/libhello.0.dylib" in client.out
+    elif platform.system() == "Linux":
+        assert os.path.exists(os.path.join(package_folder, "lib", "libhello.so.0"))
+
     # Create works
     client.run("create .")
     assert "hello/0.1: Hello World Release!" in client.out
@@ -269,6 +286,10 @@ def test_autotools_fix_shared_libs():
         libbye_la_HEADERS = bye.h
         libbye_ladir = $(includedir)
         libbye_la_LIBADD = libhello.la
+
+        bin_PROGRAMS = main
+        main_SOURCES = main.cpp
+        main_LDADD = libhello.la libbye.la
     """)
 
     test_src = textwrap.dedent("""
@@ -280,6 +301,7 @@ def test_autotools_fix_shared_libs():
         "src/makefile.am": makefile_am,
         "src/bye.cpp": bye_cpp,
         "src/bye.h": bye_h,
+        "src/main.cpp": test_src,
         "test_package/main.cpp": test_src,
         "conanfile.py": conanfile,
     })
@@ -304,5 +326,13 @@ def test_autotools_fix_shared_libs():
     assert "@rpath/libhello.dylib (compatibility version 1.0.0, current version 1.0.0)" in client.out
     assert "@rpath/libbye.dylib (compatibility version 1.0.0, current version 1.0.0)" in client.out
 
+    # app rpath fixed in executable
+    exe_path = os.path.join(package_folder, "bin", "main")
+    client.run_command("otool -L {}".format(exe_path))
+    assert "@rpath/libhello.dylib" in client.out
+    client.run_command(exe_path)
+    assert "Bye, bye!" in client.out
+
+    # Running the test-package also works
     client.run("test test_package hello/0.1@ -o hello:shared=True")
     assert "Bye, bye!" in client.out
diff --git a/conans/test/functional/toolchains/microsoft/test_msbuilddeps.py b/conans/test/functional/toolchains/microsoft/test_msbuilddeps.py
index 9c6a9120b..f36d3bede 100644
--- a/conans/test/functional/toolchains/microsoft/test_msbuilddeps.py
+++ b/conans/test/functional/toolchains/microsoft/test_msbuilddeps.py
@@ -1008,4 +1008,4 @@ def test_build_requires_transitives():
     assert "conan_dep_build.props" in tool
     assert "conan_dep.props" not in tool
     tool_vars = c.load("conan_tool_build_vars_release_x64.props")
-    assert "<Conantool_buildDependencies>dep_build</Conantool_buildDependencies>" in tool_vars
+    assert "<Conantool_buildRootFolder>" in tool_vars
diff --git a/conans/test/functional/tools/scm/test_git.py b/conans/test/functional/tools/scm/test_git.py
index cd1e47c06..499319541 100644
--- a/conans/test/functional/tools/scm/test_git.py
+++ b/conans/test/functional/tools/scm/test_git.py
@@ -585,3 +585,72 @@ class TestConanFileSubfolder:
         c.init_git_repo()
         c.run("export conan")
         assert "pkg/0.1: git version" in c.out
+
+
+class TestGitIncluded:
+    def test_git_included(self):
+        conanfile = textwrap.dedent("""
+            import os
+            import shutil
+            from conan import ConanFile
+            from conan.tools.scm import Git
+
+            class Pkg(ConanFile):
+                name = "pkg"
+                version = "0.1"
+
+                def export_sources(self):
+                    git = Git(self)
+                    included = git.included_files()
+                    for i in included:
+                        dst =  os.path.join(self.export_sources_folder, i)
+                        os.makedirs(os.path.dirname(dst), exist_ok=True)
+                        print("COPYING ", i, dst)
+                        shutil.copy2(i, dst)
+
+                def source(self):
+                    self.output.info("SOURCES: {}!!".format(sorted(os.listdir("."))))
+                    self.output.info("SOURCES_SUB: {}!!".format(sorted(os.listdir("sub"))))
+            """)
+
+        c = TestClient()
+        c.save({"conanfile.py": conanfile,
+                ".gitignore": "*.txt",
+                "myfile.txt": "test",
+                "myfile.other": "othertest",
+                "sub/otherfile": "other"})
+        c.init_git_repo()
+        c.run("create .")
+        assert "pkg/0.1: SOURCES: ['.gitignore', 'myfile.other', 'sub']!!" in c.out
+        assert "pkg/0.1: SOURCES_SUB: ['otherfile']!!" in c.out
+
+    def test_git_included_subfolder(self):
+        conanfile = textwrap.dedent("""
+            import os
+            import shutil
+            from conan import ConanFile
+            from conan.tools.scm import Git
+
+            class Pkg(ConanFile):
+                name = "pkg"
+                version = "0.1"
+
+                def export_sources(self):
+                    git = Git(self, "src")
+                    included = git.included_files()
+                    for i in included:
+                        shutil.copy2(i, self.export_sources_folder)
+
+                def source(self):
+                    self.output.info("SOURCES: {}!!".format(sorted(os.listdir("."))))
+            """)
+
+        c = TestClient()
+        c.save({"conanfile.py": conanfile,
+                ".gitignore": "*.txt",
+                "somefile": "some",
+                "src/myfile.txt": "test",
+                "src/myfile.other": "othertest"})
+        c.init_git_repo()
+        c.run("create .")
+        assert "pkg/0.1: SOURCES: ['myfile.other']!!" in c.out
diff --git a/conans/test/functional/tools/system/package_manager_test.py b/conans/test/functional/tools/system/package_manager_test.py
index 210f6434d..89d27e705 100644
--- a/conans/test/functional/tools/system/package_manager_test.py
+++ b/conans/test/functional/tools/system/package_manager_test.py
@@ -50,11 +50,10 @@ def test_apt_install_substitutes():
     client.save({"conanfile.py": conanfile_py.format(installs)})
     client.run("create . test/1.0@ -c tools.system.package_manager:mode=install "
                "-c tools.system.package_manager:sudo=True", assert_error=True)
-
-    assert "dpkg-query: no packages found matching non-existing1:amd64" in client.out
-    assert "dpkg-query: no packages found matching non-existing2:amd64" in client.out
-    assert "dpkg-query: no packages found matching non-existing3:amd64" in client.out
-    assert "dpkg-query: no packages found matching non-existing4:amd64" in client.out
+    assert "dpkg-query: no packages found matching non-existing1" in client.out
+    assert "dpkg-query: no packages found matching non-existing2" in client.out
+    assert "dpkg-query: no packages found matching non-existing3" in client.out
+    assert "dpkg-query: no packages found matching non-existing4" in client.out
     assert "ERROR: while executing system_requirements(): " \
            "None of the installs for the package substitutes succeeded." in client.out
 
@@ -88,8 +87,8 @@ def test_build_require():
             tool_requires = "tool_require/1.0"
         """)})
     client.run("create consumer.py consumer/1.0@ -s:b arch=armv8 -s:h arch=x86 --build=missing")
-    assert "dpkg-query: no packages found matching non-existing1:arm64" in client.out
-    assert "dpkg-query: no packages found matching non-existing2:arm64" in client.out
+    assert "dpkg-query: no packages found matching non-existing1" in client.out
+    assert "dpkg-query: no packages found matching non-existing2" in client.out
     assert "missing: ['non-existing1', 'non-existing2']" in client.out
 
 
diff --git a/conans/test/functional/tools/test_apple_tools.py b/conans/test/functional/tools/test_apple_tools.py
index 15fba0bcf..cfb351a67 100644
--- a/conans/test/functional/tools/test_apple_tools.py
+++ b/conans/test/functional/tools/test_apple_tools.py
@@ -3,6 +3,7 @@ import textwrap
 
 import pytest
 
+from conans.test.assets.genconanfile import GenConanfile
 from conans.test.utils.tools import TestClient
 
 
@@ -24,3 +25,96 @@ def test_xcrun():
     client.save({"conanfile.py": conanfile}, clean_first=True)
     client.run("create .")
     assert "Xcode.app/Contents/Developer/Platforms/MacOSX.platform" in client.out
+
+
+@pytest.mark.skipif(platform.system() != "Darwin", reason="Requires Xcode")
+def test_xcrun_in_tool_requires():
+    # https://github.com/conan-io/conan/issues/12260
+    client = TestClient()
+    tool = textwrap.dedent("""
+        from conan import ConanFile
+        from conan.tools.apple import XCRun
+        class Pkg(ConanFile):
+            settings = "os", "compiler", "build_type", "arch"
+
+            def package_info(self):
+                xcrun = XCRun(self{})
+                self.output.info("sdk: %s" % xcrun.sdk)
+        """)
+    client.save({"br.py": tool.format(", use_settings_target=True")})
+    client.run("export br.py br/0.1@")
+
+    conanfile = textwrap.dedent("""
+        from conan import ConanFile
+        class Pkg(ConanFile):
+            settings = "os", "compiler", "build_type", "arch"
+            tool_requires = "br/0.1"
+        """)
+
+    profile_ios = textwrap.dedent("""
+        include(default)
+        [settings]
+        os=iOS
+        os.version=15.4
+        os.sdk=iphoneos
+        os.sdk_version=15.0
+        arch=armv8
+    """)
+
+    client.save({"conanfile.py": conanfile, "profile_ios": profile_ios})
+    client.run("create . pkg/1.0@ -pr:h=./profile_ios -pr:b=default --build")
+    assert "br/0.1: sdk: iphoneos15.0" in client.out
+    assert "br/0.1: sdk: macosx" not in client.out
+
+    client.save({"br.py": tool.format("")})
+    client.run("export br.py br/0.1@")
+    client.run("create . pkg/1.0@ -pr:h=./profile_ios -pr:b=default --build")
+    assert "br/0.1: sdk: iphoneos15.0" not in client.out
+    assert "br/0.1: sdk: macosx" in client.out
+
+
+@pytest.mark.skipif(platform.system() != "Darwin", reason="Requires Xcode")
+def test_xcrun_in_required_by_tool_requires():
+    """
+    ConanCenter case, most typical, openssl builds with autotools so needs the sysroot
+    and is a require by cmake so in the build context it needs the settings_build, not
+    the settings_target, that's why the use_settings_target default is False
+    """
+    client = TestClient()
+
+    openssl = textwrap.dedent("""
+        from conan import ConanFile
+        from conan.tools.apple import XCRun
+        class Pkg(ConanFile):
+            settings = "os", "compiler", "build_type", "arch"
+            def build(self):
+                xcrun = XCRun(self)
+                self.output.info("sdk for building openssl: %s" % xcrun.sdk)
+        """)
+
+    consumer = textwrap.dedent("""
+        from conan import ConanFile
+        class Pkg(ConanFile):
+            settings = "os", "compiler", "build_type", "arch"
+            tool_requires = "cmake/1.0"
+        """)
+
+    profile_ios = textwrap.dedent("""
+        include(default)
+        [settings]
+        os=iOS
+        os.version=15.4
+        os.sdk=iphoneos
+        os.sdk_version=15.0
+        arch=armv8
+    """)
+
+    client.save({"cmake.py": GenConanfile("cmake", "1.0").with_requires("openssl/1.0"),
+                 "openssl.py": openssl,
+                 "consumer.py": consumer,
+                 "profile_ios": profile_ios})
+
+    client.run("export openssl.py openssl/1.0@")
+    client.run("export cmake.py")
+    client.run("create consumer.py consumer/1.0@ -pr:h=./profile_ios -pr:b=default --build")
+    assert "sdk for building openssl: macosx" in client.out
diff --git a/conans/test/functional/utils.py b/conans/test/functional/utils.py
index ddcda2346..e318c6c6d 100644
--- a/conans/test/functional/utils.py
+++ b/conans/test/functional/utils.py
@@ -75,12 +75,15 @@ def check_vs_runtime(artifact, client, vs_version, build_type, architecture="amd
 
 
 def check_exe_run(output, names, compiler, version, build_type, arch, cppstd, definitions=None,
-                  cxx11_abi=None, subsystem=None):
+                  cxx11_abi=None, subsystem=None, extra_msg=""):
     output = str(output)
     names = names if isinstance(names, list) else [names]
 
     for name in names:
-        assert "{}: {}".format(name, build_type) in output
+        if extra_msg:  # For ``conan new`` templates
+            assert "{} {} {}".format(name, extra_msg, build_type) in output
+        else:
+            assert "{}: {}".format(name, extra_msg, build_type) in output
         if compiler == "msvc":
             if arch == "x86":
                 assert "{} _M_IX86 defined".format(name) in output
diff --git a/conans/test/integration/command/install/install_missing_dep_test.py b/conans/test/integration/command/install/install_missing_dep_test.py
index 09e7d1412..eb631db51 100644
--- a/conans/test/integration/command/install/install_missing_dep_test.py
+++ b/conans/test/integration/command/install/install_missing_dep_test.py
@@ -46,4 +46,5 @@ class InstallMissingDependency(unittest.TestCase):
         client.save({"conanfile.py": conanfile}, clean_first=True)
         client.run("create . pkg/1.0@", assert_error=True)
         self.assertIn("ERROR: Missing prebuilt package for 'dep1/1.0', 'dep2/1.0'", client.out)
+        assert "conan search dep1/1.0@ --table=table.html" in client.out
         self.assertIn("Or try to build locally from sources with '--build=dep1 --build=dep2'", client.out)
diff --git a/conans/test/integration/configuration/conf/test_conf.py b/conans/test/integration/configuration/conf/test_conf.py
index 5bdeb5477..9310a156b 100644
--- a/conans/test/integration/configuration/conf/test_conf.py
+++ b/conans/test/integration/configuration/conf/test_conf.py
@@ -177,10 +177,15 @@ def test_composition_conan_conf_different_data_types_by_cli_arg(client):
     assert "tools.microsoft.msbuildtoolchain:compile_options${'ExceptionHandling': 'Async'}" in client.out
 
 
-@pytest.mark.skipif(six.PY2, reason="only Py3")
 def test_jinja_global_conf(client):
     save(client.cache.new_config_path, "user.mycompany:parallel = {{os.cpu_count()/2}}\n"
-                                       "user.mycompany:other = {{platform.system()}}\n")
+                                       "user.mycompany:other = {{platform.system()}}\n"
+                                       "user.mycompany:dist = {{distro.id() if distro else '42'}}\n")
     client.run("install .")
     assert "user.mycompany:parallel={}".format(os.cpu_count()/2) in client.out
     assert "user.mycompany:other={}".format(platform.system()) in client.out
+    if platform.system() == "Linux":
+        import distro
+        assert "user.mycompany:dist={}".format(distro.id()) in client.out
+    else:
+        assert "user.mycompany:dist=42" in client.out
diff --git a/conans/test/integration/environment/test_env.py b/conans/test/integration/environment/test_env.py
index f60c0c4db..334936ae8 100644
--- a/conans/test/integration/environment/test_env.py
+++ b/conans/test/integration/environment/test_env.py
@@ -483,18 +483,19 @@ def test_multiple_deactivate():
     os.chmod(os.path.join(client.current_folder, "display.sh"), 0o777)
     client.run("install .")
 
-    if platform.system() == "Windows":
-        cmd = "conanbuild.bat && display.bat && deactivate_conanbuild.bat && display.bat"
-    else:
-        cmd = '. ./conanbuild.sh && ./display.sh && . ./deactivate_conanbuild.sh && ./display.sh'
-    out, _ = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
-                              shell=True, cwd=client.current_folder).communicate()
-    out = out.decode()
-    assert "VAR1=Value1!!" in out
-    assert "VAR2=Value2!!" in out
-    assert 2 == str(out).count("Restoring environment")
-    assert "VAR1=!!" in out
-    assert "VAR2=!!" in out
+    for _ in range(2):  # Just repeat it, so we can check things keep working
+        if platform.system() == "Windows":
+            cmd = "conanbuild.bat && display.bat && deactivate_conanbuild.bat && display.bat"
+        else:
+            cmd = '. ./conanbuild.sh && ./display.sh && . ./deactivate_conanbuild.sh && ./display.sh'
+        out, _ = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
+                                  shell=True, cwd=client.current_folder).communicate()
+        out = out.decode()
+        assert "VAR1=Value1!!" in out
+        assert "VAR2=Value2!!" in out
+        assert 2 == str(out).count("Restoring environment")
+        assert "VAR1=!!" in out
+        assert "VAR2=!!" in out
 
 
 @pytest.mark.skipif(platform.system() != "Windows", reason="Path problem in Windows only")
@@ -681,3 +682,41 @@ def test_files_always_created():
     assert os.path.isfile(os.path.join(c.current_folder, f"conanrun.{ext}"))
     assert os.path.isfile(os.path.join(c.current_folder, f"conanbuildenv-release-{arch}.{ext}"))
     assert os.path.isfile(os.path.join(c.current_folder, f"conanbuildenv-release-{arch}.{ext}"))
+
+
+def test_error_with_dots_virtualenv():
+    # https://github.com/conan-io/conan/issues/12163
+    tool = textwrap.dedent(r"""
+        from conan import ConanFile
+        class ToolConan(ConanFile):
+            name = "tool"
+            version = "0.1"
+            settings = "arch", "os"
+
+            def package_info(self):
+                self.buildenv_info.define("DUMMY", "123456")
+        """)
+    test_package = textwrap.dedent(r"""
+        from conan import ConanFile
+        import os
+
+        class ToolTestConan(ConanFile):
+            name = "app"
+            version = "0.1"
+            settings = "os", "compiler", "build_type", "arch"
+            generators = "VirtualBuildEnv"
+
+            def build_requirements(self):
+                self.tool_requires("tool/0.1")
+
+            def build(self):
+                self.run("echo DUMMY=$DUMMY")
+                self.run("set")
+            """)
+    client = TestClient()
+    client.save({"dep/conanfile.py": tool,
+                 "consumer/conanfile.py": test_package})
+
+    client.run("create dep -s arch=armv8.3")
+    client.run("create consumer -s arch=armv8.3")
+    assert "DUMMY=123456" in client.out
diff --git a/conans/test/integration/environment/test_runenv_profile.py b/conans/test/integration/environment/test_runenv_profile.py
new file mode 100644
index 000000000..d05b8f910
--- /dev/null
+++ b/conans/test/integration/environment/test_runenv_profile.py
@@ -0,0 +1,36 @@
+import textwrap
+
+import pytest
+
+from conans.test.utils.tools import TestClient
+
+
+@pytest.fixture
+def client():
+    conanfile = textwrap.dedent("""
+       from conan import ConanFile
+       class Pkg(ConanFile):
+           generators = "VirtualRunEnv"
+           def generate(self):
+               for var in (1, 2):
+                   v = self.runenv.vars(self).get("MyVar{}".format(var))
+                   self.output.info("MyVar{}={}!!".format(var, v))
+       """)
+    profile1 = textwrap.dedent("""
+      [runenv]
+      MyVar1=MyValue1_1
+      MyVar2=MyValue2_1
+      """)
+    client = TestClient()
+    client.save({"conanfile.py": conanfile,
+                 "profile1": profile1})
+    return client
+
+
+def test_buildenv_profile_cli(client):
+    client.run("install . -pr=profile1")
+    assert "conanfile.py: MyVar1=MyValue1_1!!" in client.out
+    assert "conanfile.py: MyVar2=MyValue2_1!!" in client.out
+    env = client.load("conanrunenv.sh")
+    assert "MyValue1_1" in env
+    assert "MyValue2_1" in env
diff --git a/conans/test/integration/layout/test_layout_generate.py b/conans/test/integration/layout/test_layout_generate.py
index ebe3cf106..7548f0788 100644
--- a/conans/test/integration/layout/test_layout_generate.py
+++ b/conans/test/integration/layout/test_layout_generate.py
@@ -96,3 +96,32 @@ def test_generate_source_folder_test_package():
             "test_package/conanfile.py": conanfile})
     c.run("create .")
     assert "PKG_CONFIG_PATH True!" in c.out
+
+
+def test_generate_build_folder_test_package():
+    c = TestClient()
+    conanfile = textwrap.dedent("""
+        import os
+        from conan import ConanFile
+        from conan.tools.cmake import cmake_layout
+
+        class Pkg(ConanFile):
+            settings = "os", "compiler", "build_type", "arch"
+
+            def requirements(self):
+                self.requires(self.tested_reference_str)
+
+            def layout(self):
+                cmake_layout(self)
+
+            def generate(self):
+                self.output.info(f"build_folder in test_package: {bool(self.build_folder)}")
+
+            def test(self):
+                pass
+        """)
+
+    c.save({"conanfile.py": GenConanfile("pkg", "1.0"),
+            "test_package/conanfile.py": conanfile})
+    c.run("create .")
+    assert f"build_folder in test_package: True" in c.out
diff --git a/conans/test/integration/toolchains/env/test_virtualenv_winbash.py b/conans/test/integration/toolchains/env/test_virtualenv_winbash.py
index dc231f5d8..c7f2ebcaf 100644
--- a/conans/test/integration/toolchains/env/test_virtualenv_winbash.py
+++ b/conans/test/integration/toolchains/env/test_virtualenv_winbash.py
@@ -67,60 +67,12 @@ def test_virtualenv_deactivated(client, win_bash):
 
 
 @pytest.mark.skipif(platform.system() != "Windows", reason="Requires Windows")
-def test_nowinbash_virtual_msys(client):
-    # Make sure the "tools.microsoft.bash:subsystem=msys2" is ignored if not win_bash
-    conanfile = str(GenConanfile().with_settings("os")
-                    .with_generator("VirtualBuildEnv").with_generator("VirtualRunEnv")
-                    .with_require("foo/1.0"))
-
-    client.save({"conanfile.py": conanfile})
-    client.run("install . -s:b os=Windows -s:h os=Windows")
-    assert not os.path.exists(os.path.join(client.current_folder, "conanbuildenv.sh"))
-    build_contents = client.load("conanbuildenv.bat")
-    assert 'set "AR=c:/path/to/ar"' in build_contents
-    assert 'set "PATH=%PATH%;c:/path/to/something"' in build_contents
-    assert not os.path.exists(os.path.join(client.current_folder, "conanrunenv.sh"))
-    run_contents = client.load("conanrunenv.bat")
-    assert 'set "RUNTIME_VAR=c:/path/to/exe"' in run_contents
-
-    # BUILD subsystem=msys2 HOST subsystem=None
-    client.save({"conanfile.py": conanfile}, clean_first=True)
-    client.run("install . -s:b os=Windows -s:b os.subsystem=msys2 -s:h os=Windows")
-    assert not os.path.exists(os.path.join(client.current_folder, "conanbuildenv.bat"))
-    build_contents = client.load("conanbuildenv.sh")
-    assert 'export AR="/c/path/to/ar"' in build_contents
-    assert 'export PATH="$PATH:/c/path/to/something"' in build_contents
-    assert not os.path.exists(os.path.join(client.current_folder, "conanrunenv.sh"))
-    run_contents = client.load("conanrunenv.bat")
-    assert 'set "RUNTIME_VAR=c:/path/to/exe"' in run_contents
-
-    # BUILD subsystem=None HOST subsystem=msys2
-    client.save({"conanfile.py": conanfile}, clean_first=True)
-    client.run("install . -s:b os=Windows  -s:h os=Windows -s:h os.subsystem=msys2")
-    assert not os.path.exists(os.path.join(client.current_folder, "conanbuildenv.sh"))
-    build_contents = client.load("conanbuildenv.bat")
-    assert 'set "AR=c:/path/to/ar"' in build_contents
-    assert 'set "PATH=%PATH%;c:/path/to/something"' in build_contents
-    assert not os.path.exists(os.path.join(client.current_folder, "conanrunenv.bat"))
-    run_contents = client.load("conanrunenv.sh")
-    assert 'export RUNTIME_VAR="/c/path/to/exe"' in run_contents
-
-    # BUILD subsystem=msys2 HOST subsystem=msys2
-    client.save({"conanfile.py": conanfile}, clean_first=True)
-    client.run("install . -s:b os=Windows -s:b os.subsystem=msys2 "
-               "-s:h os=Windows -s:h os.subsystem=msys2")
-    assert not os.path.exists(os.path.join(client.current_folder, "conanbuildenv.bat"))
-    build_contents = client.load("conanbuildenv.sh")
-    assert 'export AR="/c/path/to/ar"' in build_contents
-    assert 'export PATH="$PATH:/c/path/to/something"' in build_contents
-    assert not os.path.exists(os.path.join(client.current_folder, "conanrunenv.bat"))
-    run_contents = client.load("conanrunenv.sh")
-    assert 'export RUNTIME_VAR="/c/path/to/exe"' in run_contents
-
-
-@pytest.mark.skipif(platform.system() != "Windows", reason="Requires Windows")
-def test_nowinbash_virtual_cygwin(client):
-    # Make sure the "tools.microsoft.bash:subsystem=cygwin" is ignored if not win_bash
+def test_nowinbash(client):
+    """ whe the recipe doesn't define win_bash=True 2 things can happen:
+    - No need to run in bash, things will run in normal command, with .bat
+    - You run directly in a subsytem terminal a recipe that was not aware of that, still the
+       files need to follow the subsystem
+    """
     conanfile = str(GenConanfile().with_settings("os")
                     .with_generator("VirtualBuildEnv").with_generator("VirtualRunEnv")
                     .with_require("foo/1.0"))
@@ -135,39 +87,29 @@ def test_nowinbash_virtual_cygwin(client):
     run_contents = client.load("conanrunenv.bat")
     assert 'set "RUNTIME_VAR=c:/path/to/exe"' in run_contents
 
-    # BUILD subsystem=cygwin HOST subsystem=None
+    # Running it inside a cygwin subsystem
     client.save({"conanfile.py": conanfile}, clean_first=True)
-    client.run("install . -s:b os=Windows -s:b os.subsystem=cygwin -s:h os=Windows")
+    client.run("install . -s:b os=Windows -s:h os=Windows "
+               "-c:h tools.microsoft.bash:active=True")
     assert not os.path.exists(os.path.join(client.current_folder, "conanbuildenv.bat"))
     build_contents = client.load("conanbuildenv.sh")
     assert 'export AR="/cygdrive/c/path/to/ar"' in build_contents
     assert 'export PATH="$PATH:/cygdrive/c/path/to/something"' in build_contents
-    assert not os.path.exists(os.path.join(client.current_folder, "conanrunenv.sh"))
-    run_contents = client.load("conanrunenv.bat")
-    assert 'set "RUNTIME_VAR=c:/path/to/exe"' in run_contents
-
-    # BUILD subsystem=None HOST subsystem=cygwin
-    client.save({"conanfile.py": conanfile}, clean_first=True)
-    client.run("install . -s:b os=Windows  -s:h os=Windows -s:h os.subsystem=cygwin")
-    assert not os.path.exists(os.path.join(client.current_folder, "conanbuildenv.sh"))
-    build_contents = client.load("conanbuildenv.bat")
-    assert 'set "AR=c:/path/to/ar"' in build_contents
-    assert 'set "PATH=%PATH%;c:/path/to/something"' in build_contents
     assert not os.path.exists(os.path.join(client.current_folder, "conanrunenv.bat"))
     run_contents = client.load("conanrunenv.sh")
     assert 'export RUNTIME_VAR="/cygdrive/c/path/to/exe"' in run_contents
 
-    # BUILD subsystem=cygwin HOST subsystem=cygwin
+    # Running it inside a msys2 subsystem, test tat it overrides
     client.save({"conanfile.py": conanfile}, clean_first=True)
-    client.run("install . -s:b os=Windows -s:b os.subsystem=cygwin "
-               "-s:h os=Windows -s:h os.subsystem=cygwin")
+    client.run("install . -s:b os=Windows -s:h os=Windows "
+               "-c tools.microsoft.bash:subsystem=msys2 -c:h tools.microsoft.bash:active=True")
     assert not os.path.exists(os.path.join(client.current_folder, "conanbuildenv.bat"))
     build_contents = client.load("conanbuildenv.sh")
-    assert 'export AR="/cygdrive/c/path/to/ar"' in build_contents
-    assert 'export PATH="$PATH:/cygdrive/c/path/to/something"' in build_contents
+    assert 'export AR="/c/path/to/ar"' in build_contents
+    assert 'export PATH="$PATH:/c/path/to/something"' in build_contents
     assert not os.path.exists(os.path.join(client.current_folder, "conanrunenv.bat"))
     run_contents = client.load("conanrunenv.sh")
-    assert 'export RUNTIME_VAR="/cygdrive/c/path/to/exe"' in run_contents
+    assert 'export RUNTIME_VAR="/c/path/to/exe"' in run_contents
 
 
 @pytest.mark.skipif(platform.system() != "Windows", reason="Requires Windows")
diff --git a/conans/test/integration/toolchains/gnu/test_basic_layout.py b/conans/test/integration/toolchains/gnu/test_basic_layout.py
index 19cd9ebb6..968596115 100644
--- a/conans/test/integration/toolchains/gnu/test_basic_layout.py
+++ b/conans/test/integration/toolchains/gnu/test_basic_layout.py
@@ -23,3 +23,25 @@ def test_basic_layout_subproject():
     ext = "sh" if platform.system() != "Windows" else "bat"
     assert os.path.isfile(os.path.join(c.current_folder, "pkg", "build-release", "conan",
                                        "conanautotoolstoolchain.{}".format(ext)))
+
+
+# TODO: Remove this test in 2.0
+def test_basic_layout_no_generators():
+    """ test that conan doesn't crash for auto_use=True
+    because generator folder doesn't exist
+    # https://github.com/conan-io/conan/issues/12383
+    """
+    c = TestClient()
+    conanfile = textwrap.dedent("""
+        from conan import ConanFile
+        from conan.tools.layout import basic_layout
+        class Pkg(ConanFile):
+            name = "pkg"
+            version = "0.1"
+            settings = "os", "compiler", "build_type", "arch"
+            def layout(self):
+                basic_layout(self)
+        """)
+    c.save({"conanfile.py": conanfile})
+    c.run("create . -c tools.env.virtualenv:auto_use=True")
+    # It used to fail, if it doesn't crash, it is good
diff --git a/conans/test/integration/toolchains/meson/test_mesontoolchain.py b/conans/test/integration/toolchains/meson/test_mesontoolchain.py
index 1f9a933c7..c5b273ada 100644
--- a/conans/test/integration/toolchains/meson/test_mesontoolchain.py
+++ b/conans/test/integration/toolchains/meson/test_mesontoolchain.py
@@ -58,8 +58,8 @@ def test_apple_meson_keep_user_custom_flags():
     content = t.load(MesonToolchain.cross_filename)
     assert "c_args = ['-isysroot', '/other/sdk/path', '-arch', 'myarch', '-otherminversion=10.7']" in content
     assert "c_link_args = ['-isysroot', '/other/sdk/path', '-arch', 'myarch', '-otherminversion=10.7']" in content
-    assert "cpp_args = ['-isysroot', '/other/sdk/path', '-arch', 'myarch', '-otherminversion=10.7']" in content
-    assert "cpp_link_args = ['-isysroot', '/other/sdk/path', '-arch', 'myarch', '-otherminversion=10.7']" in content
+    assert "cpp_args = ['-isysroot', '/other/sdk/path', '-arch', 'myarch', '-otherminversion=10.7', '-stdlib=libc++']" in content
+    assert "cpp_link_args = ['-isysroot', '/other/sdk/path', '-arch', 'myarch', '-otherminversion=10.7', '-stdlib=libc++']" in content
 
 
 @pytest.mark.skipif(sys.version_info.major == 2, reason="Meson not supported in Py2")
@@ -71,7 +71,7 @@ def test_extra_flags_via_conf():
         compiler=gcc
         compiler.version=9
         compiler.cppstd=17
-        compiler.libcxx=libstdc++11
+        compiler.libcxx=libstdc++
         build_type=Release
 
         [buildenv]
@@ -91,7 +91,7 @@ def test_extra_flags_via_conf():
 
     t.run("install . -pr=profile")
     content = t.load(MesonToolchain.native_filename)
-    assert "cpp_args = ['-flag0', '-other=val', '-flag1', '-flag2']" in content
+    assert "cpp_args = ['-flag0', '-other=val', '-flag1', '-flag2', '-D_GLIBCXX_USE_CXX11_ABI=0']" in content
     assert "c_args = ['-flag0', '-other=val', '-flag3', '-flag4']" in content
     assert "c_link_args = ['-flag0', '-other=val', '-flag5', '-flag6']" in content
     assert "cpp_link_args = ['-flag0', '-other=val', '-flag5', '-flag6']" in content
diff --git a/conans/test/integration/toolchains/microsoft/test_msbuilddeps.py b/conans/test/integration/toolchains/microsoft/test_msbuilddeps.py
index 0422276c3..32f40c7c2 100644
--- a/conans/test/integration/toolchains/microsoft/test_msbuilddeps.py
+++ b/conans/test/integration/toolchains/microsoft/test_msbuilddeps.py
@@ -45,6 +45,19 @@ def test_msbuilddeps_format_names():
     c.run("install pkg.name-more+/1.0@ -g MSBuildDeps -s build_type=Release -s arch=x86_64")
     # Checking that MSBuildDeps builds correctly the XML file
     # loading all .props and xml parse them to check no errors
+    pkg_more = c.load("conan_pkg_name-more_.props")
+    assert "$(conan_pkg_name-more__libmpdecimal___props_imported)" in pkg_more
+    assert "$(conan_pkg_name-more__mycomp_some-comp__props_imported)" in pkg_more
+
+    some_comp = c.load("conan_pkg_name-more__mycomp_some-comp_.props")
+    assert "<conan_pkg_name-more__mycomp_some-comp__props_imported>" in some_comp
+
+    libmpdecimal = c.load("conan_pkg_name-more__libmpdecimal__.props")
+    assert "<conan_pkg_name-more__libmpdecimal___props_imported>" in libmpdecimal
+
+    libmpdecimal_release = c.load("conan_pkg_name-more__libmpdecimal___release_x64.props")
+    assert "$(conan_pkg_name-more__mycomp_some-comp__props_imported)" in libmpdecimal_release
+
     counter = 0
     for f in os.listdir(c.current_folder):
         if f.endswith(".props"):
diff --git a/conans/test/integration/tools/system/package_manager_test.py b/conans/test/integration/tools/system/package_manager_test.py
index f63da31ec..dbac4cf19 100644
--- a/conans/test/integration/tools/system/package_manager_test.py
+++ b/conans/test/integration/tools/system/package_manager_test.py
@@ -10,7 +10,7 @@ from conan.tools.system.package_manager import Apt, Dnf, Yum, Brew, Pkg, PkgUtil
 from conans import Settings
 from conans.errors import ConanException
 from conans.model.conf import Conf
-from conans.test.utils.mocks import ConanFileMock
+from conans.test.utils.mocks import ConanFileMock, MockSettings
 
 
 @pytest.mark.parametrize("platform, tool", [
@@ -196,26 +196,66 @@ def test_dnf_yum_return_code_100(tool_class, result):
         assert f"Command '{result}' failed" == str(exc_info.value)
 
 
+@pytest.mark.parametrize("tool_class, arch_host, result", [
+    # not cross-compile -> do not add host architecture
+    (Apt, 'x86_64', 'apt-get install -y --no-install-recommends package1 package2'),
+    (Yum, 'x86_64', 'yum install -y package1 package2'),
+    (Dnf, 'x86_64', 'dnf install -y package1 package2'),
+    (Brew, 'x86_64', 'brew install package1 package2'),
+    (Pkg, 'x86_64', 'pkg install -y package1 package2'),
+    (PkgUtil, 'x86_64', 'pkgutil --install --yes package1 package2'),
+    (Chocolatey, 'x86_64', 'choco install --yes package1 package2'),
+    (PacMan, 'x86_64', 'pacman -S --noconfirm package1 package2'),
+    (Zypper, 'x86_64', 'zypper --non-interactive in package1 package2'),
+    # cross-compile -> add host architecture https://github.com/conan-io/conan/issues/12320
+    (Apt, 'x86', 'apt-get install -y --no-install-recommends package1:i386 package2:i386'),
+    (Yum, 'x86', 'yum install -y package1.i?86 package2.i?86'),
+    (Dnf, 'x86', 'dnf install -y package1.i?86 package2.i?86'),
+    (Brew, 'x86', 'brew install package1 package2'),
+    (Pkg, 'x86', 'pkg install -y package1 package2'),
+    (PkgUtil, 'x86', 'pkgutil --install --yes package1 package2'),
+    (Chocolatey, 'x86', 'choco install --yes package1 package2'),
+    (PacMan, 'x86', 'pacman -S --noconfirm package1-lib32 package2-lib32'),
+    (Zypper, 'x86', 'zypper --non-interactive in package1 package2'),
+])
+def test_tools_install_mode_install_different_archs(tool_class, arch_host, result):
+    conanfile = ConanFileMock()
+    conanfile.conf = Conf()
+    conanfile.settings = MockSettings({"arch": f"{arch_host}"})
+    conanfile.settings_build = MockSettings({"arch": "x86_64"})
+    conanfile.conf["tools.system.package_manager:tool"] = tool_class.tool_name
+    conanfile.conf["tools.system.package_manager:mode"] = "install"
+    with mock.patch('conans.ConanFile.context', new_callable=PropertyMock) as context_mock:
+        context_mock.return_value = "host"
+        tool = tool_class(conanfile)
+
+        def fake_check(*args, **kwargs):
+            return ["package1", "package2"]
+        from conan.tools.system.package_manager import _SystemPackageManagerTool
+        with patch.object(_SystemPackageManagerTool, 'check', MagicMock(side_effect=fake_check)):
+            tool.install(["package1", "package2"])
+
+    assert tool._conanfile.command == result
+
+
 @pytest.mark.parametrize("tool_class, result", [
+    # cross-compile but arch_names=None -> do not add host architecture
+    # https://github.com/conan-io/conan/issues/12320 because the package is archless
     (Apt, 'apt-get install -y --no-install-recommends package1 package2'),
     (Yum, 'yum install -y package1 package2'),
     (Dnf, 'dnf install -y package1 package2'),
-    (Brew, 'brew install package1 package2'),
-    (Pkg, 'pkg install -y package1 package2'),
-    (PkgUtil, 'pkgutil --install --yes package1 package2'),
-    (Chocolatey, 'choco --install --yes package1 package2'),
     (PacMan, 'pacman -S --noconfirm package1 package2'),
-    (Zypper, 'zypper --non-interactive in package1 package2'),
 ])
-def test_tools_install_mode_install(tool_class, result):
+def test_tools_install_archless(tool_class, result):
     conanfile = ConanFileMock()
     conanfile.conf = Conf()
-    conanfile.settings = Settings()
+    conanfile.settings = MockSettings({"arch": "x86"})
+    conanfile.settings_build = MockSettings({"arch": "x86_64"})
     conanfile.conf["tools.system.package_manager:tool"] = tool_class.tool_name
     conanfile.conf["tools.system.package_manager:mode"] = "install"
     with mock.patch('conans.ConanFile.context', new_callable=PropertyMock) as context_mock:
         context_mock.return_value = "host"
-        tool = tool_class(conanfile)
+        tool = tool_class(conanfile, arch_names={})
 
         def fake_check(*args, **kwargs):
             return ["package1", "package2"]
@@ -223,6 +263,8 @@ def test_tools_install_mode_install(tool_class, result):
         with patch.object(_SystemPackageManagerTool, 'check', MagicMock(side_effect=fake_check)):
             tool.install(["package1", "package2"])
 
+    assert tool._conanfile.command == result
+
 
 @pytest.mark.parametrize("tool_class, result", [
     (Apt, 'dpkg-query -W -f=\'${Status}\' package | grep -q "ok installed"'),
@@ -244,3 +286,5 @@ def test_tools_check(tool_class, result):
         context_mock.return_value = "host"
         tool = tool_class(conanfile)
         tool.check(["package"])
+
+    assert tool._conanfile.command == result
diff --git a/conans/test/unittests/client/toolchain/autotools/autotools_toolchain_test.py b/conans/test/unittests/client/toolchain/autotools/autotools_toolchain_test.py
index acbe860bb..aedd2fdf9 100644
--- a/conans/test/unittests/client/toolchain/autotools/autotools_toolchain_test.py
+++ b/conans/test/unittests/client/toolchain/autotools/autotools_toolchain_test.py
@@ -58,6 +58,15 @@ def test_invalid_target_triple():
     assert "Unknown 'UNKNOWN_ARCH' machine, Conan doesn't know how " \
            "to translate it to the GNU triplet," in str(excinfo)
 
+def test_custom_host_triple():
+    conanfile = ConanFileMock()
+    conanfile.settings = MockSettings({"os": "Linux", "arch": "x86"})
+    conanfile.settings_build = MockSettings({"os": "Linux", "arch": "x86_64"})
+    conanfile.conf.define("tools.gnu:host_triplet", "i686-pc-linux-gnu")
+    tc = AutotoolsToolchain(conanfile)
+    tc.generate_args()
+    obj = load_toolchain_args()
+    assert "--host=i686-pc-linux-gnu" in obj["configure_args"]
 
 def test_cppstd():
     # Using "cppstd" is discarded
diff --git a/conans/test/unittests/tools/apple/__init__.py b/conans/test/unittests/tools/apple/__init__.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/conans/test/unittests/tools/apple/test_apple_tools.py b/conans/test/unittests/tools/apple/test_apple_tools.py
index 4146d0e50..6331c1dab 100644
--- a/conans/test/unittests/tools/apple/test_apple_tools.py
+++ b/conans/test/unittests/tools/apple/test_apple_tools.py
@@ -1,5 +1,8 @@
+import pytest
+
 from conans.test.utils.mocks import ConanFileMock, MockSettings
-from conan.tools.apple import is_apple_os, to_apple_arch
+from conans.test.utils.test_files import temp_folder
+from conan.tools.apple import is_apple_os, to_apple_arch, fix_apple_shared_install_name
 
 def test_tools_apple_is_apple_os():
     conanfile = ConanFileMock()
@@ -22,3 +25,14 @@ def test_tools_apple_to_apple_arch():
 
     conanfile.settings = MockSettings({"arch": "x86_64"})
     assert to_apple_arch(conanfile) == "x86_64"
+
+def test_fix_shared_install_name_no_libraries():
+    conanfile = ConanFileMock(
+        options="""{"shared": [True, False]}""",
+        options_values={"shared": True})
+    conanfile.settings = MockSettings({"os": "Macos"})
+    conanfile.folders.set_base_package(temp_folder())
+
+    with pytest.raises(Exception) as e:
+        fix_apple_shared_install_name(conanfile)
+        assert "not found inside package folder" in str(e.value)
diff --git a/conans/test/unittests/tools/build/test_stdcpp_library.py b/conans/test/unittests/tools/build/test_stdcpp_library.py
new file mode 100644
index 000000000..563284da8
--- /dev/null
+++ b/conans/test/unittests/tools/build/test_stdcpp_library.py
@@ -0,0 +1,18 @@
+import pytest
+from conan.tools.build import stdcpp_library
+from conans.test.utils.mocks import MockSettings, MockConanfile
+
+
+@pytest.mark.parametrize("libcxx,expected_library", [
+    ("libstdc++", "stdc++"),
+    ("libstdc++11", "stdc++"),
+    ("libc++", "c++"),
+    ("c++_shared", "c++_shared"), 
+    ("c++_static", "c++_static"),
+    ("foobar", None)
+])
+def test_stdcpp_library(libcxx, expected_library):
+    settings = MockSettings({"compiler.libcxx": libcxx})
+    conanfile = MockConanfile(settings)
+
+    assert stdcpp_library(conanfile) == expected_library
diff --git a/conans/test/unittests/tools/cmake/test_cmaketoolchain.py b/conans/test/unittests/tools/cmake/test_cmaketoolchain.py
index 2fac1acfd..2d30b9eb1 100644
--- a/conans/test/unittests/tools/cmake/test_cmaketoolchain.py
+++ b/conans/test/unittests/tools/cmake/test_cmaketoolchain.py
@@ -302,7 +302,7 @@ def test_fpic_when_shared_true(conanfile_linux_shared, fPIC):
     toolchain = CMakeToolchain(conanfile_linux_shared)
     cmake_value = 'ON' if fPIC else 'OFF'
     content = toolchain.content
-    assert 'set(CMAKE_POSITION_INDEPENDENT_CODE {})'.format(cmake_value) in content
+    assert 'set(CMAKE_POSITION_INDEPENDENT_CODE {} CACHE BOOL'.format(cmake_value) in content
 
 
 def test_fpic_when_not_shared(conanfile_linux_shared):
diff --git a/conans/test/unittests/tools/microsoft/test_subsystem.py b/conans/test/unittests/tools/microsoft/test_subsystem.py
index 07a43d329..65e5423e8 100644
--- a/conans/test/unittests/tools/microsoft/test_subsystem.py
+++ b/conans/test/unittests/tools/microsoft/test_subsystem.py
@@ -18,6 +18,7 @@ def test_unix_path(subsystem, expected_path):
     c = ConfDefinition()
     c.loads(textwrap.dedent("""\
         tools.microsoft.bash:subsystem={}
+        tools.microsoft.bash:active=True
     """.format(subsystem)))
 
     settings = MockSettings({"os": "Windows"})
@@ -25,7 +26,6 @@ def test_unix_path(subsystem, expected_path):
     conanfile.conf = c.get_conanfile_conf(None)
     conanfile.settings = settings
     conanfile.settings_build = settings
-    conanfile.win_bash = True
 
     path = unix_path(conanfile, "c:/path/to/stuff")
     assert expected_path == path