Skip to content
This repository has been archived by the owner on Jul 1, 2022. It is now read-only.

WIP: Pkg Artifacts with legacy mode #4

Merged
merged 11 commits into from
Jun 23, 2020
Merged

WIP: Pkg Artifacts with legacy mode #4

merged 11 commits into from
Jun 23, 2020

Conversation

benlorenz
Copy link
Member

@benlorenz benlorenz commented Mar 25, 2020

This is still work in progress

Switch to Pkg Artifacts for dependencies with a legacy mode for Julia 1.0 - 1.2.
Legacy mode is using a generated build_flint.jl which uses the tarballs from the artifacts.
To use the artifacts one has to add the OscarRegistry.

I have removed the source build as in #3, for now I have only added a FLINT_PATH environment variable to specify custom libflint.$dlext for julia 1.2 or older.
For julia 1.3 one can add the following to ~/.julia/artifacts/Overrides.toml:

[cabf4574-4f87-5802-9a0b-e4b5b01a80fc]
flint = "/home/me/flint-install"

where /home/me/flint-install should contain a lib directory containing libflint.so

I removed the setting of gmp memory functions. I dont think we should touch this, also julia is doing this by itself already and we should be using the julia-libgmp.

I added a small ccall test using flint_malloc and flint_free.

Issues / Todo:

  • multiple libgmp seems to cause no issues.
  • Add flint_jll to Yggdrasil.
  • update yggdrasil flint
  • Better integration of source build.
  • More testing of different configurations / julia versions: tests on travis seem good (as expected) so far
  • reverse dependency tests
  • and probably more

@fieker
Copy link
Contributor

fieker commented Mar 26, 2020

We're only setting the gmp functions in the unlikely event of having to load gmp ourselves. If gmp is already there, the memory functions are not touched. (This assumes that Julia is doing it)

@frankluebeck frankluebeck self-assigned this Mar 26, 2020
@fingolfin
Copy link
Member

