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

Add windows build (try IV) #16

Closed
wants to merge 48 commits into from
Closed

Add windows build (try IV) #16

wants to merge 48 commits into from

Conversation

jpfeuffer
Copy link
Contributor

@jpfeuffer jpfeuffer commented Mar 28, 2024

Checklist

  • Used a personal fork of the feedstock to propose changes
  • Bumped the build number (if the version is unchanged)
  • Reset the build number to 0 (if the version changed)
  • Re-rendered with the latest conda-smithy (Use the phrase @conda-forge-admin, please rerender in a comment in this PR for automated rerendering)
  • Ensured the license file is being packaged.

@conda-forge-webservices
Copy link

Hi! This is the friendly automated conda-forge-linting service.

I just wanted to let you know that I linted all conda-recipes in your PR (recipe) and found it was in an excellent condition.

@wolfv
Copy link
Member

wolfv commented Mar 29, 2024

Hi @jpfeuffer thanks for working on this. If there is anything I can do to help, let me know :)

@jpfeuffer
Copy link
Contributor Author

Thank you! One question, not related to windows. What's happening with the Mac builds? It times out downloading the SDK on Intel for example.

@tkralphs
Copy link
Contributor

OK, so now we are back to the original problem, which is that we are trying to link to a BLAS library with Fortran linkage and we need one with C linkage. It looks like we are installing both libblas and libcblas, so maybe don't install libblas. You might also need to check that the path to and name of the library are correct in build.sh. I guess the CBLAS library may have a different name to avoid conflict (libcblas?).

@jpfeuffer
Copy link
Contributor Author

Okay. Now it says it supports C linkage but it "does not work" whatever that means 😅

@jpfeuffer
Copy link
Contributor Author

I found sth that indicates a missing include dir might be the problem:
https://stackoverflow.com/questions/32915936/linking-ipopt-against-openblas

I could add more variables but is there a better/automated way of finding dependencies here?

@tkralphs
Copy link
Contributor

tkralphs commented Mar 29, 2024

The reason for the failure to link is something you would normally figure out by looking at the config.log. If there is a way to get access to build artifacts after the fact, that would help. But I did realize that we are using the flag --with-blas. It might make no difference, but using --with-blas-lib is probably better and just to be safe, you do want to use --with-blas-incdir to specify the right include directory. This is necessary in general when linking to a package for which the header files are not in a location that is in the compiler's header search path.

@jpfeuffer
Copy link
Contributor Author

@tkralphs I am printing the log to the console now. I am not sure what to look for right now. I can go over the whole thing at some point but maybe you will see it quickly.

@jpfeuffer
Copy link
Contributor Author

I actually checked the whole logs now, and there is nothing else hinting on why BLAS linking would fail. But I might have missed something since those logs are incredibly convoluted.

@jpfeuffer
Copy link
Contributor Author

One thing I noticed is that a lot of paths are wrong. Apparently m2 is not well supported in conda and you have to do all kinds of workarounds to preserve paths.

ContinuumIO/anaconda-issues#12124

@jpfeuffer
Copy link
Contributor Author

Ok, as expected, tests introduce another level of complexity.
I would like to merge without tests and move on to the solvers. In the meantime of course someone could do a parallel PR to fix tests here.

@tkralphs
Copy link
Contributor

tkralphs commented Apr 6, 2024

The issue in the test will be fixed in the next release by this: coin-or/CoinUtils#217. Why don't you just leave it for now and after I make the release, we can see if it's fixed.

@jpfeuffer
Copy link
Contributor Author

Yes that's fine, I was about to wait for the release anyway. I just don't want it to be a longer thing because if I lose focus on this side project I am not sure when I will revisit.

@tkralphs
Copy link
Contributor

tkralphs commented Apr 6, 2024

There was a timeout installing Mamba, which I guess will fix itself, but I couldn't see how to force the workflows to be run again except by closing and reopening the PR. But anyway, everything seems to be good with the new release.

@wolfv
Copy link
Member

wolfv commented Apr 6, 2024

I triggered a rerun from the github page :)

@jpfeuffer
Copy link
Contributor Author

jpfeuffer commented Apr 6, 2024

I think we need to skip tests on osx-arm since it's cross compiled. Could that be?
Or can you run the executables under Rosetta emulation on those Mac runners?
Edit: Rosetta works the other way round of course. So I think we should disable.

@tkralphs
Copy link
Contributor

tkralphs commented Apr 7, 2024

Yeah, let's just skip tests on osx-arm.

@wolfv
Copy link
Member

wolfv commented Apr 7, 2024

You could also use

test: native_and_emulated

in the conda-forge.yml file and then it should not run the tests on osx-arm64 (after a conda-smithy rerender).

@wolfv
Copy link
Member

wolfv commented Apr 7, 2024

Actually, you can remove the deprecated value of test_on_native_only: true and add test: native_and_emulated to conda-forge.yml and then rerender :)

The rerender would also use the new URL in the readme etc. so it might be good to do anyways.

I did it locally but for some reason can't push to your PR.

@jpfeuffer
Copy link
Contributor Author

@wolfv does this also work if the tests are in the build stage?
I think the failing tests are the one from the build stage. If we want to test the test suite in the test stage we would need to restructure quite a bit.

@wolfv
Copy link
Member

wolfv commented Apr 7, 2024

@jpfeuffer you're right. sorry. you could do a bash if statement in that case.

if [[ $target_platform != "osx-arm64" ]]; then
   make test
fi

@h-vetinari
Copy link
Member

The general pattern for this would be:

if [[ "$CONDA_BUILD_CROSS_COMPILATION" != "1" ]]; then
  # run the tests; cannot be done in cross-compilation
  make tests
fi

@jpfeuffer
Copy link
Contributor Author

