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

Library building for Windows compilers #1476

Open
wants to merge 59 commits into
base: main
Choose a base branch
from
Open

Conversation

partouf
Copy link
Member

@partouf partouf commented Dec 7, 2024

Part of #1332

Will need to address the following:

  • Building with CMake on Windows
  • Building with MingW compilers
  • Building with MSVC compilers
  • Sending packages to Conan
  • Whatever else comes up

Will not include (things to be added later):

  • Windows builder packer image
  • Infra setup for Windows builder
  • Non-C++ stuff

@partouf
Copy link
Member Author

partouf commented Dec 7, 2024

Does not introduce a new LibraryBuilder class in order to reuse as much as possible from existing (proven) code

@partouf
Copy link
Member Author

partouf commented Dec 13, 2024

msvc builds done, now remains only conan stuff which is probably the hardest

@partouf
Copy link
Member Author

partouf commented Dec 13, 2024

TODO

  • Copy some extra files to Win SDK directory

image

@partouf
Copy link
Member Author

partouf commented Jan 9, 2025

Am at a a bit of deadlock now. Will write it down in the hopes that I miraculously think of the correct solution.

The problem:

When building the libraries for Windows, I force the recipe for conan to be a 'package install' which means it packages the install directory and you say to cmake hey install it to that directory.

This is done to avoid having headers on disk permanently like we have for most of our Linux libraries.

But the consequence of that is that the conan recipe changes, and that's replaced on the conan server for that library version.

Now, technically, CE doesn't actually use the recipes. It's only for telling conan what to zip up and upload. But if the recipe is changed, will it also say it needs reuploading for compilers that already have an upload? I need to figure this out first. I think I can check this by uploading a msvc build and then try to upload a build for a gcc that we've already done in the past. But I do need to disable force uploading before I do that.

Doing that now before continuing this writeup.

@partouf
Copy link
Member Author

partouf commented Jan 9, 2025

Ok, so changing the recipe doesn't cause issues with checking if a build has already been done.

Next issue:

Not having a directory where all the libraries are installed is obviously an issue for our ce_install build command. Because it first has to be installed before being able to build it.

I have tested the process simply by calling ce_install install first for the library and version that I was testing, but obviously this is terrible for automation.

So we need a way to temporary install the library version before building it.

The question is how, options are:

  • Have an option to install as part of the build command
  • Handle the installation outside of the python script

Either way, it will always cause installation of the library and will slow down the build even if there's nothing to build.
Then again, compared to looping over all the compilers and checking if it needs to be built, it's probably negligible.

I think it might be best to integrate it into the python script, since the installable is already available here https://github.com/compiler-explorer/infra/blob/main/bin/lib/ce_install.py#L478

Will give that a go.

@partouf
Copy link
Member Author

partouf commented Jan 10, 2025

Was pretty easy to add

@partouf
Copy link
Member Author

partouf commented Jan 17, 2025

Starting to work well.

MSVC x64 and x86 work, arm does not because supportsBinary is set to false. We can figure that out in the future.

Next todo:

  • Some paths for the buildscript are resolved to the network share, this is not really a thing we want to use (in case we want to add sandboxing or caching in the future or something), and it's not consistent.

Example:

cmake --install-prefix "C:\tmp\staging\8566353b-7420-4392-88eb-8fe6d4be4159\install"
-GNinja "-DCMAKE_VERBOSE_MAKEFILE=ON"
  "-DCMAKE_BUILD_TYPE=Debug"
 "-DCMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN=\\172.30.0.254\winshared\compilers\msvc\14.20.27508-14.20.27525.0\bin\Hostx64"
 "-DCMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN=\\172.30.0.254\winshared\compilers\msvc\14.20.27508-14.20.27525.0\bin\Hostx64"
  "-DCMAKE_CXX_FLAGS_DEBUG=/EHsc /utf-8    "
 -D "CMAKE_C_COMPILER=Z:/compilers/msvc/14.20.27508-14.20.27525.0/bin/Hostx64/x86/cl.exe"
 -D "CMAKE_CXX_COMPILER=Z:/compilers/msvc/14.20.27508-14.20.27525.0/bin/Hostx64/x86/cl.exe"
 C:\tmp\staging\libs\fmt\4.1.0 > cecmakelog.txt 2>&1

@partouf
Copy link
Member Author

partouf commented Jan 17, 2025

so Path.resolve() also resolves drives that are on a network share
os.path.abspath() does not (looks like it also normalizes, so that might be the way to go)
testing...

@partouf
Copy link
Member Author

partouf commented Jan 20, 2025

Todo:

@partouf
Copy link
Member Author

partouf commented Jan 25, 2025

  • cannot supply pwsh scripts in yaml file due to escaping issue of { and }, help needed

@mattgodbolt
Copy link
Member

Hi @partouf - can you give an example of something that repro's the issue you're facing?
Something like :

- after_stage_script
  - '{ moo }'

? where you don't want the { to be anything but a literal { ? I think this isn't a YAML problem if so but the config_expand.py not supporting escaping. I'll look to add that.

@partouf
Copy link
Member Author

partouf commented Jan 28, 2025

Hi @partouf - can you give an example of something that repro's the issue you're facing? Something like :

- after_stage_script
  - '{ moo }'

? where you don't want the { to be anything but a literal { ? I think this isn't a YAML problem if so but the config_expand.py not supporting escaping. I'll look to add that.

The problem starts when I want to allow alternatives to shellscripting, for example for boost_bin https://github.com/compiler-explorer/infra/blob/main/bin/yaml/libraries.yaml#L137
where -Werror is replaced in CMake files so we can actually build the library

An example for a Powershell alternative (according to our AI friends) would be:

      after_stage_script_pwsh:
      - Get-ChildItem -Recurse -Filter "CMakeLists.txt, *.cmake" | ForEach-Object {
      -   (Get-Content $_.FullName) -replace '-Werror', '-Wno-error' | Set-Content $_.FullName
      - }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants