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

Backports for 0.6.4 #27621

Merged
merged 12 commits into from
Jul 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -539,10 +539,10 @@ endif
# Allow the user to specify this in Make.user
GCCPATH ?= $(LOCALBASE)/lib/gcc$(_GCCVER)

LDFLAGS += -L$(build_libdir) -L$(GCCPATH) -Wl,-rpath,$(build_libdir) -Wl,-rpath,$(GCCPATH)

# This ensures we get the right RPATH even if we're missing FFLAGS somewhere
FC += -Wl,-rpath=$(GCCPATH)
# We're going to copy over the libraries we need from GCCPATH into build_libdir, then
# tell everyone to look for them there. At install time, the build_libdir added into
# the RPATH here is removed by patchelf.
LDFLAGS += -L$(build_libdir) -Wl,-rpath,$(build_libdir)

endif # gfortran
endif # FreeBSD
Expand Down Expand Up @@ -934,6 +934,9 @@ else ifeq ($(OS), Darwin)
RPATH_LIB := -Wl,-rpath,'@loader_path/julia/' -Wl,-rpath,'@loader_path/'
else
RPATH := -Wl,-rpath,'$$ORIGIN/$(build_libdir_rel)' -Wl,-rpath-link,$(build_shlibdir) -Wl,-z,origin
ifeq ($(OS), FreeBSD)
RPATH += -Wl,-rpath,'$$ORIGIN/$(build_private_libdir_rel)'
endif
RPATH_ORIGIN := -Wl,-rpath,'$$ORIGIN' -Wl,-z,origin
RPATH_ESCAPED_ORIGIN := -Wl,-rpath,'\$$\$$ORIGIN' -Wl,-z,origin
RPATH_LIB := -Wl,-rpath,'$$ORIGIN/julia' -Wl,-rpath,'$$ORIGIN' -Wl,-z,origin
Expand Down
38 changes: 37 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,24 @@ endif
endif
endif

# On FreeBSD, /lib/libgcc_s.so.1 is incompatible with Fortran; to use Fortran on FreeBSD,
# we need to link to the libgcc_s that ships with the same GCC version used by libgfortran.
# To work around this, we copy the GCC libraries we need, namely libgfortran, libgcc_s,
# and libquadmath, into our build library directory, $(build_libdir). We also add them to
# JL_PRIVATE_LIBS so that they know where they need to live at install time.
ifeq ($(OS),FreeBSD)
define std_so
julia-deps: | $$(build_libdir)/$(1).so
$$(build_libdir)/$(1).so: | $$(build_libdir)
$$(INSTALL_M) $$(GCCPATH)/$(1).so* $$(build_libdir)
JL_PRIVATE_LIBS += $(1)
endef

$(eval $(call std_so,libgfortran))
$(eval $(call std_so,libgcc_s))
$(eval $(call std_so,libquadmath))
endif # FreeBSD

ifeq ($(OS),WINNT)
define std_dll
julia-deps: | $$(build_bindir)/lib$(1).dll $$(build_depsbindir)/lib$(1).dll
Expand Down Expand Up @@ -417,6 +435,20 @@ endif
$(call stringreplace,$(DESTDIR)$(libdir)/libjulia-debug.$(SHLIB_EXT),sys-debug.$(SHLIB_EXT)$$,$(private_libdir_rel)/sys-debug.$(SHLIB_EXT))
endif

# On FreeBSD, remove the build's libdir from each library's RPATH
ifeq ($(OS),FreeBSD)
$(JULIAHOME)/contrib/fixup-rpath.sh $(build_depsbindir)/patchelf $(DESTDIR)$(libdir) $(build_libdir)
$(JULIAHOME)/contrib/fixup-rpath.sh $(build_depsbindir)/patchelf $(DESTDIR)$(private_libdir) $(build_libdir)
$(JULIAHOME)/contrib/fixup-rpath.sh $(build_depsbindir)/patchelf $(DESTDIR)$(bindir) $(build_libdir)
# Set libgfortran's RPATH to ORIGIN instead of GCCPATH. It's only libgfortran that
# needs to be fixed here, as libgcc_s and libquadmath don't have RPATHs set. If we
# don't set libgfortran's RPATH, it won't be able to find its friends on systems
# that don't have the exact GCC port installed used for the build.
for lib in $(DESTDIR)$(private_libdir)/libgfortran*$(SHLIB_EXT)*; do \
$(build_depsbindir)/patchelf --set-rpath '$$ORIGIN' $$lib; \
done
endif

mkdir -p $(DESTDIR)$(sysconfdir)
cp -R $(build_sysconfdir)/julia $(DESTDIR)$(sysconfdir)/

Expand All @@ -443,7 +475,11 @@ ifneq ($(DESTDIR),)
endif
@$(MAKE) -C $(BUILDROOT) -f $(JULIAHOME)/Makefile install
cp $(JULIAHOME)/LICENSE.md $(BUILDROOT)/julia-$(JULIA_COMMIT)
ifneq ($(OS), WINNT)
# Run fixup-libgfortran on all platforms but Windows and FreeBSD. On FreeBSD we
# pull in the GCC libraries earlier and use them for the build to make sure we
# don't inadvertently link to /lib/libgcc_s.so.1, which is incompatible with
# libgfortran.
ifeq (,$(findstring $(OS),FreeBSD WINNT))
-$(CUSTOM_LD_LIBRARY_PATH) PATH=$(PATH):$(build_depsbindir) $(JULIAHOME)/contrib/fixup-libgfortran.sh $(DESTDIR)$(private_libdir)
endif
ifeq ($(OS), Linux)
Expand Down
6 changes: 3 additions & 3 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1129,10 +1129,10 @@ function typed_hcat(::Type{T}, A::AbstractVecOrMat...) where T
return B
end

vcat(A::AbstractVecOrMat...) = typed_vcat(promote_eltype(A...), A...)
vcat(A::AbstractVecOrMat{T}...) where {T} = typed_vcat(T, A...)
vcat(A::AbstractMatrix...) = typed_vcat(promote_eltype(A...), A...)
vcat(A::AbstractMatrix{T}...) where {T} = typed_vcat(T, A...)

function typed_vcat(::Type{T}, A::AbstractVecOrMat...) where T
function typed_vcat(::Type{T}, A::AbstractMatrix...) where T
nargs = length(A)
nrows = sum(a->size(a, 1), A)::Int
ncols = size(A[1], 2)
Expand Down
43 changes: 31 additions & 12 deletions base/linalg/bidiag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -543,20 +543,39 @@ function naivesub!(A::Bidiagonal{T}, b::AbstractVector, x::AbstractVector = b) w
if N != length(b) || N != length(x)
throw(DimensionMismatch("second dimension of A, $N, does not match one of the lengths of x, $(length(x)), or b, $(length(b))"))
end
if !A.isupper #do forward substitution
for j = 1:N
x[j] = b[j]
j > 1 && (x[j] -= A.ev[j-1] * x[j-1])
x[j] /= A.dv[j] == zero(T) ? throw(SingularException(j)) : A.dv[j]
end
else #do backward substitution
for j = N:-1:1
x[j] = b[j]
j < N && (x[j] -= A.ev[j] * x[j+1])
x[j] /= A.dv[j] == zero(T) ? throw(SingularException(j)) : A.dv[j]

if N == 0
return x
end

@inbounds begin
if !A.isupper #do forward substitution
x[1] = xj1 = A.dv[1]\b[1]
for j = 2:N
xj = b[j]
xj -= A.ev[j - 1] * xj1
dvj = A.dv[j]
if iszero(dvj)
throw(SingularException(j))
end
xj = dvj\xj
x[j] = xj1 = xj
end
else #do backward substitution
x[N] = xj1 = A.dv[N]\b[N]
for j = (N - 1):-1:1
xj = b[j]
xj -= A.ev[j] * xj1
dvj = A.dv[j]
if iszero(dvj)
throw(SingularException(j))
end
xj = dvj\xj
x[j] = xj1 = xj
end
end
end
x
return x
end

