conan-io / conan

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

[feature] Add support for gcc thread model 'mcf' for MINGW #16855

Open ErikTempelaarVO opened 1 month ago

ErikTempelaarVO commented 1 month ago

What is your suggestion?

Hi! I would like for conan to be able to support the mcfgthread model for gcc on Windows natively.

mcf is a new thread model, available in gcc since 13.1. gcc has it as --enable-thread option, it's called 'mcf'

See the thread line below:

        version: ["4.1", "4.4", "4.5", "4.6", "4.7", "4.8", "4.9",
                  "5", "5.1", "5.2", "5.3", "5.4", "5.5",
                  "6", "6.1", "6.2", "6.3", "6.4", "6.5",
                  "7", "7.1", "7.2", "7.3", "7.4", "7.5",
                  "8", "8.1", "8.2", "8.3", "8.4", "8.5",
                  "9", "9.1", "9.2", "9.3", "9.4", "9.5",
                  "10", "10.1", "10.2", "10.3", "10.4", "10.5",
                  "11", "11.1", "11.2", "11.3", "11.4",
                  "12", "12.1", "12.2", "12.3",
                  "13", "13.1", "13.2", "14"]
        libcxx: [libstdc++, libstdc++11]
        threads: [None, posix, win32, mcf]  # Windows MinGW

This way I can add it to my profiles

compiler.threads=mcf

Without having to install a custom setting.yaml to developer laptops or CI machines.

Thanks for taking this in consideration!

Have you read the CONTRIBUTING guide?

memsharded commented 1 month ago

Hi @ErikTempelaarVO

Thanks for the suggestion.

Without having to install a custom setting.yaml to developer laptops or CI machines.

This shouldn't be a stopper. Conan 2 got the custom settings_user.yml to allow for easy definition and maintenance. And conan config install is the recommended way to distribute configuration. There is generally many other configuration like remotes, global.conf, custom profiles, plugins, hooks... that will be installed in developer and CI machines. How are you defining this stuff currently if not using conan config install? (btw, Conan also got conan config install-pkg, that allows to put configuration inside conan packages too, versioning them, etc).

Now, to the suggestion, I am not against adding a new entry to the defaults if it makes sense. However, I'd like to understand better this, because at the moment there is nothing in the Conan toolchains that uses this as input to define anything into the generated toolchain files. I don't know if this is expected, users are managing that already, it depends mostly on how the mingw compiler is installed and configured. So having more details about this would be very useful.

What I am trying to avoid is the expectation from users that if they define compiler.threads=mcf then they will magically get the mcfthreads library installed, configured and injected into their builds.

ErikTempelaarVO commented 1 month ago

Hi @memsharded

Thanks for your quick response.

conan config install is what we use now and it works well. I will look into install-pkg as well.

The reason I wanted to configure it in my profile is because I wanted conan to keep different caches for the same libs; I believe the setting results in a different binary package ID, maintaining the caches with mingw-posix.

I wouldn't expect this setting to have any other effect. I'm well aware that the thread model is embedded in the installed gcc binaries. But isn't that also the case for the other thread/exception models?

Still I understand your concerns there, maybe it's not as trivial as I'd hoped.

memsharded commented 1 month ago

The reason I wanted to configure it in my profile is because I wanted conan to keep different caches for the same libs; I believe the setting results in a different binary package ID, maintaining the caches with mingw-posix.

yes, it totally makes sense to have your own profiles with compiler.threads=mcf, and that results in a different package_id that is the correct approach. Just it requires having a custom settings_user.yml distributed together with those same profiles, not sure if I am missing something.

But isn't that also the case for the other thread/exception models?

Yes, that was my understanding so far, but this new mcf threads library looked like something a bit external, so I was not sure about the compiler configuration for this one, better be sure.

Still I understand your concerns there, maybe it's not as trivial as I'd hoped.

It might be trivial, I am just trying to make sure and understand possible implications, side effects and issues.

If the mcf threads library is something that can come installed with mingw, and it doesn't require any other configuration than a specific installation of mingw, then I don't oppose to add mcf as a new threads model to gcc. Would you like to do the PR yourself?

ErikTempelaarVO commented 1 month ago

Yes, that was my understanding so far, but this new mcf threads library looked like something a bit external, so I was not sure about the compiler configuration for this one, better be sure.

That's true, it used to be an external/standalone library. And it can still be used that way (i.e. installed as package in msys2/mingw).

But with recent GCC it can also be used as GCC's implementation for std::thread.

