-
Notifications
You must be signed in to change notification settings - Fork 231
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
Fixing build for arm64 Windows #582
Fixing build for arm64 Windows #582
Conversation
Thank you for this. It is awesome that you are supporting ktx on vcpkg. I will report the compiler bug to ARM to get the workaround in the upstream astc-encoder. Please modify the GitHub action to use the build script The configuration should include FEATURE_DOC=ON, FEATURE_TOOLS=ON & SUPPORT_SSE=OFF. I'd also like to include FEATURE_JNI=ON if it can be done easily, i.e. if the GitHub Actions VM includes a JDK. (Appveyors' do). The Release build should also have PACKAGE=YES to build the installer. Does Actions have a Windows arm64 VM available? If so it would be better to run the build on that so that KTX_FEATURE_TESTS can be on and the tests run after the CI build. As you have them off, you must have discovered that they error when cross-compiling. This is because cmake attempts to execute the compiled tests to have gtest add the list of tests to the cmake test runner. If the build must be done on x64 Windows then |
Yeah I can update the yml to use the build script no problem The only issue is that Github does not support arm64 on windows. There is no Server build of Windows available so they don't provided an arm64 windows env. See this closed PR for more details: actions/runner-images#768 . That's why I had to turn off the Tests. This is cross compiling with MSVC from an x64 host so the tests compile fine but they can't be run. |
Okay. Please modify the build script to support turning off the tests. If you want an example, |
I will very soon be landing changes for signing windows binaries and installers. I want to get this working on the arm build as well. For that I need equivalents to the following from upcoming .appveyor.yml changes to be added to the GitHub action: In the global environment
In the install phase
In the before_build phase
The appveyor-tools for secure file decryption should work fine on any Windows system. The 3 environment variables are must be encrypted. Please add these to this PR when you make the changes to use the script. |
So a couple notes from the first pass on this:
|
…t will return failure codes
Well the matrix was a good idea because packaging is broken right now. I reproduced this locally: a |
Just pulled master and that, as well as appveryor package just fine... Some of my changes must have broken something |
After some trial and error... you can't package a build that doesn't build tools. That makes sense... |
Don't know why that build failed downloading doxygen. I ran the action on my fork and it succeeded: https://github.com/Honeybunch/KTX-Software/actions/runs/2419034724 |
I don't entirely follow. Only VS2022 is fine. Is there some other problem?
I know nothing about Actions. On the other CI platforms I'm familiar with each job gets a pristine VM so they all can and do share a common build directory name. The purpose of the environment variable is to make sure the build directory name is passed to the deploy step, yet to be added here, without error. What is important is that any package name reflect the platform as all the packages will eventually end up in a single directory in GitHub Releases and people need to be able to pick their package. I want to deploy the Windows ARM package and the Android package from Actions.
Sorry about that. This script returning an error is not generally all that useful because the VS builds it calls do not themselves return any error exit state. Nevertheless it is good to fix it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please package only the release configuration to save build time.
The installing doxygen step seems to have taken 0 seconds and there is no output. If you are installing Doxygen from Chocolatey there the problem was likely an issue communicating with the Chocolatey server. I use it from Appveyor for older build images and it is notoriously unreliable. Luckily VS2019 and later VM images on Appveyor come with Chocolately installed. UPDATE: I clicked the broken check in the list below instead of the link in your comment. I see the error. I think all we can do is retry. UPDATE 2: I've initiated a retry. Why are many of the windows-arm64 jobs after the broken one listed as dependents and therefore were not run? Do all the jobs share a VM in Actions so they need the Doxygen download to succeed? We only need to include FEATURE_DOCS=YES in the Release config build we are packaging. The docs are the same in all configs. |
I have just landed the PR #583 for signing the Windows binaries and packages. Please rebase this PR with master to include it. You will have a conflict in |
…into arm64-windows-fix
Just took care of the merge. Day job has been busy. Going to try to get this sorted this weekend |
I have tried to reproduce the Appveyor build failures and have failed. The same failures happen in master but are masked because, prior to your fix, To pursue this I recommend
I also recommend cancelling all other builds after pushing these changes. The mentioned variable |
Done. Now lets get this PR finished. |
…into arm64-windows-fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some questions I'd like to know the answers to.
@@ -174,6 +174,10 @@ submitted to the exclusive jurisdiction of the Swedish Courts. | |||
#if defined(_MSC_VER) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't you say
#if defined(_MSC_VER) && !__clang__
and then let the existing #elif __clang__
handle the clang case?
Done the way it is here raises the question for me of how does clang_cl handle the pragma warning
statements. Does it just ignore them or does it warn about them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could do that yeah. An easy refactor for sure.
ClangCL does report MSVC's error codes so it does also handle the MSVC specific warning statements. That's why I did it this way, I figured whatever warnings we want to disable for MSVC we also want to disable for ClangCL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like you did refactor it.
If CLangCL is handling MSVC specific warnings there shouldn't be any need for the #pragma clang diagnostic ignored "-Wunused-parameter"
as that is the same as warning 4100 in CL. Because we do need it, it looks like at best #pragma warning
is being ignored. Is CLangCL's handling of #pragma warning
documented somewhere?
I agree with the statement "I figured whatever warnings we want to disable for MSVC we also want to disable for ClangCL.". If the original way you did it implements this then restore it but add a comment as to why and about the way CLangCL handles these things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes sorry looks like it just ignores them. This current approach works the same as it did before, it's no longer if/else with _MSC_VER
so we apply msvc style warning pragmas for any compiler that has it defined. It's a little odd to read though so if you want I can make it explicit like I did before
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way you have it is fine but I suggest adding a comment // clang_cl defines both _MSC_VER and __clang__
to prevent somebody going down the road of trying #elif
in future.
CMakeLists.txt
Outdated
# When targeting Windows arm64 CMAKE_SYSTEM_PROCESSOR will incorrectly | ||
# return AMD64. | ||
# See: https://gitlab.kitware.com/cmake/cmake/-/issues/15170 | ||
# We assume that when builing for Windows arm64 that we are using MSVC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/builing/building/
CMakeLists.txt
Outdated
@@ -524,7 +524,7 @@ PRIVATE | |||
# "CMAKE_CXX_COMPILER_ID = ${CMAKE_CXX_COMPILER_ID} " | |||
# "CMAKE_CXX_COMPILER_VERSION = ${CMAKE_CXX_COMPILER_VERSION}" | |||
#) | |||
if(MSVC) | |||
if(${CMAKE_CXX_COMPILER_ID} MATCHES "MSVC") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is another if(MSVC)
at line #158 that needs fixing. That is why the Appveyor CI build is failing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, not sure why Appveyor is failing yet but changing that at 158 causes other errors that make ClangCL builds fail with:
clang-cl : error : argument unused during compilation: '-O0'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see what's happening on appveyor. Yeah, strange. Let me see if I can figure out a better solution here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
REALLY not sure why Appveyor's environment results in CMake not understanding the MSVC check
lib/etcdec.cxx
Outdated
#elif __clang__ | ||
#pragma warning(disable: 4100 4244) | ||
#endif | ||
#if __clang__ | ||
#pragma clang diagnostic push | ||
#pragma clang diagnostic ignored "-Wunused-parameter" | ||
#if __clang_major__ > 13 || (__clang_major__ == 13 && __clang_minor__ >= 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're still getting unused-but-set-variable
warnings in the CLangCL builds. Probably the version number here needs adjusting. I think I must have found that version 13.0.0 complained that -Wunused-but-set-variable
was unrecognized hence the carve out.
It appears that Apple Clang has different version numbers from Clang which is why CMake inrtroduced AppleCLang
as a compiler id. Looking at this chart Apple Clang version 13.0.0 is based on clang 12.0.0. Not sure then why I got unused-but-set as unrecognized for 13.0.0 since we're seeing it in clang 12.0.0.
Anyway we need to fix version number handling here and in CMakeLists to account for the differences. According to the chart, Xcode 14 will have Apple clang 14.0.0 which is base on clang 14.0.0 so maybe they'll stay in better sync from here on.
Ahh! The fifth answer to this SO question says that in Clang you can use statements like #if __has_warning("-Wunused-but-set-variable")
. That will be much better than version number heuristics. Please change this code accordingly.
Not sure what to do in CMakeLists.
The mingw build is also getting warnings so these blocks of warning disables need to handle that compiler too. Isn't it GCC? It is better to make a new PR for fixing those and concentrate here on fixing clang-cl. |
Cleaned up some mingw warnings since I was curious and they were simple. Though I do see a warning with |
Are you absolutely sure that |
I figured out where those warnings are coming from. They're from building the |
Thank you @Honeybunch for this amazing piece of work with all its attention to detail. |
* Set up code signing in GitHub actions. * Fix compile warnings in both clang_cl and mingw. * Fix build script to return failure codes
* Set up code signing in GitHub actions. * Fix compile warnings in both clang_cl and mingw. * Fix build script to return failure codes
* Set up code signing in GitHub actions. * Fix compile warnings in both clang_cl and mingw. * Fix build script to return failure codes
* Set up code signing in GitHub actions. * Fix compile warnings in both clang_cl and mingw. * Fix build script to return failure codes
* Set up code signing in GitHub actions. * Fix compile warnings in both clang_cl and mingw. * Fix build script to return failure codes
A side effect of trying to get the arm64-android triplet available for ktx on vcpkg, I discovered that the arm64-windows build was also broken due to a compiler bug. So I've provided a workaround. See: microsoft/vcpkg#24869
Not sure if this is the best mechanism for applying a compiler flag globally to the astc-encoder but it did work. Happy to tweak this approach.