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

[WIP] sage: Add darwin support #45364

Closed
wants to merge 2 commits into from
Closed

Conversation

jbaum98
Copy link
Contributor

@jbaum98 jbaum98 commented Aug 20, 2018

Motivation for this change

I want sage to build on darwin. Lot's of packages just need their platforms updated.

Right now, I'm having trouble getting sagelib to build, failing with an error

clang++ -bundle -undefined dynamic_lookup build/temp.macosx-10.10-x86_64-2.7/build/cythonized/sage/libs/linbox/linbox.o -L/nix/store/5w9j23h0qsar813vdvsi1dyhg73iczlh-givaro-4.0.4/lib -L/nix/store/l3xnp9rniv92n69m2mls4ww0s14jqln0-linbox-1.5.2/lib -L/private/tmp/nix-build-python2.7-sagelib-8.3.drv-1/sage-src-8.3/lib -L/nix/store/xkksa1sdiddm4m7hd2mx87acvbs3rzjd-python-2.7.15/lib -llinbox -llinboxsage -lblas -lgivaro -lgmp -lgmpxx -lstdc++ -o build/lib.macosx-10.10-x86_64-2.7/sage/libs/linbox/linbox.so
ld: warning: directory not found for option '-L/private/tmp/nix-build-python2.7-sagelib-8.3.drv-1/sage-src-8.3/lib'
ld: library not found for -lblas
clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation)

I know it's blas related, but there's a lot of blas stuff going on in pkgs/applications/science/math/sage/sagelib.nix. @timokau any thoughts?

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Fits CONTRIBUTING.md.

@timokau
Copy link
Member

timokau commented Aug 20, 2018

The equivalent log line from the linux build is

g++ -pthread -shared -lgcc_s build/temp.linux-x86_64-2.7/build/cythonized/sage/libs/linbox/linbox.o -L/nix/store/5pbx09wbqrmfplri7jgzq4gcpnbcd0nm-givaro-4.0.4/lib -L/nix/store/m4lqi72qdfnkr2vyydl8hr2x1fwhmyhk-linbox-1.5.2/lib -L/build/sage-src-8.3/lib -L/nix/store/f01rhaxdfip9c49k4mhfjgfrwl5lcamn-python-2.7.15/lib -llinbox -llinboxsage -lgivaro -lgmp -lgmpxx -lopenblas -lstdc++ -lpython2.7 -o build/lib.linux-x86_64-2.7/sage/libs/linbox/linbox.so

I'm honestly a bit surprised how that works because the openblas lib dir is not passed to the linker. Anyways I think the important difference is -lopenblas on linux vs -lblas on darwin. Anyways the args passed to gcc are generated in sage's env.py starting at line 313. That is done by calling pkgconfig. Since you changed linboxes blas from openblas to blas, that causes the difference. So you probably need to add plain blas as a dependency for sage as well.

