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

Run fixup-libgfortran at the make stage #29522

Merged
merged 1 commit into from
Nov 17, 2018

Conversation

staticfloat
Copy link
Member

@staticfloat staticfloat commented Oct 4, 2018

This as opposed to at the make binary-dist stage. This allows from-source Julia builds to have libgfortran, etc... sitting in julia's RPATH, which is important for from-source builds using BinaryBuilder versions of e.g. Arpack.jl to be able to link everything together using RPATH magic.

@andreasnoack this should fix your "this doesn't work if I just make && ./julia" problem.

This as opposed to at the `make binary-dist` stage.  This allows
from-source Julia builds to have `libgfortran`, etc... sitting in
`julia`'s `RPATH`, which is important for from-source builds using
BinaryBuilder versions of e.g. Arpack.jl to be able to link
everything together using `RPATH` magic.
Copy link
Member

@vtjnash vtjnash left a comment

Choose a reason for hiding this comment

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

Can we make this optional? This seems like something we definitely don't want to be doing for actual local builds.

@Keno
Copy link
Member

Keno commented Oct 4, 2018

Can you explain why this is required? Wouldn't opening openblas pull an appropriate libgfortran into the process that Arpack should be able to find?

@staticfloat
Copy link
Member Author

staticfloat commented Oct 4, 2018 via email

@andreasnoack
Copy link
Member

Bump. If people don't like the solution here then please propose an alternative that will make make && ./julia work with binary dependencies which depend on libgfortran.

@ararslan ararslan added the building Build system, or building Julia or its dependencies label Oct 9, 2018
@staticfloat
Copy link
Member Author

I see three solutions here:

  • Move libgfortran and co. into Julia's build libdir, so that it can be found through the RPATH. (That's what this PR does)
  • Change the default dlopen() on all platforms to include RTLD_GLOBAL.
  • Explicitly dlopen("libgfortran", RTLD_GLOBAL) within Julia somewhere before we try to load other dependent libraries.

I think the first choice is the best. What do you guys think?

@vtjnash
Copy link
Member

vtjnash commented Oct 11, 2018

OK. I think I understand better now. Per Keno's PR in 2016 (#17458 (comment)), this was not supposed to work ever (but accidentally was working in installed versions of Julia). But then we re-introduced that code-path in 2017 #21134 incidentally while thinking we were just doing code cleanup.

@staticfloat
Copy link
Member Author

staticfloat commented Oct 11, 2018

Because the lib/julia RPATH is within libjulia and because the dlopen() is initiating from within libjulia, that should be orthogonal though, right? Regardless of what julia has embedded within it, it's what is embedded within libjulia that matters, I would think.

Regardless, I don't think it matters one way or another. We want this behavior, and we need a way to ensure that it works from within the build tree.

@staticfloat
Copy link
Member Author

I'm bumping this again, as we are still getting reports of things not working from users that build from source (hence merging this would help them) and that can't use Arpack.jl despite the effort we've put into GCC multiversioning and all that.

@staticfloat
Copy link
Member Author

Bump; people are still running into this. Please suggest an alternative solution.

@andreasnoack andreasnoack added the triage This should be discussed on a triage call label Nov 7, 2018
@staticfloat
Copy link
Member Author

Please either let me merge this or suggest an alternative solution, I get a steady stream of complaints and bug reports about this.

@Keno
Copy link
Member

Keno commented Nov 11, 2018

Is this a problem on OS X also? I think OS X chains rpaths so if it's within libjulia's rpath we should be able to find it. In any case, I'd be ok with this if instead of copying it, we'd symlink. Longterm, our plan for dealing with libraries spread over the filesystem should be able to deal with this using a virtual "libgfortran" package.

@staticfloat
Copy link
Member Author

Is this a problem on OS X also?

Yes, this is a problem on OS X. You can verify by building a from-source version of Julia on OSX with libgfortran.dylib within a non-default-search path, then running pkg> build Arpack, which fails. On my system, libgfortran.5.dylib is located at /usr/local/opt/gcc/lib/gcc/8/libgfortran.5.dylib, as it's installed through Homebrew.

That is not within libjulia's RPATH; libopenblas64_.dylib has a direct path to that location embedded within it; we don't add system directories to the RPATH of our libraries by default; (I just checked on Linux and OSX) so OSX finds things due to full paths being embedded, Linux finds things because they tend to be on the system path already, and FreeBSD does this early copying already.

I'd be ok with this if instead of copying it, we'd symlink.

I don't see why copying is a problem. If you're worried about staleness in the face of a compiler upgrade, we have many other things that would be stale in that event, and so a make cleanall would already be required. Symlinks would save some disk space, but I'm not convinced the extra complexity required to collapse those symlinks at make binary-dist time is worth it.

Longterm, our plan for dealing with libraries spread over the filesystem should be able to deal with this using a virtual "libgfortran" package.

True, but that's still a little ways off, and I don't see any real downsides to this change.

@StefanKarpinski
Copy link
Member

Triage defers to Elliot "The Linker" Saba on this one.

@StefanKarpinski StefanKarpinski removed the triage This should be discussed on a triage call label Nov 15, 2018
@StefanKarpinski StefanKarpinski added this to the 1.1 milestone Nov 15, 2018
@vtjnash
Copy link
Member

vtjnash commented Nov 15, 2018

and FreeBSD does this early copying already.

That's present to work around a configuration issue with their gcc compiler. I think the idea is that once the real fix makes its way upstream, we can drop that hack?

@StefanKarpinski
Copy link
Member

@staticfloat: please do go ahead with this.

@staticfloat staticfloat merged commit 90e3155 into master Nov 17, 2018
@staticfloat
Copy link
Member Author

Thanks for the vote of confidence, Triage. We'll be able to remove this once JuliaLang/Pkg.jl#841 is brought to fruition.

@martinholters martinholters deleted the sf/the_ultimate_gfortran_conspiracy branch November 17, 2018 19:40
@Keno
Copy link
Member

Keno commented Nov 20, 2018

We now see

PATH=/usr/local/texlive/2018/bin/x86_64-linux:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/keno/julia/usr/tools /home/keno/julia/contrib/fixup-libgfortran.sh --verbose /home/keno/julia/usr/lib
Discovered traces of libgfortran within /home/keno/julia/usr/lib
Got SONAMES of libgcc_s.so.1 libgfortran.so.4 libquadmath.so.0
changing linkage of /home/keno/julia/usr/lib/libopenblas64_.so to libgcc_s.so.1
changing linkage of /home/keno/julia/usr/lib/libopenblas64_.so to libgfortran.so.4
changing linkage of /home/keno/julia/usr/lib/libopenblas64_.so to libquadmath.so.0
changing linkage of /home/keno/julia/usr/lib/libopenblas64_.so.0 to libgcc_s.so.1
changing linkage of /home/keno/julia/usr/lib/libopenblas64_.so.0 to libgfortran.so.4
changing linkage of /home/keno/julia/usr/lib/libopenblas64_.so.0 to libquadmath.so.0
changing linkage of /home/keno/julia/usr/lib/libcholmod.so to libgcc_s.so.1
changing linkage of /home/keno/julia/usr/lib/libcholmod.so to libgfortran.so.4
changing linkage of /home/keno/julia/usr/lib/libcholmod.so to libquadmath.so.0
changing linkage of /home/keno/julia/usr/lib/liblapack* to libgcc_s.so.1
  /home/keno/julia/usr/lib/liblapack* doesn't exist, skipping
changing linkage of /home/keno/julia/usr/lib/liblapack* to libgfortran.so.4
  /home/keno/julia/usr/lib/liblapack* doesn't exist, skipping
changing linkage of /home/keno/julia/usr/lib/liblapack* to libquadmath.so.0
  /home/keno/julia/usr/lib/liblapack* doesn't exist, skipping
changing linkage of /home/keno/julia/usr/lib/libgcc_s.so.1 to libgcc_s.so.1
changing linkage of /home/keno/julia/usr/lib/libgcc_s.so.1 to libgfortran.so.4
changing linkage of /home/keno/julia/usr/lib/libgcc_s.so.1 to libquadmath.so.0
changing linkage of /home/keno/julia/usr/lib/libgfortran.so.4 to libgcc_s.so.1
changing linkage of /home/keno/julia/usr/lib/libgfortran.so.4 to libgfortran.so.4
changing linkage of /home/keno/julia/usr/lib/libgfortran.so.4 to libquadmath.so.0
changing linkage of /home/keno/julia/usr/lib/libquadmath.so.0 to libgcc_s.so.1
changing linkage of /home/keno/julia/usr/lib/libquadmath.so.0 to libgfortran.so.4
changing linkage of /home/keno/julia/usr/lib/libquadmath.so.0 to libquadmath.so.0

on every make. Can we avoid that?

tkf pushed a commit to tkf/julia that referenced this pull request Nov 21, 2018
This as opposed to at the `make binary-dist` stage.  This allows
from-source Julia builds to have `libgfortran`, etc... sitting in
`julia`'s `RPATH`, which is important for from-source builds using
BinaryBuilder versions of e.g. Arpack.jl to be able to link
everything together using `RPATH` magic.
@staticfloat
Copy link
Member Author

#30135

@andreasnoack
Copy link
Member

Can this be backported?

@staticfloat
Copy link
Member Author

Sure, I just opened a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
building Build system, or building Julia or its dependencies
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants