conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
8.25k stars 980 forks source link

[question] How to disable compatilibity? #16564

Closed Nekto89 closed 4 months ago

Nekto89 commented 4 months ago

What is your question?

Hi,

I'm trying to switch from C++17 to C++20. I'm using

core.package_id:default_embed_mode=full_mode
core.package_id:default_non_embed_mode=full_mode
core.package_id:default_unknown_mode=full_mode

I've noticed that conan assumes that binaries with C++17 can be used instead of building binaries for C++20. How can I forbid this through profile or global.conf? I would like each cppstd to have separate binaries.

Have you read the CONTRIBUTING guide?

AbrilRBS commented 4 months ago

Hi @Nekto89 thanks a lot for your question.

The main idea behind the compatibility plugin is to allow users to modify it as needed.

While individual recipes can disable the default compatibility checks by using the extensions_properties attribute (docs here), your best bet would be to modify your compatibility.py plugin as explained here, maybe adding a line to the default cppstd_compat.py file like:

def cppstd_compat(conanfile):
    if self.conf.get("user.compatibility:skip", default=False):
        return
    ...

This will allow you to define the user.compatibility:skip conf in your profiles, and even scope it to only those packages you deem necessary (or all of them) by using patterns

In your profile:

[conf]
# Skip compat for every package
*:user.compatibility:skip=True

Note that this file also implements useful fallbacks for msvc versions as well as the new cstd compatibility, in case you need to keep those around, feel free to rearrange the file to suit your needs!

Let me know if this helps :)

Nekto89 commented 4 months ago

Thanks, having to change compatibility.py will slightly increase complexity of configuring conan. Also this default behavior doesn't look very safe. So there is no built-in way to completely disable compatibility except for not forgetting to replace body of method with "pass"?

AbrilRBS commented 4 months ago

Thanks, having to change compatibility.py will slightly increase complexity of configuring conan.

I think this should not be an increase in configuration complexity. Your conan configuration should be managed via the conan config install mechanisim, which will install your modififications to this file alongside the rest of the config

Nekto89 commented 4 months ago

Also default compatibility works in a strange way. With conan 2.4.1

[settings]
arch=x86_64
os=Windows
compiler=msvc
compiler.version=194
compiler.update=0
compiler.runtime=dynamic
compiler.cppstd=20
build_type=Debug

it looks for 193 and ignores 194:

fmt/10.1.1@user/channel: Checking 4 compatible configurations
fmt/10.1.1@user/channel: Compatible configurations not found in cache, checking servers
fmt/10.1.1@user/channel: '3138c33a093356caafe595a6afb075fe030b39d8': compiler.cppstd=14, compiler.version=193
fmt/10.1.1@user/channel: '04cb32c4ac1dc1292377e35c31747068e8dccca4': compiler.cppstd=17, compiler.version=193
fmt/10.1.1@user/channel: 'c836d3e0f897d3dae1d548efef0948473e70730b': compiler.version=193
fmt/10.1.1@user/channel: 'ff3ca53c106736062900673f741cba64c9b4a86e': compiler.cppstd=23, compiler.version=193

On server I have image but it didn't find it

AbrilRBS commented 4 months ago

Hi @Nekto89 thanks a lot for the report! Indeed, this seems like an oversight of the msvc 194->193 compatibility fallback. I've now submited https://github.com/conan-io/conan/pull/16573 to try to address it :)