Yep I found it in the docs. I used it like this.
It's ready to merge I think! 🤞

Copy link
Member

@h-vetinari h-vetinari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First look; not sure how this works without a fortran compiler... 🤔

I'm not a maintainer here (though floating around the cbc stack for a while), but personally I'd prefer a cleaner git history for this PR. 🤷

recipe/meta.yaml Outdated Show resolved Hide resolved
recipe/meta.yaml Outdated Show resolved Hide resolved
recipe/meta.yaml Outdated Show resolved Hide resolved
recipe/meta.yaml Outdated
- {{ compiler('fortran') }}
- pkg-config
- make # [unix]
- {{ compiler('fortran') }} # [not win]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand how this works - how is it possible that we don't need a fortran compiler on windows after all?
The configure script already warns:

configure: WARNING: Failed to find a Fortran compiler!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The project itself has no Fortran, the Fortran compiler is needed when linking to a Blas/Lapack library with Fortran linkage to determine the name-mangling scheme (I'm not really an expert on this). When either not linking to Blas/Lapack at all (it is not technically needed, though performance is better with it) or when linking to a Blas/Lapack with C linkage, no Fortran compiler is needed. Granted, the warning is a little confusing, though it is only a warning, not an error.

My (now very vague) recollection, pieced together by looking at comments I wrote during earlier attempts, is that we were at first trying to link to Blas/Lapack with Fortran linkage, which first failed because of the lack of a Fortran compiler and then because of the unexpected extension for object files built with flang.

It's quite possible I failed to see the forest for the trees at that point and got caught up in trying to fix the immediate issue rather than taking a step back to see that this could be avoided altogether by just leaving out the --with-blas flag rather than trying to make the Fortran linkage work. I took the presence of those flag for granted for some reason and there's still no way to make the build work with those flags present on WIndows. Even coming back to it this time with fresh eyes, it wasn't until I tried to really isolate why we've able to build on Github Actions and not here that I realized that it was those flags that were the culprit.

Anyway, sorry for the tail-chasing.

Comment on lines +13 to +16
fortran_compiler:
- flang
fortran_compiler_version:
- '5'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that you're still adding fortran compilers here (seems to be based on an old rerender before adding the selector to the fortran compiler). However, since the dependency is missing in meta.yaml, this isn't actually pulled into the build environment for now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would think we should remove this now.

@tkralphs
Copy link
Contributor

tkralphs commented Apr 9, 2024

OK, so everything is passing now, but there are a few unresolved conversations above. @jschueller, can you let me know when you think we're ready to go?

@jpfeuffer
Copy link
Contributor Author

jpfeuffer commented Apr 9, 2024

@tkralphs I want to have a look at the blas problem. Can you explain how the version of blas affects coin?
Are there preferred versions? libblas vs libcblas vs none? Does it make sense to have both at any time?

Should we just try to use cblas on all platforms to avoid having to deal with fortran?

@tkralphs
Copy link
Contributor

Can you explain how the version of blas affects coin?
Are there preferred versions? libblas vs libcblas vs none? Does it make sense to have both at any time?

As I said, I am not an expert on this, but there are two separate issues. The first issue is practical---how to link to the library. The second issue is performance. There are many different implementations of the BLAS API and their performance will differ. Which one would be the best performing with Cbc probably differs by platform. I don't have a specific recommendation for that. On Windows, whatever we can make work would be good.

For the linking, to link to a library with Fortran linkage, you need to know the name-mangling scheme used by the library (you can read about the general idea here if you're unfamiliar), which is why the Fortran compiler is required. My recollection, though. is that flang is not going to work as a compiler on Windows because it doesn't produce object files with the extension expected on Windows (.o versus .obj, unless this has changed). So even if the linking is successful, the tests fails because configure does not detect that the object files was correctly produced.

So I believe our only option is to link to a library with C linkage. cblas is just a C wrapper around the original BLAS interface and should be what we need. But I could not see how to link to the DLL provided by cblas, as discussed above.

That is about the extent of my knowledge. We can seek out some advice if we need to know more, but I would personally just merge and move on to trying to get a working Cbc on Windows. After it's working without BLAS, we can separately try to add BLAS later.

@jpfeuffer
Copy link
Contributor Author

jpfeuffer commented Apr 10, 2024

Ok since we are also not passing --with-lapack and lapack also needs fortran, I removed everything fortran related now.
Let's add it coorectly in a second round.

@jpfeuffer
Copy link
Contributor Author

Will do a re-render once it passes.

@jpfeuffer
Copy link
Contributor Author

@conda-forge-admin, please rerender

Copy link
Contributor

Hi! This is the friendly automated conda-forge-webservice.

I tried to rerender for you, but it looks like I wasn't able to push to the add-windows-build branch of jpfeuffer/coin-or-utils-feedstock. Did you check the "Allow edits from maintainers" box?

NOTE: Our webservices cannot push to PRs from organization accounts or PRs from forks made from organization forks because of GitHub permissions. Please fork the feedstock directly from conda-forge into your personal GitHub account.

This message was generated by GitHub actions workflow run https://github.com/conda-forge/coin-or-utils-feedstock/actions/runs/8630351073.

@jpfeuffer jpfeuffer closed this by deleting the head repository Apr 10, 2024
@jpfeuffer
Copy link
Contributor Author

I re-did the PR by re-forking from conda-forge directly. Also to cleanup commit history.

@jpfeuffer
Copy link
Contributor Author

That is about the extent of my knowledge. We can seek out some advice if we need to know more, but I would personally just merge and move on to trying to get a working Cbc on Windows. After it's working without BLAS, we can separately try to add BLAS later.

I am fine with that approach. However, this might be surprising for some people used to having this feature. At least during the transition period until our new release is on par with the old one again.

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.

5 participants