### Generic promotion methods and fallbacks
Expand Down
19 changes: 17 additions & 2 deletions base/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,29 @@ cbrt(x::AbstractFloat) = x < 0 ? -(-x)^(1//3) : x^(1//3)
"""
exp2(x)

Compute ``2^x``.
Compute the base 2 exponential of `x`, in other words ``2^x``.

# Examples
```jldoctest
julia> exp2(5)
32.0
```
"""
exp2(x::AbstractFloat) = 2^x

"""
exp10(x)

Compute the base 10 exponential of `x`, in other words ``10^x``.

# Examples
```jldoctest
julia> exp10(2)
100.0
```
"""
exp10(x::AbstractFloat) = 10^x

for f in (:sinh, :cosh, :tanh, :atan, :asinh, :exp, :expm1)
@eval ($f)(x::AbstractFloat) = error("not implemented for ", typeof(x))
end
Expand Down Expand Up @@ -945,7 +960,7 @@ muladd(x,y,z) = x*y+z
# Float16 definitions

for func in (:sin,:cos,:tan,:asin,:acos,:atan,:sinh,:cosh,:tanh,:asinh,:acosh,
:atanh,:exp,:log,:log2,:log10,:sqrt,:lgamma,:log1p)
:atanh,:exp,:exp2,:exp10,:log,:log2,:log10,:sqrt,:lgamma,:log1p)
@eval begin
$func(a::Float16) = Float16($func(Float32(a)))
$func(a::Complex32) = Complex32($func(Complex64(a)))
Expand Down
32 changes: 32 additions & 0 deletions contrib/fixup-rpath.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/sh
# Usage: fixup-rpath.sh <patchelf path> <dir to process> <build libdir>

if [ $# -ne 3 ]; then
echo "Incorrect number of arguments: Expected 3, got $#"
echo "Usage: fixup-rpath.sh <patchelf path> <directory to process> <build libdir>"
exit 1
fi

patchelf="$1"
executable_dir="$2"
build_libdir="$3"

for lib in $(find ${executable_dir} -type f -perm -111); do
# First get the current RPATH
rpath="$(${patchelf} --print-rpath ${lib})"

# If it doesn't contain the build's libdir, we don't care about it
if [ -z "$(echo ${rpath} | grep -F ${build_libdir})" ]; then
continue
fi

# Remove build_libdir from the RPATH, retaining the rest
new_rpath="$(echo ${rpath} | tr : \\n | grep -vF ${build_libdir} | tr \\n :)"
# Drop the trailing :
new_rpath="${new_rpath%?}"

echo " Setting RPATH for ${lib} to '${new_rpath}'"

# Now set the new RPATH
${patchelf} --set-rpath "${new_rpath}" ${lib}
done
1 change: 1 addition & 0 deletions deps/blas.mk
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ endif

OPENBLAS_BUILD_OPTS += CFLAGS="$(CFLAGS) $(OPENBLAS_CFLAGS)"
OPENBLAS_BUILD_OPTS += FFLAGS="$(FFLAGS) $(OPENBLAS_FFLAGS)"
OPENBLAS_BUILD_OPTS += LDFLAGS="$(LDFLAGS) $(RPATH_ESCAPED_ORIGIN)"

# Debug OpenBLAS
ifeq ($(OPENBLAS_DEBUG), 1)
Expand Down
2 changes: 2 additions & 0 deletions deps/tools/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ ifeq ($(OS),WINNT)
ifneq ($(USEMSVC), 1)
CONFIGURE_COMMON += LDFLAGS="$(LDFLAGS) -Wl,--stack,8388608"
endif
else
CONFIGURE_COMMON += LDFLAGS="$(LDFLAGS) $(RPATH_ESCAPED_ORIGIN)"
endif
CONFIGURE_COMMON += F77="$(FC)" CC="$(CC) $(DEPS_CFLAGS)" CXX="$(CXX) $(DEPS_CXXFLAGS)"

Expand Down
3 changes: 2 additions & 1 deletion src/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -2003,7 +2003,8 @@ static void jl_deserialize_struct(jl_serializer_state *s, jl_value_t *v, size_t
}
else {
// garbage entry - delete it :(
((jl_typemap_entry_t*)v)->min_world = ((jl_typemap_entry_t*)v)->max_world - 1;
((jl_typemap_entry_t*)v)->min_world = 1;
((jl_typemap_entry_t*)v)->max_world = 0;
}
}
}
Expand Down
Loading