Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[question] Could we add the arm64 building support for msys2? #26379

Open
codereba opened this issue Jan 14, 2025 · 8 comments · May be fixed by #26466
Open

[question] Could we add the arm64 building support for msys2? #26379

codereba opened this issue Jan 14, 2025 · 8 comments · May be fixed by #26466
Labels
question Further information is requested

Comments

@codereba
Copy link
Contributor

codereba commented Jan 14, 2025

MSYS2 already provides some support for arm64 now, contains clang arm64 and cross build tool from x64 to arm64, please refer to:
https://www.msys2.org/wiki/arm64/
https://packages.msys2.org/groups/mingw-w64-cross-toolchain

Currently msys2 conanfile.py just raise an exception:
raise ConanInvalidConfiguration("Only Windows x64 and arm64 supported")
Please refer to:
https://github.com/conan-io/conan-center-index/blob/master/recipes/msys2/all/conanfile.py#L71

Could we add the arm64 building support for msys2? let user to choose how to use msys2 for building.

Reproduce steps:

git clone https://github.com/audacity/audacity.git
cd audacity
git checkout Audacity-3.7.1
mkdir build
cd build
cmake .. -G "Visual Studio 17 2022" -A ARM64 -Thost=ARM64 -B output -DCMAKE_BUILD_TYPE=Debug
@codereba codereba added the question Further information is requested label Jan 14, 2025
@jcar87
Copy link
Contributor

jcar87 commented Jan 14, 2025

msys2 in Conan Center is used to provide bash and autotools for recipes that only support being built in that environment, and NOT the compiler (gcc, clang) - that is still msvc
As far as I know, these tools are still x86-64, as per the link you have provided:

Screenshot 2025-01-14 at 09 56 49

This is easy to reflect with Conan, you can do do so:

  • via command line --settings:build "msys2/*:arch=x86_64
  • modify your build profile to contain, in the [settings] section:
msys2/*:arch=x86_64

(note that you will need to pass two different profiles when invoking conan install or conan create)

This should suffice to build libraries to target armv8 on Windows for libraries that require msys2, for example:

conan install --require=libx264/cci.20240224 --build=missing --settings:build="msys2/*:arch=x86_64"

This should successfully build the arm64 version of libx264 on Windows:

======== Input profiles ========
Profile host:
[settings]
arch=armv8
build_type=Release
compiler=msvc
compiler.cppstd=14
compiler.runtime=dynamic
compiler.runtime_type=Release
compiler.version=194
os=Windows
[conf]


Profile build:
[settings]
arch=armv8
build_type=Release
compiler=msvc
compiler.cppstd=14
compiler.runtime=dynamic
compiler.runtime_type=Release
compiler.version=194
os=Windows
msys2/*:arch=x86_64
[conf]

Let us know if this works for you!

@codereba
Copy link
Contributor Author

codereba commented Jan 14, 2025

Hi @jcar87 ,

Thanks for your response,

I have a question, if the msys2 files are x64 arch then they can run on windows arm by the arm64 emulation, why msys2 recipe deny the armv8 as the target arch?
https://github.com/conan-io/conan-center-index/blob/master/recipes/msys2/all/conanfile.py#L71

We may not need to deny arm arch, let user to choose what to do.

And if you think we need to change this behavior, please let me to fix it, I'm interested in contributing this work.

@jcar87
Copy link
Contributor

jcar87 commented Jan 14, 2025

I have a question, if the msys2 files are x64 arch then they can run on windows arm by the arm64 emulation, why msys2 recipe deny the armv8 as the target arch?

When the arch is armv8 in both build profile and host profile - the user is asking "please give me msys2 that is built to run natively on armv8" - and such package does not exist, because those tools simply don't run natively. I think it's valid to error out rather than assume it "will" work.

At best we may want to improve the error message to point to user to what to do for compatibility. I think we may need to document better in Conan Center how to operate natively on ARM64 Windows.

@codereba
Copy link
Contributor Author

Hi @jcar87 ,

I found this error has happened when building audacity with the following commands, please refer to:
https://github.com/audacity/audacity/blob/Audacity-3.7.1/conan/conanfile.py

git clone https://github.com/audacity/audacity.git
cd audacity
git checkout Audacity-3.7.1
mkdir build
cd build
cmake .. -G "Visual Studio 17 2022" -A ARM64 -Thost=ARM64 -B output -DCMAKE_BUILD_TYPE=Debug

The arch settings are configured by audacity, the arch setting of the msys2 is inherited from the profile of audacity.

@jcar87
Copy link
Contributor

jcar87 commented Jan 14, 2025

If audacity uses dependencies from Conan Center - please refer to their build instructions with regards to custom profiles https://github.com/audacity/audacity/blob/Audacity-3.7.1/BUILDING.md#custom-conan-profiles so that you can configure this option when building Audacity

@codereba
Copy link
Contributor Author

codereba commented Jan 14, 2025

Hi @jcar87 :

I think we can set -Thost=x64 to prevent this exception,
cmake .. -G "Visual Studio 17 2022" -A ARM64 -Thost=x64 -B output -DCMAKE_BUILD_TYPE=Debug
but if use the setting then all then modules are building by the x64 build tool (because cpu is armv8, that's emulated mode).

The CPU is armv8, that's better performance and compatibility if we can use the arm64 native building tool, and other modules are compiled correctly with native building tool, if we choose this solution, conan will build all the modules in emulated mode (that's not the best performance and compatibility).

That's my thought, Thanks for your explanation.

@jcar87
Copy link
Contributor

jcar87 commented Jan 14, 2025

I think you are correct, if when building Audacity you set -Thost=x64 then CMake will choose the non-native compiler, and everything that runs during the build would be slower and underised.

As I said - wherever Conan is invoked by Audacity, ensure that you can override the "build" profile such that the msys2 setting is overridden to the x86_64 architecture, without impacting anything else. We do not maintain the Audacity project so we're unable to provide further assistance.

@codereba
Copy link
Contributor Author

codereba commented Jan 14, 2025

Got it, could we refine the message? let user understand and resolve the issue easily, if only change the doc, the user needs to research the answer in the doc, that maybe a little more complicated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
2 participants