@@ -91,7 +91,8 @@ stdenv.mkDerivation rec {
license = licenses.gpl3Plus;
## xcas is buildable on darwin but there are specific instructions I could
## not test
platforms = platforms.linux;
## ^^ not sure what this means
Copy link
Member

Choose a reason for hiding this comment

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

@symphorien do you remember what you meant by that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah that was a note that I wanted to discuss that comment above about xcas

Copy link
Member

Choose a reason for hiding this comment

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

OSX is supported as per https://www-fourier.ujf-grenoble.fr/~parisse/giac_compile.html
but the compilation process is said to be different: quote:

Notes for compilation on Mac OS X. For recent versions of giac (>=0.9.x) on Mac OS X.6 run the script mkosx.

So I thought the derivation would not work as such on osx and would require more work.

Copy link
Member

@symphorien symphorien Sep 6, 2019

Choose a reason for hiding this comment

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

If xcas works as is on darwin, you can just remove the comment.

@jbaum98
Copy link
Contributor Author

jbaum98 commented Aug 20, 2018

There are like three or four dependencies with openblas in the name, a few of which seem to have to do with pkg-config. I should change them all to blas? Or do I just have to change the input to sage in all-packages and it will propagate by itslef?

@timokau
Copy link
Member

timokau commented Aug 20, 2018

Those provide different pkg-config files for openblas, see #45257. If you want to switch to blas completely, you probably would have to provide equivalents of those for blas. For now I'd just try to add blas in addition to openblas. Its not pretty but it might work (its only needed to compile the cython files interfacing with linbox).

@timokau
Copy link
Member

timokau commented Aug 20, 2018

Also I think openblas and atlas are the only two officially supported blas implementations by sage. So not sure if plain blas would work.

@timokau
Copy link
Member

timokau commented Oct 3, 2018

@jbaum98 are you still interested in this?

@jbaum98
Copy link
Contributor Author

jbaum98 commented Oct 4, 2018

I am, I haven't had much time to work on it though. What was the decision on the blas thing?

@timokau
Copy link
Member

timokau commented Oct 4, 2018

What decision?

@timokau
Copy link
Member

timokau commented Oct 4, 2018

Regarding the blas thing I would recommend to try if the plain sage package (which currently doesn't run any tests) also fails the fflas_ffpack tests. If not, compare differences in build. If yes, just disable checks on darwin for now (it is reported upstream and nobody has noticed yet so it cannot be too serious).

@mmahut
Copy link
Member

mmahut commented Aug 25, 2019

Are there any updates on this pull request, please?

@jbaum98
Copy link
Contributor Author

jbaum98 commented Aug 25, 2019

Sorry, this fell off my radar. I may be able to take another crack at it in a few weeks, but I started this because I needed to use sage, and I don't anymore.

@timokau
Copy link
Member

timokau commented Aug 25, 2019

While full darwin support for sage would be nice of course, isn't the part in this PR basically ready?

@vcunat
Copy link
Member

vcunat commented Aug 25, 2019

Yes, assuming those packages (still) work reasonably on darwin...

@timokau
Copy link
Member

timokau commented Aug 25, 2019

@jbaum98 are you up to a rebase and a re-test?

@jbaum98
Copy link
Contributor Author

jbaum98 commented Aug 26, 2019

For sure. I won't be able to do it for another week or two because I don't have a Mac machine available right now.

@jbaum98
Copy link
Contributor Author

jbaum98 commented Sep 6, 2019

I did a rebase and now it's stuck building gap because libtool is using an absolute path:

/usr/bin/libtool -o libz.a adler32.o crc32.o deflate.o infback.o inffast.o inflate.o inftrees.o trees.o zutil.o compress.o uncompr.o gzclose.o gzlib.o gzread.o gzwrite.o
xcode-select: error: no developer tools were found at '/Applications/Xcode.app', and no install could be requested (perhaps no UI is present), please install manually from 'developer.apple.com'.

This particular issue seems to have a straightforward fix, but I can't say if I'll have time to work on this for a bit. I feel like this isn't the issue I was stuck on last time, but to be honest I don't remember that well.

@vcunat
Copy link
Member

vcunat commented Sep 8, 2019

libgap was an unreachable file, so I removed it in 252a30e.

@GrahamcOfBorg build gap giac lrcalc nauty
@GrahamcOfBorg build pynac singular ecl arb
@GrahamcOfBorg build fplll iml mpfi brial
@GrahamcOfBorg build cliquer m4ri m4rie rankwidth
@GrahamcOfBorg build rubiks sympow python3Packages.cvxopt

@vcunat
Copy link
Member

vcunat commented Sep 8, 2019

The merge conflict was blocking the builds, I presume, so let me try again:

@GrahamcOfBorg build gap giac lrcalc nauty
@GrahamcOfBorg build pynac singular ecl arb
@GrahamcOfBorg build fplll iml mpfi brial
@GrahamcOfBorg build cliquer m4ri m4rie rankwidth
@GrahamcOfBorg build rubiks sympow python3Packages.cvxopt

@vcunat
Copy link
Member

vcunat commented Sep 8, 2019

If I read Borg right, the only build failures are gap and sympow.

vcunat added a commit that referenced this pull request Sep 15, 2019
vcunat amended the commit a bit; see the PR for details/discussion.
@timokau
Copy link
Member

timokau commented Sep 20, 2019

Right, libgap is outdated.

If I read Borg right, the only build failures are gap and sympow.

In that case should we just leave out the gap and sympow parts for now?

@vcunat
Copy link
Member

vcunat commented Sep 21, 2019

Yes, that's what I did last weekend; Hydra: https://hydra.nixos.org/eval/1542673#tabs-new

@vcunat vcunat closed this Sep 21, 2019
vcunat added a commit that referenced this pull request Sep 21, 2019
vcunat amended the commit a bit; see the PR for details/discussion.

(cherry picked from commit 991c0e1)
@timokau
Copy link
Member

timokau commented Sep 21, 2019

Nice, thanks @vcunat and @jbaum98 :)

@timokau
Copy link
Member

timokau commented Sep 25, 2019

By the way I'm still interested in getting sage to run on darwin. As far as I'm aware, there is currently no good way for a mac user to install sage without building it from source. So this could help a lot of people.

If anyone wants to take a shot, feel free to reach out either by opening a new nixpkgs issue or messaging me on IRC/matrix.

@symphorien symphorien mentioned this pull request Nov 25, 2019
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants