staticfloat / homebrew-julia

small repository to install julia
221 stars 35 forks source link

julia quasi-broken after gcc update #238

Open tcovert opened 7 years ago

tcovert commented 7 years ago

Hi @staticfloat.

I just did a brew update, which lead to a new version of gcc (I am now using version 7.10 apparently). Now I get linear algebra warnings when I start julia, like this:

tcovert-imac:~ tcovert$ julia
WARNING: Error during initialization of module LinAlg:
ErrorException("could not load library "libopenblas"
dlopen(libopenblas.dylib, 1): Library not loaded: /usr/local/opt/gcc/lib/gcc/6/libgfortran.3.dylib
  Referenced from: /usr/local/opt/openblas-julia/lib/libopenblas.dylib
  Reason: image not found")
WARNING: Error during initialization of module CHOLMOD:
ErrorException("could not load library "libcholmod"
dlopen(libcholmod.dylib, 1): Library not loaded: /usr/local/opt/gcc/lib/gcc/6/libgfortran.3.dylib
  Referenced from: /usr/local/opt/openblas-julia/lib/libopenblasp-r0.2.19.dylib
  Reason: image not found")
               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.5.1 (2017-03-05 13:25 UTC)
 _/ |\__'_|_|_|\__'_|  |  homebrew-julia release
|__/                   |  x86_64-apple-darwin16.4.0

julia> 

My guess is that the only thing that needs to change is for julia to look for libgfortran in /usr/local/opt/gcc/lib/gcc/7/ instead of /usr/local/opt/gcc/lib/gcc/6/ but I don't know how to make that happen.

I tried uninstalling julia, arpack-julia, suite-sparse-julia and openblas-julia, and re-installing, but the error persists. FWIW I had a similar problem with R this morning and I solved it by re-building it from source, which I guess is not possible with julia home-brew?

Any advice? Thanks.

joshbode commented 7 years ago

Same issue here.

This fixes it for me until the julia and openblas-julia bottles are eventually rebuilt:

$ brew reinstall --build-from-source openblas-julia
$ ln -s /usr/local/Cellar/openblas-julia/0.2.19/lib/libopenblas{_penryn,}p-r0.2.19.dylib

The second command is a bit of a hack to avoid rebuilding julia from source, which is looking for /usr/local/opt/openblas-julia/lib/libopenblasp-r0.2.19.dylib and the name (e.g. penryn) may be slightly different depending upon your hardware. Alternatively, instead of the symlink, do:

$ brew reinstall --build-from-source julia
tcovert commented 7 years ago

@joshbode Thanks for the suggestion - that worked. I ended up just building openblas-julia from source anyway. I didn't realize that if you do brew install --build-from-source julia, home-brew only compiles julia and not the dependencies!

dpo commented 7 years ago

@tcovert If you want to build all dependencies from source, you can do

HOMEBREW_BUILD_FROM_SOURCE=1 brew install julia
aseemmahajan commented 7 years ago

Hi @staticfloat, I'm still getting an error where libopenblas looks for libgfortran in the gcc6 rather than the gcc7 directory, even after reinstalling gcc, julia, open-blas, suite-sparse, and arpack from their source (I've pasted the errors and warnings below). Would you have any suggestions? Thanks!

`WARNING: Error during initialization of module LinAlg: ErrorException("could not load library "libopenblas" dlopen(libopenblas.dylib, 1): Library not loaded: /usr/local/opt/gcc/lib/gcc/6/libgfortran.3.dylib Referenced from: /usr/local/opt/openblas-julia/lib/libopenblas.dylib Reason: image not found") WARNING: Error during initialization of module CHOLMOD: ErrorException("could not load library "libcholmod" dlopen(libcholmod.dylib, 1): Library not loaded: /usr/local/opt/gcc/lib/gcc/6/libgfortran.3.dylib Referenced from: /usr/local/opt/openblas-julia/lib/libopenblasp-r0.2.19.dylib Reason: image not found") WARNING: Error during initialization of module LinAlg: ErrorException("could not load library "libopenblas" dlopen(libopenblas.dylib, 1): Library not loaded: /usr/local/opt/gcc/lib/gcc/6/libgfortran.3.dylib Referenced from: /usr/local/opt/openblas-julia/lib/libopenblas.dylib Reason: image not found") WARNING: Error during initialization of module CHOLMOD: ErrorException("could not load library "libcholmod" dlopen(libcholmod.dylib, 1): Library not loaded: /usr/local/opt/gcc/lib/gcc/6/libgfortran.3.dylib Referenced from: /usr/local/opt/openblas-julia/lib/libopenblasp-r0.2.19.dylib Reason: image not found")

dpo commented 7 years ago

@aseemmahajan Make sure you don't have old builds of dependencies lying around. E.g., what's in /usr/local/Cellar/openblas-julia? If that doesn't help, could you paste here the output of brew gist-logs openblas-julia and brew gist-logs julia? (Those commands output URLs.)

prairie-guy commented 7 years ago

I had a working (brew installed) version of julia until I upgraded to OSx 10.12 I am now unable to successfully install julia with: brew install julia I am using OSx 10.12.5 (16F73) I have successfully executed the following: brew update, brew upgrade, brew doctor

Here is the output from gcc --version:

$ gcc --version Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/c++/4.2.1 Apple LLVM version 8.1.0 (clang-802.0.42) Target: x86_64-apple-darwin16.6.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Per this thread, I have tried all of the following:

In all cases, I removed the dependencies before trying the installation of julia.

If I do a vanilla install and then launch julia, here is the output:

`$ julia WARNING: Error during initialization of module LinAlg: ErrorException("could not load library "libopenblas" dlopen(libopenblas.dylib, 1): Library not loaded: /usr/local/opt/gcc/lib/gcc/6/libgfortran.3.dylib Referenced from: /usr/local/opt/openblas-julia/lib/libopenblas.dylib Reason: image not found") WARNING: Error during initialization of module CHOLMOD: ErrorException("could not load library "libcholmod" dlopen(libcholmod.dylib, 1): Library not loaded: /usr/local/opt/gcc/lib/gcc/6/libgfortran.3.dylib Referenced from: /usr/local/opt/openblas-julia/lib/libopenblasp-r0.2.19.dylib Reason: image not found")

Version 0.5.1 (2017-03-05 13:25 UTC) homebrew-julia release x86_64-apple-darwin16.4.0 `

I'm stuck. Any advice would be greatly appreciated. I have been a long time julia user and have used it flawlessly in the past on OSx and Ubuntu without issue.

Thanks in advance.

prairie-guy commented 7 years ago

On further investigation, I note from the error: Library not loaded: /usr/local/opt/gcc/lib/gcc/6/libgfortran.3.dylib that gcc/6/ does not exist.

Instead, I have: /usr/local/opt/gcc/lib/gcc/7/libgfortran.4.dylib

Not sure how to resolve this.

prairie-guy commented 7 years ago

Per a previous request, I have executed the following (still getting an error):

brew reinstall --build-from-source openblas-julia brew reinstall --build-from-source julia

brew gist-logs openblas-julia https://gist.github.com/f091b18a65bd3557c42e45d5072dbd39

dpo commented 7 years ago

Try brew uninstall --ignore-dependencies --force $(brew deps --recursive julia) followed by brew install julia.

prairie-guy commented 7 years ago

Thanks for helping!

I tried your suggestion: brew uninstall --ignore-dependencies --force $(brew deps --recursive julia) brew install julia.

Appears to be the same problem: $ julia WARNING: Error during initialization of module LinAlg: ErrorException("could not load library "libopenblas" dlopen(libopenblas.dylib, 1): Library not loaded: /usr/local/opt/gcc/lib/gcc/6/libgfortran.3.dylib Referenced from: /usr/local/opt/openblas-julia/lib/libopenblas.dylib Reason: image not found")

WARNING: Error during initialization of module CHOLMOD: ErrorException("could not load library "libcholmod"

dlopen(libcholmod.dylib, 1): Library not loaded: /usr/local/opt/gcc/lib/gcc/6/libgfortran.3.dylib Referenced from: /usr/local/opt/openblas-julia/lib/libopenblasp-r0.2.19.dylib Reason: image not found")

Version 0.5.1 (2017-03-05 13:25 UTC) homebrew-julia release x86_64-apple-darwin16.4.0

gist-logs: brew gist-logs openblas-julia https://gist.github.com/8bfd683023afd72e7c84c502f294d071

brew gist-logs julia https://gist.github.com/109f43b0d2324a1b77c6db902188356d

dpo commented 7 years ago

Sorry, the last command should have been HOMEBREW_BUILD_FROM_SOURCE=1 brew install julia to build from source. I'm not sure there are updated bottles for openblas. Have another try if possible.

prairie-guy commented 7 years ago

duo,

Still no luck. Per your suggestion, I tried: brew uninstall --ignore-dependencies --force $(brew deps --recursive julia) HOMEBREW_BUILD_FROM_SOURCE=1 brew install julia

Here are the dependencies: gmp mpfr gcc libffi staticfloat/julia/llvm37-julia pcre2 fftw openssl libssh2 libgit2 mbedtls staticfloat/julia/openblas-julia staticfloat/julia/arpack-julia staticfloat/julia/suite-sparse-julia

Here are the last 15 lines leading up the to compile error of julia: checking for sendfile in -lsendfile... no checking for socket in -lsocket... no checking for special C compiler options needed for large files... no checking for _FILE_OFFSET_BITS value needed for large files... no checking sys/ahafs_evProds.h usability... no checking sys/ahafs_evProds.h presence... no checking for sys/ahafs_evProds.h... no checking for pkg-config... yes checking that generated files are newer than configure... done configure: creating ./config.status config.status: creating libuv.pc config.status: creating Makefile config.status: executing depfiles commands config.status: executing libtool commands make: *** [julia-deps] Error 2

gist-logs: brew gist-logs julia https://gist.github.com/8a8302dffab1963002cc358d523f0389

Not sure if it is an issue, but I note quite a few warnings as follows: ld: warning: object file (/usr/local/opt/suite-sparse-julia/lib/libumfpack.a(umf_i_analyze.o)) was built for newer OSX version (10.12) than being linked (10.8)

Moreover, every warning is related to: suite-sparse-julia

Thanks again for you help. (I know I can just install julia as a dmg download, but I really like using brew to be my one-stop whenever possible.)

prairie-guy commented 7 years ago

Finally, I am up and running! It's a hack, which I don't understand, except that it works. Perhaps someone can look at this and figure out what I need to do to come up with a better fix.

This works: brew uninstall --ignore-dependencies --force $(brew deps --recursive julia) brew install gcc cd /usr/local/opt/gcc/lib/gcc/ ln -s 7 6 cd 6 ln -s libgfortran.4.dylib libgfortran.3.dylib brew install julia

julia then launches as: Version 0.5.1 (2017-03-05 13:25 UTC)

All tests are passed with: /usr/local/opt/julia/bin/julia -e "Base.runtests()"

Clearly it appears to be a problem with julia or one or more of it's dependencies looking for gcc6 vs gcc7. I would really like to figure out if this is a problem on my side or if this is an issue caused by the brew packages themselves.

In any case, thanks for you help. Any feedback most welcome.

dpo commented 7 years ago

Here, you tricked the Julia bottle into believing that you have gcc 6 installed. I don't have much experience with the Julia build system, so it would be interesting if someone with experience could comment on the build error you reported above. @staticfloat ? @tkelman ?

tkelman commented 7 years ago

I'm increasingly thinking we should deprecate this tap and demote homebrew support to a less recommended way of installing julia the way we've had to do with the ppa and debian packaging, leave keeping things working and maintenance in homebrew to homebrew.

dpo commented 7 years ago

Any idea about the compilation error?

staticfloat commented 7 years ago

Unfortunately I agree with Tony, I clearly don't have time to properly maintain this tap, and rebuilding bottles is an activity that I do not really want to spend more time doing.

Officially, I recommend just brew cask install julia to get a binary version of Julia working on your machine. If you want to have multiple source versions of Julia on your computer, I suggest just doing a normal from-source build, possibly with git-worktree if you want to save a few hundred MB of disk space.

I'm going to add a notice at the top of the README.md saying that I'm not going to continue building bottles for this, but I'm going to keep the repo up in case anyone wants to fork it and continue maintaining the build recipes.

tkelman commented 7 years ago

the specific error here is likely due to the bottles being built against gcc 6, when your system is trying to use gcc 7 for anything new. replacing the existing gcc 6 bottles in place with gcc 7 ones might be visible to base julia's CI or packages' bindeps though, so should be rebuilt carefully.

the main differences here from homebrew-science is using ilp64 blas, right? and possibly some patches or forks of things?

tkelman commented 7 years ago

when this tap was created it was really rare for anything outside of homebrew core to have bottles, but these days homebrew-science uses the homebrew buildbots and has bottles for openblas etc right? usual trouble about fitting julia into a larger distribution set would be what to do about llvm and our many patches.

staticfloat commented 7 years ago

Yes, the main "raison d'être" of this tap was so that we could hold our own patched versions of things like LLVM, OpenBLAS, etc...

This need has lessened as we now have easy access to bottles for things like OpenBLAS. If we want to continue to use the bottles here for Travis Julia builds on OSX, I imagine I will have to update the bottles eventually. Or we could come up with some other way of caching the build dependencies on Travis; doesn't have to be Homebrew-based.

To anyone still trying to get this to work, you may try running brew install staticfloat/juliadeps/libgfortran, that will install a gcc 6 compatible libgfortran on your system, but I really do recommend just using the brew cask install julia method.

tkosaka1976 commented 7 years ago

I'm not favor to use caskroom. It's for application, not for command line tools. Does anyone can support this tap as other languages, r, ruby, python, which can be installed from homebrew usual formula. I hope so.

dpo commented 7 years ago

https://github.com/dpo/homebrew-julia

At least Julia 0.5.2 builds on Sierra with Xcode 8 and homebrew/science dependencies. Currently trying to get Travis builds going. The only remaining touchy dependency is llvm. I'll give Julia 0.6 a go when I get a chance, or anyone should feel free to submit a pull request. If we could somehow get rid of the special llvm dependency, I could eventually submit this to homebrew/science and we would get bottles.

staticfloat commented 7 years ago

You may just try letting Julia build its own llvm as part of the process. Create an llvm resource to download the source tarball and then let Julia unpack , build and patch it during the build process.

On Tue, Jun 20, 2017, 13:06 Dominique notifications@github.com wrote:

https://github.com/dpo/homebrew-julia

At least Julia 0.5.2 builds on Sierra with Xcode 8 and homebrew/science dependencies. Currently trying to get Travis builds going. The only remaining touchy dependency is llvm. I'll give Julia 0.6 a go when I get a chance, or anyone should feel free to submit a pull request. If we could somehow get rid of the special llvm dependency, I could eventually submit this to homebrew/science and we would get bottles.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/staticfloat/homebrew-julia/issues/238#issuecomment-309875842, or mute the thread https://github.com/notifications/unsubscribe-auth/AAH_aFYAr4mYWyDTrcY_iqd1ePHg5JVDks5sGCY0gaJpZM4NQ0SV .

--

-E

dpo commented 7 years ago

Will Julia only accept LLVM 3.7? Homebrew has bottles for later versions.

staticfloat commented 7 years ago

It's not so much the version, it's the patches. Julia applies many patches

tkelman commented 7 years ago

Supported versions are: Julia 0.4 - LLVM 3.3 with patches Julia 0.5 - LLVM 3.7 with patches Julia 0.6 - LLVM 3.9 with patches

Other LLVM-julia version combinations may build, but be sure to run the full Julia test suite.

dpo commented 7 years ago

Great, thanks! I'll have a look. Would it make sense to include those patches that pertain to OSX into the main Homebrew formula for LLVM?

staticfloat commented 7 years ago

I sincerely doubt they would take them; our patches are often used to backport parts of a later LLVM release into an older one.

tkelman commented 7 years ago

Only a handful of our LLVM patches are OS-specific, usually they're fixing Julia-relevant LLVM bugs. But our particular subset of backported LLVM bugfixes isn't necessarily what other LLVM consumers like rust, ghc, etc need or want.

dpo commented 7 years ago

Ok. A few more questions if you don't mind:

staticfloat commented 7 years ago

Always happy to answer questions

is Apple Accelerate still "too old" or has it improved recently as far as Julia is concerned? In Homebrew/science, arpack and suite-sparse are bottled with Accelerate, not with openblas. Where does Accelerate fail for Julia?

I don't know, I haven't kept up with it.

What's the difference between the "full" and "not full" tarballs in the Julia releases?

The "full" tarballs in Julia releases contain all the dependency source tarballs bundled in as well. That will be a slightly wasteful download for you as some of the tarballs bundled in won't be necessary, but that's probably fine as you will need the LLVM tarball if you're going to have Julia build its own tarball as I suggested above.

dpo commented 7 years ago

We won't get bottles from Homebrew if we can't use the bottled versions of arpack and suite-sparse. I wonder what's wrong with Accelerate.

tkelman commented 7 years ago

Accelerate was using a very old lapack version last I checked. We mostly switched to openblas for platform uniformity though. If it passes the julia test suite and works with julia packages the same way as the official binaries you're probably okay, but the more ways the build differs from the upstream recommendation, the less we'll recommend using it.

staticfloat commented 7 years ago

Also the homebrew guys were interested in figuring out how to intelligently have openblas based versions of arpack and suitesparse bottled as well; it may be worthwhile talking with them and thinking through possible ways to do that now that we're all a few years wiser and brew is more capable.

On Tue, Jun 20, 2017, 18:24 Tony Kelman notifications@github.com wrote:

Accelerate was using a very old lapack version last I checked. We mostly switched to openblas for platform uniformity though. If it passes the julia test suite and works with julia packages the same way as the official binaries you're probably okay, but the more ways the build differs from the upstream recommendation, the less we'll recommend using it.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/staticfloat/homebrew-julia/issues/238#issuecomment-309936045, or mute the thread https://github.com/notifications/unsubscribe-auth/AAH_aILnlT8q2_WJP8HbVoND9sohAdhCks5sGHDWgaJpZM4NQ0SV .

--

-E

dpo commented 7 years ago

For the time being, here's a successful source build using OpenBLAS all around: https://travis-ci.org/dpo/homebrew-julia/builds/245190425. I'll give Accelerate a go.

dpo commented 7 years ago

Unfortunately Accelerate is missing important LAPACK functions, including sgeqrt (block QR) and ssytrf_rook (Bunch-Kaufmann). Julia builds but several linalg tests fail. Accelerates still uses LAPACK 3.2.1. (there's 3.7.0 now). Fortunately, all tests pass when building Julia with OpenBLAS even though arpack and suite-sparse use Accelerate. That should be enough to get us bottles.

tkelman commented 7 years ago

It could be an issue to have two different blas/lapack libraries using the same symbol names loaded into the same process at the same time, but I think the darwin shared library loader might be less susceptible to that than linux or windows. Accelerate and openblas use different fortran calling conventions for complex-return functions, which may end up visible. But for now if you haven't triggered any issues, guess you're okay so far.

dpo commented 7 years ago

Using different blas/lapack in a toolchain (unfortunately) happens regularly. I filed a bug report for Apple to include missing functions in Accelerate. We'll see.

tkelman commented 7 years ago

I'm pretty sure @andreasnoack has done the same a while back, I don't think Apple prioritizes development of Accelerate much at all.

dpo commented 7 years ago

The sentence starting with "If you see build failures in OpenBLAS" in the OSX section of the README could probably be deleted because Accelerate is not really an option at this time.

tkelman commented 7 years ago

Yep, since you've tried it recently, a PR to delete that bit would be good by me.

tkelman commented 7 years ago

Oh, though if you use system BLAS but not system LAPACK, Julia will build a newer reference LAPACK so maybe not

dpo commented 7 years ago

Right, though that LAPACK won't have been optimized.

dpo commented 7 years ago

Here's Julia 0.6.0: https://travis-ci.org/dpo/homebrew-julia/builds/245507026. All tests pass on my machine.