>g++ --version -v
Using built-in specs.
COLLECT_AS_OPTIONS='--version'
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=C:/tools/mingw32/bin/../libexec/gcc/i686-w64-mingw32/14.1.0/lto-wrapper.exe
OFFLOAD_TARGET_NAMES=nvptx-none
g++ (MinGW-W64 i686-ucrt-mcf-dwarf, built by Brecht Sanders) 14.1.0
Copyright (C) 2024 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Target: i686-w64-mingw32
Configured with: ../configure --prefix=/R/winlibs_stage_mcf_ucrt_32/inst_gcc-14.1.0/share/gcc --build=i686-w64-mingw32 --host=i686-w64-mingw32 --enable-offload-targets=nvptx-none --with-pkgversion='MinGW-W64 i686-ucrt-mcf-dwarf, built by Brecht Sanders' --with-tune=generic --enable-checking=release --enable-threads=mcf --with-dwarf2 --disable-sjlj-exceptions --disable-libunwind-exceptions --disable-serial-configure --disable-bootstrap --enable-host-shared --enable-plugin --disable-default-ssp --disable-rpath --disable-libstdcxx-debug --disable-version-specific-runtime-libs --with-stabs --disable-symvers --enable-languages=c,c++,fortran,lto,objc,obj-c++ --disable-gold --disable-nls --disable-stage1-checking --disable-win32-registry --disable-multilib --enable-ld --enable-libquadmath --enable-libada --enable-libssp --enable-libstdcxx --enable-lto --enable-fully-dynamic-string --enable-libgomp --enable-graphite --enable-mingw-wildcard --enable-libstdcxx-time --enable-libstdcxx-pch --with-mpc=/d/Prog/winlibs_stage_mcf_ucrt/custombuilt32 --with-mpfr=/d/Prog/winlibs_stage_mcf_ucrt/custombuilt32 --with-gmp=/d/Prog/winlibs_stage_mcf_ucrt/custombuilt32 --with-isl=/d/Prog/winlibs_stage_mcf_ucrt/custombuilt32 --enable-large-address-aware --disable-libstdcxx-backtrace --enable-install-libiberty --enable-__cxa_atexit --without-included-gettext --with-diagnostics-color=auto --enable-clocale=generic --with-libiconv --with-system-zlib --with-build-sysroot=/R/winlibs_stage_mcf_ucrt_32/gcc-14.1.0/build_mingw/mingw-w64 CFLAGS='-D__USE_MINGW_ANSI_STDIO=0 -I/d/Prog/winlibs_stage_mcf_ucrt/custombuilt32/include/libdl-win32  -march=pentium4 -mtune=generic -O2  -Wno-error=format' CXXFLAGS='-D__USE_MINGW_ANSI_STDIO=0 -Wno-int-conversion -march=pentium4 -mtune=generic -O2 ' LDFLAGS='-pthread -Wl,--no-insert-timestamp -Wl,--dynamicbase  -Wl,--nxcompat -Wl,--tsaware' LD=/d/Prog/winlibs_stage_mcf_ucrt/custombuilt32/share/binutils/bin/ld.exe
Thread model: mcf
Supported LTO compression algorithms: zlib zstd
gcc version 14.1.0 (MinGW-W64 i686-ucrt-mcf-dwarf, built by Brecht Sanders)
COLLECT_GCC_OPTIONS='--version' '-v' '-shared-libgcc' '-mtune=generic' '-march=pentiumpro' '-dumpdir' 'a-'
 C:/tools/mingw32/bin/../libexec/gcc/i686-w64-mingw32/14.1.0/cc1.exe -quiet -v -iprefix C:/tools/mingw32/bin/../lib/gcc/i686-w64-mingw32/14.1.0/ -U_REENTRANT help-dummy -quiet -dumpdir a- -dumpbase help-dummy -mtune=generic -march=pentiumpro -version --version -o C:\Users\RXQ\AppData\Local\Temp\ccJjRrvu.s
GNU C17 (MinGW-W64 i686-ucrt-mcf-dwarf, built by Brecht Sanders) version 14.1.0 (i686-w64-mingw32)
        compiled by GNU C version 14.1.0, GMP version 6.3.0, MPFR version 4.2.1, MPC version 1.3.1, isl version isl-0.26-GMP

Is something like this (c88457586b18c426819ed5fbd77c9e3a5ae8f693) all what is needed to add support?

memsharded commented 1 month ago

Sounds good.

Is something like this (https://github.com/conan-io/conan/commit/c88457586b18c426819ed5fbd77c9e3a5ae8f693) all what is needed to add support?

Yes, basically what https://github.com/conan-io/conan/commit/c88457586b18c426819ed5fbd77c9e3a5ae8f693 does, but for the gcc.threads field.