There is now a Flint_jll (see JuliaPackaging/Yggdrasil#661) thanks to @benlorenz , yay!

@fingolfin
Copy link
Member

So, how important is support for Julia 1.0-1.2 to us? We can't support them in Oscar.jl anyway, because Gap.jl needs Julia 1.1 at the least (and I've gone full in with 1.3 otherwise since we declared elsewhere that'll be the minimum for Oscar overall).

I mean, I don't mind adding in backwards compatibility shims if that helps (and somebody else does it ;-) ), I just wonder if it's really worth the effort?

@fieker
Copy link
Contributor

fieker commented Apr 4, 2020 via email

@fingolfin
Copy link
Member

The main reason I am wondering is that using GMP_jll and Zlib_jll is considerably more convenient for me than using their "old-style" binary builder counterparts; yet I am afraid that mixing the two will again trigger the warning in LoadFlint about multiple GMP being loaded... For this reason, I also think we should disable that error. It's OK for Flint, but for GMP, it just is quite likely that this will be triggered eventually by other packages outside our control.

@benlorenz
Copy link
Member Author

At the moment it seems that with using GMP_jll (even without mixing with old style build.jl) there will always be two gmp libraries loaded, one from julia and one from the artifact. We could get rid of the second one for some packages by changing GMP_jll from a dependency to a build-dependency. But for all packages that need some compilation in build.jl (or even at runtime) we need GMP_jll for the gmp headers.

And just to be clear: the jll packages are what BinaryBuilder now produces, and BinaryProvider (which is used for he build_*.jl files) will be deprecated at some point.
See also here: JuliaPackaging/Yggdrasil#653

@benlorenz benlorenz force-pushed the artifactswithlegacy branch 6 times, most recently from 9431d87 to 462a3fc Compare April 4, 2020 13:00
@fieker
Copy link
Contributor

fieker commented Apr 6, 2020 via email

@fieker
Copy link
Contributor

fieker commented Apr 6, 2020 via email

@fingolfin
Copy link
Member

Sure, I am fine with using the old-style BinaryBuilder / BinaryProvider stuff here, resp. keep compatibility with Julia 1.0, if that's necessary for Nemo / to make Bill happy ;-).

As to multiple GMP versions being loaded: My point is that we can't prevent that anyway: if LoadFlint is loaded first then it doesn't see if a dozen copies of libgmp get loaded afterwards. There are Julia package using GMP_jll already anyway, and people may load them after Oscar...

In the meantime, the check causes an annoyance to people who would otherwise be happily using our stuff. So I would suggest that we downgrade it to a (big and fat) warning in the meantime... Independent of that, I'll work on fixing GAP.jl to not load a new GMP (it's going to be a bit slow today without the babysitter, but I'll manage ;-) )

@fieker
Copy link
Contributor

fieker commented Apr 6, 2020 via email

@fieker
Copy link
Contributor

fieker commented Apr 6, 2020 via email

@fingolfin
Copy link
Member

Overall, I like this PR: It allows us to use _Jll packages while retaining compatibility with Julia 1.0-1.2, so I'd hope @wbhart has no objects to it.

@benlorenz What needs to be done with this PR to make it ready, from your perspective? The one thing I found by re-reading the discussion is that GMP_jll.jl will always load a second copy of GMP... But apparently this causes no issues in practice (as otherwise I am sure others would have noticed, and also our tests).

I am really interested in getting this in, as it would allow GAP.jl and Polymake.jl to switch to Jll packages, which will simplify all kinds of things down the road, I think.

@benlorenz
Copy link
Member Author

I think the second gmp from GMP_jll should not cause issues. At some point this might be resolved by julia itself using pkg artifacts for dependencies.

I need to test the latest version with older julia versions again and check what downstream software needs in form of exported variables (libgmp path, libflint path, ..., maybe handles instead?)

Also I wanted to provide a function for running the old build script manually which at the end shows what is needed to use the custom installation.

I got distracted by trying to update polymake for the artifacts.

@fingolfin
Copy link
Member

Note that we use Travis to test this package against Julia 1.0, 1.3, 1.4 and nightly, on Linux and macOS. we can also add a test using Xcode 11.4; and we only dropped 1.1 and 1.2 to reduce the time the tests run, but we can of course add them back (this repo shouldn't get updates too often anyway).

Anyway, no pressure, we all are busy with many other things, too :-). I just got reminded of this because of oscar-system/GAP.jl#415 :-). Thank you for working on this.

add legacy mode for old julia version via build.jl

remove source build
FLINT_PATH for custom flint installations with julia 1.2 or older

dont touch gmp memory functions
@benlorenz benlorenz force-pushed the artifactswithlegacy branch 2 times, most recently from 442df11 to 214aeb9 Compare April 18, 2020 23:01
@benlorenz benlorenz force-pushed the artifactswithlegacy branch 2 times, most recently from 444e9ef to a871563 Compare June 7, 2020 23:43
Copy link
Member

@fingolfin fingolfin left a comment

Choose a reason for hiding this comment

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

@benlorenz the error on Travis you are seeing is about fmpz_poly_is_x -- this is a genuine error, as that function does not exist anymore in Flint 2.6.0, it was renamed. For compatibility, there is only this left:

fmpq_poly.h:260:#define fmpq_poly_is_x fmpq_poly_is_gen
fmpz_mod_poly.h:219:#define fmpz_mod_poly_is_x fmpz_mod_poly_is_gen
fmpz_poly.h:282:#define fmpz_poly_is_x fmpz_poly_is_gen

But of course that means there is no symbol we can ccall anymore. Ways to resolve this:

  1. We need to adjust Nemo.jl in lock step with the switch to Flint 2.6.0. If we also switch to JLLs at the same time, this might require a bit of a leap of faith.
  2. Or we first merge PR Just to test the new flint alpha #5 by @thofma, then update Nemo.jl, then update and merge this PR
  3. Or @wbhart releases Flint 2.6.1 with actual binary stubs for fmpz_poly_is_x and friends, then we can delay updating Nemo.jl

There are probably other approaches, we just need to pick one and execute on it.

deps/build.jl Outdated
end
println("DONE")
# GMP and MPFR might not be needed on unix as julia should have those loaded already
# but on windows flint will not load without them so we put leave them here for simplicity
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# but on windows flint will not load without them so we put leave them here for simplicity
# but on windows flint will not load without them so we leave them here for simplicity

@thofma
Copy link
Collaborator

thofma commented Jun 10, 2020

(#5 was only there to test the alpha release.)

Does this still allow to build flint locally? I mean, using the package manager and everything linked properly.

At the moment I can do NEMO_SOURCE_BUILD=1 and then Pkg.build("Nemo") will build flint locally.

Also, Nemo will require corresponding jll packages for arb and antic.

@wbhart
Copy link

wbhart commented Jun 10, 2020

The change has to be made in Nemo at some point. The intention was that it would happen immediately, which is why I didn't retain the symbol in the library.

@benlorenz
Copy link
Member Author

In the meeting I was referring to other builds with weird errors:
https://travis-ci.com/github/oscar-system/LoadFlint.jl/jobs/345475873
and
https://travis-ci.com/github/oscar-system/LoadFlint.jl/jobs/345656248

The first one seems to appear only with a fresh deps directory and also goes away when using an absolute path instead of dev .. The second one I don't understand yet.

@benlorenz
Copy link
Member Author

Regarding source build:
In my opinion it does not really make sense to have the code to build everything (flint, arb, antic, maybe even gmp and mpfr) from source in LoadFlint.jl.
It would also be good to have this outside of the package directory and not inside deps/....

There exist two mechanisms two provide a custom flint:

  • For julia >= 1.3 one can override the FLINT_jll location in Overrides.toml (which will be used by all packages using FLINT_jll and thus avoid any conflicts between different flint versions).
  • For julia 1.0 one can set the environment variable FLINT_PATH with a custom path.

Maybe Nemo can have a script or function that does a source build in a custom directory, independent of the julia build command. At the end of the build this could print the required Overrides.toml entries / environment variables. Something like the following made up output:

$ julia-1.3 /path/to/Nemo.jl/build_from_source.jl --prefix=/home/something/nemo-deps
...
Build successful.
Please add the following to your ~/.julia/artifacts/Overrides.toml:
# flint
[e134572f-a0d5-539d-bddf-3cad8db41a82]
FLINT = "/home/something/nemo-deps"

# arb
[... something ...]
arb = "/home/something/nemo-deps"

# antic
[... something ...]
antic = "/home/something/nemo-deps"

For julia 1.0 we could print FLINT_PATH and maybe some other variables that Nemo uses to pick up arb and antic.

@frankluebeck frankluebeck removed their assignment Jun 10, 2020
@benlorenz
Copy link
Member Author

benlorenz commented Jun 10, 2020

The change has to be made in Nemo at some point. The intention was that it would happen immediately, which is why I didn't retain the symbol in the library.

Maybe Nemo could do dlsym for both variants on first use (or even during startup) and use the function pointer later on? (To keep it compatible with flint 2.6 and 2.5)

This partially reverts commit 56e89f4,
to switch to the older flint for testing.
Also add compat to use old flint_jll.
@benlorenz
Copy link
Member Author

I have switched this back to the FLINT_jll from before 2.6 which was tagged as 0.0.1 in Yggdrasil. This is compatible with the current Nemo release and the also the latest polymake release.
I have added reverse dependency tests in travis building and testing Nemo and Polymake (and both together) with the current LoadFlint version. This takes quite a while but should cover all relevant platforms: https://travis-ci.com/github/oscar-system/LoadFlint.jl/builds/172498061
What is not currently tested on travis is using the custom flint path or overrides.

We can do the bump to 2.6 in a later pull request together with a version bump to 0.2.0 when Nemo is fixed to work with 2.6 (or can work with both flint versions).

@thofma
Copy link
Collaborator

thofma commented Jun 23, 2020

Thanks Benjamin. How about merging your PR and tagging it as 0.2.0? Then we can play with it on the Nemo side (without automatically using it) and see if everything works fine. I know that the reverse dependency tests should catch any such error, but I want to make sure :)

@benlorenz benlorenz marked this pull request as ready for review June 23, 2020 09:05
@thofma thofma merged commit 9b24d10 into master Jun 23, 2020
@fingolfin fingolfin deleted the artifactswithlegacy branch June 23, 2020 14:50
@fingolfin
Copy link
Member

Note that both Polymake.jl and Nemo.jl currently only use LoadFlint 0.1, so they won't see or use 0.2.0...

So what is the plan forward here? To update Nemo.jl and Polymake.jl to use LoadFlint.jl 0.2.0? Then release LoadFlint 0.3.0 which uses FLINT_jll 2.6.0 (which will of course not be able to pass the "reverse" tests), then afterwards update Nemo.jl and Polymake.jl once more.

(BTW, all these issue would be easy to resolve if we were using a monorepo ... :-)

@thofma
Copy link
Collaborator

thofma commented Jun 23, 2020

Yes. We should actually use something newer than 2.6.0. There has been some important bugfixes since then.

Nemo is basically good to go with Artifacts and legacy mode, see Nemocas/Nemo.jl#845.

thofma added a commit that referenced this pull request Jun 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants