Skip to content

Commit

Permalink
Merge pull request #47488 from JuliaLang/backports-release-1.8
Browse files Browse the repository at this point in the history
Backports for Julia 1.8.4
  • Loading branch information
KristofferC authored Dec 16, 2022
2 parents 0434deb + 3f58584 commit 3d1e89d
Show file tree
Hide file tree
Showing 52 changed files with 1,315 additions and 724 deletions.
92 changes: 0 additions & 92 deletions .github/workflows/rerun_failed.yml

This file was deleted.

63 changes: 0 additions & 63 deletions .github/workflows/statuses.yml

This file was deleted.

43 changes: 36 additions & 7 deletions Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ JULIA_THREADS := 1
# Set to 1 to enable profiling with OProfile
USE_OPROFILE_JITEVENTS ?= 0

# USE_PERF_JITEVENTS defined below since default is OS specific
# USE_PERF_JITEVENTS, and USE_INTEL_JITEVENTS defined below since default is OS specific

# assume we don't have LIBSSP support in our compiler, will enable later if likely true
HAVE_SSP := 0
Expand Down Expand Up @@ -437,8 +437,10 @@ endif
# Set to 1 to enable profiling with perf
ifeq ("$(OS)", "Linux")
USE_PERF_JITEVENTS ?= 1
USE_INTEL_JITEVENTS ?= 1
else
USE_PERF_JITEVENTS ?= 0
USE_INTEL_JITEVENTS ?= 0
endif

JULIACODEGEN := LLVM
Expand Down Expand Up @@ -1147,6 +1149,29 @@ BB_TRIPLET := $(subst $(SPACE),-,$(filter-out cxx%,$(filter-out libgfortran%,$(s

LIBGFORTRAN_VERSION := $(subst libgfortran,,$(filter libgfortran%,$(subst -,$(SPACE),$(BB_TRIPLET_LIBGFORTRAN))))

# CSL_NEXT_GLIBCXX_VERSION is a triple of the symbols representing support for whatever
# the next libstdc++ version would be. This is used for two things.
# 1. Whether the system libraries are new enough, if we need to use the libs bundled with CSL
# 2. To know which libstdc++ to load at runtime
# We want whichever libstdc++ library is newer, because if we don't it can cause problems.
# While what CSL bundles is quite bleeding-edge compared to what most distros ship, if someone
# tries to build an older branch of Julia, the version of CSL that ships with it may be
# relatively old. This is not a problem for code that is built in BB, but when we build Julia
# with the system compiler, that compiler uses the version of `libstdc++` that it is bundled
# with, and we can get linker errors when trying to run that `julia` executable with the
# `libstdc++` that comes from the (now old) BB-built CSL.
# To fix this, we take note when the system `libstdc++.so` is newer than whatever we
# would get from CSL (by searching for a `GLIBCXX_X.Y.Z` symbol that does not exist
# in our CSL, but would in a newer one), and default to `USE_BINARYBUILDER_CSL=0` in
# this case. This ensures that we link against a version with the symbols required.
# We also check the system libstdc++ at runtime in the cli loader library, and
# load it if it contains the version symbol that indicates that it is newer than the one
# shipped with CSL. Although we do not depend on any of the symbols, it is entirely
# possible that a user might choose to install a library which depends on symbols provided
# by a newer libstdc++. Without runtime detection, those libraries would break.
CSL_NEXT_GLIBCXX_VERSION=GLIBCXX_3\.4\.31|GLIBCXX_3\.5\.|GLIBCXX_4\.


# This is the set of projects that BinaryBuilder dependencies are hooked up for.
# Note: we explicitly _do not_ define `CSL` here, since it requires some more
# advanced techniques to decide whether it should be installed from a BB source
Expand Down Expand Up @@ -1203,18 +1228,16 @@ ifneq (,$(filter $(OS),WINNT emscripten))
RPATH :=
RPATH_ORIGIN :=
RPATH_ESCAPED_ORIGIN :=
RPATH_LIB :=
else ifeq ($(OS), Darwin)
RPATH := -Wl,-rpath,'@executable_path/$(build_libdir_rel)'
RPATH_ORIGIN := -Wl,-rpath,'@loader_path/'
RPATH_ESCAPED_ORIGIN := $(RPATH_ORIGIN)
RPATH_LIB := -Wl,-rpath,'@loader_path/'
else
RPATH := -Wl,-rpath,'$$ORIGIN/$(build_libdir_rel)' -Wl,-rpath,'$$ORIGIN/$(build_private_libdir_rel)' -Wl,-rpath-link,$(build_shlibdir) -Wl,-z,origin
RPATH_ORIGIN := -Wl,-rpath,'$$ORIGIN' -Wl,-z,origin
RPATH_ESCAPED_ORIGIN := -Wl,-rpath,'\$$\$$ORIGIN' -Wl,-z,origin -Wl,-rpath-link,$(build_shlibdir)
RPATH_LIB := -Wl,-rpath,'$$ORIGIN/' -Wl,-z,origin
RPATH := -Wl,-rpath,'$$ORIGIN/$(build_libdir_rel)' -Wl,-rpath,'$$ORIGIN/$(build_private_libdir_rel)' -Wl,-rpath-link,$(build_shlibdir) -Wl,-z,origin -Wl,--enable-new-dtags
RPATH_ORIGIN := -Wl,-rpath,'$$ORIGIN' -Wl,-z,origin -Wl,--enable-new-dtags
RPATH_ESCAPED_ORIGIN := -Wl,-rpath,'\$$\$$ORIGIN' -Wl,-z,origin -Wl,-rpath-link,$(build_shlibdir) -Wl,--enable-new-dtags
endif
RPATH_LIB := $(RPATH_ORIGIN)

# --whole-archive
ifeq ($(OS), Darwin)
Expand Down Expand Up @@ -1469,13 +1492,19 @@ else
LIBGCC_NAME := libgcc_s_seh-1.$(SHLIB_EXT)
endif
endif
# On macOS, libgcc_s has soversion 1.1 always on aarch64 and only for GCC 12+
# (-> libgfortran 5) on x86_64
ifeq ($(OS),Darwin)
ifeq ($(ARCH),aarch64)
LIBGCC_NAME := libgcc_s.1.1.$(SHLIB_EXT)
else
ifeq ($(LIBGFORTRAN_VERSION),5)
LIBGCC_NAME := libgcc_s.1.1.$(SHLIB_EXT)
else
LIBGCC_NAME := libgcc_s.1.$(SHLIB_EXT)
endif
endif
endif
ifneq ($(findstring $(OS),Linux FreeBSD),)
LIBGCC_NAME := libgcc_s.$(SHLIB_EXT).1
endif
Expand Down
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ endif
# Note that we disable MSYS2's path munging here, as otherwise
# it replaces our `:`-separated list as a `;`-separated one.
define stringreplace
MSYS2_ARG_CONV_EXCL='*' $(build_depsbindir)/stringreplace $$(strings -t x - $1 | grep $2 | awk '{print $$1;}') $3 255 "$(call cygpath_w,$1)"
MSYS2_ARG_CONV_EXCL='*' $(build_depsbindir)/stringreplace $$(strings -t x - '$1' | grep "$2" | awk '{print $$1;}') "$3" 255 "$(call cygpath_w,$1)"
endef


Expand Down Expand Up @@ -374,6 +374,16 @@ ifeq ($(BUNDLE_DEBUG_LIBS),1)
endif
endif

# Fix rpaths for dependencies. This should be fixed in BinaryBuilder later.
ifeq ($(OS), Linux)
-$(PATCHELF) --set-rpath '$$ORIGIN' $(DESTDIR)$(private_shlibdir)/libLLVM.$(SHLIB_EXT)
endif

# Replace libstdc++ path, which is also moving from `lib` to `../lib/julia`.
ifeq ($(OS),Linux)
$(call stringreplace,$(DESTDIR)$(shlibdir)/libjulia.$(JL_MAJOR_MINOR_SHLIB_EXT),\*libstdc++\.so\.6$$,*$(call dep_lib_path,$(shlibdir),$(private_shlibdir)/libstdc++.so.6))
endif


ifneq ($(LOADER_BUILD_DEP_LIBS),$(LOADER_INSTALL_DEP_LIBS))
# Next, overwrite relative path to libjulia-internal in our loader if $$(LOADER_BUILD_DEP_LIBS) != $$(LOADER_INSTALL_DEP_LIBS)
Expand Down
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ Deprecated or removed

External dependencies
---------------------

* On Linux, now autodetects the system libstdc++ version, and automatically loads the system library if it is newer. The old behavior of loading the bundled libstdc++ regardless of the system version obtained by setting the environment variable `JULIA_PROBE_LIBSTDCXX=0`.
* Removed `RPATH` from the julia binary. On Linux this may break libraries that have failed to set `RUNPATH`.

Tooling Improvements
---------------------
Expand Down
10 changes: 9 additions & 1 deletion base/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,19 @@ else ifneq ($(USE_SYSTEM_OPENLIBM),0)
$(eval $(call symlink_system_library,OPENLIBM,$(LIBMNAME)))
endif

ifeq ($(APPLE_ARCH),arm64)
# On macOS, libgcc_s has soversion 1.1 always on aarch64 and only for GCC 12+
# (-> libgfortran 5) on x86_64
ifeq ($(OS),Darwin)
ifeq ($(ARCH),aarch64)
$(eval $(call symlink_system_library,CSL,libgcc_s,1.1))
else
ifeq ($(LIBGFORTRAN_VERSION),5)
$(eval $(call symlink_system_library,CSL,libgcc_s,1.1))
else
$(eval $(call symlink_system_library,CSL,libgcc_s,1))
endif
endif
endif
ifneq (,$(LIBGFORTRAN_VERSION))
$(eval $(call symlink_system_library,CSL,libgfortran,$(LIBGFORTRAN_VERSION)))
endif
Expand Down
2 changes: 1 addition & 1 deletion base/file.jl
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ function rm(path::AbstractString; force::Bool=false, recursive::Bool=false)
rm(joinpath(path, p), force=force, recursive=true)
end
catch err
if !(force && isa(err, IOError) && err.code==Base.UV_EACCES)
if !(isa(err, IOError) && err.code==Base.UV_EACCES)
rethrow(err)
end
end
Expand Down
1 change: 1 addition & 0 deletions base/iterators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,7 @@ iterate(::ProductIterator{Tuple{}}, state) = nothing
done1 === true || return done1 # false or missing
return _pisdone(tail(iters), tail(states)) # check tail
end
@inline isdone(::ProductIterator{Tuple{}}, states) = true
@inline isdone(P::ProductIterator, states) = _pisdone(P.iterators, states)

@inline _piterate() = ()
Expand Down
1 change: 1 addition & 0 deletions base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2147,6 +2147,7 @@ end
ftime = mtime(f)
is_stale = ( ftime != ftime_req ) &&
( ftime != floor(ftime_req) ) && # Issue #13606, PR #13613: compensate for Docker images rounding mtimes
( ftime != ceil(ftime_req) ) && # PR: #47433 Compensate for CirceCI's truncating of timestamps in its caching
( ftime != trunc(ftime_req, digits=6) ) && # Issue #20837, PR #20840: compensate for GlusterFS truncating mtimes to microseconds
( ftime != 1.0 ) && # PR #43090: provide compatibility with Nix mtime.
!( 0 < (ftime_req - ftime) < 1e-6 ) # PR #45552: Compensate for Windows tar giving mtimes that may be incorrect by up to one microsecond
Expand Down
14 changes: 13 additions & 1 deletion base/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1155,13 +1155,25 @@ function may_invoke_generator(method::Method, @nospecialize(atype), sparams::Sim
end
end
end
for i = 1:length(at.parameters)
non_va_args = method.isva ? method.nargs - 1 : method.nargs
for i = 1:non_va_args
if !isdispatchelem(at.parameters[i])
if (ast_slotflag(code, 1 + i + nsparams) & SLOT_USED) != 0
return false
end
end
end
if method.isva
# If the va argument is used, we need to ensure that all arguments that
# contribute to the va tuple are dispatchelemes
if (ast_slotflag(code, 1 + method.nargs + nsparams) & SLOT_USED) != 0
for i = (non_va_args+1):length(at.parameters)
if !isdispatchelem(at.parameters[i])
return false
end
end
end
end
return true
end

Expand Down
4 changes: 2 additions & 2 deletions base/sysinfo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export BINDIR,
loadavg,
free_memory,
total_memory,
physical_free_memory,
physical_total_memory,
free_physical_memory,
total_physical_memory,
isapple,
isbsd,
isdragonfly,
Expand Down
6 changes: 4 additions & 2 deletions cli/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ LOADER_LDFLAGS = $(JLDFLAGS) -ffreestanding -L$(build_shlibdir) -L$(build_libdir

ifeq ($(OS),WINNT)
LOADER_CFLAGS += -municode -mconsole -nostdlib -fno-stack-check -fno-stack-protector -mno-stack-arg-probe
else ifeq ($(OS),Linux)
LOADER_CFLAGS += -DGLIBCXX_LEAST_VERSION_SYMBOL=\"$(shell echo "$(CSL_NEXT_GLIBCXX_VERSION)" | cut -d'|' -f1 | sed 's/\\//g')\"
endif

ifeq ($(OS),WINNT)
Expand Down Expand Up @@ -111,7 +113,7 @@ endif

$(build_shlibdir)/libjulia.$(JL_MAJOR_MINOR_SHLIB_EXT): $(LIB_OBJS) $(SRCDIR)/list_strip_symbols.h | $(build_shlibdir) $(build_libdir)
@$(call PRINT_LINK, $(CC) $(call IMPLIB_FLAGS,$@.tmp) $(LOADER_CFLAGS) -DLIBRARY_EXPORTS -shared $(SHIPFLAGS) $(LIB_OBJS) -o $@ \
$(JLIBLDFLAGS) $(LOADER_LDFLAGS) $(RPATH_LIB) $(call SONAME_FLAGS,libjulia.$(JL_MAJOR_SHLIB_EXT)))
$(JLIBLDFLAGS) $(LOADER_LDFLAGS) $(call SONAME_FLAGS,libjulia.$(JL_MAJOR_SHLIB_EXT)))
@$(INSTALL_NAME_CMD)libjulia.$(SHLIB_EXT) $@
ifeq ($(OS), WINNT)
@# Note that if the objcopy command starts getting too long, we can use `@file` to read
Expand All @@ -121,7 +123,7 @@ endif

$(build_shlibdir)/libjulia-debug.$(JL_MAJOR_MINOR_SHLIB_EXT): $(LIB_DOBJS) $(SRCDIR)/list_strip_symbols.h | $(build_shlibdir) $(build_libdir)
@$(call PRINT_LINK, $(CC) $(call IMPLIB_FLAGS,$@.tmp) $(LOADER_CFLAGS) -DLIBRARY_EXPORTS -shared $(DEBUGFLAGS) $(LIB_DOBJS) -o $@ \
$(JLIBLDFLAGS) $(LOADER_LDFLAGS) $(RPATH_LIB) $(call SONAME_FLAGS,libjulia-debug.$(JL_MAJOR_SHLIB_EXT)))
$(JLIBLDFLAGS) $(LOADER_LDFLAGS) $(call SONAME_FLAGS,libjulia-debug.$(JL_MAJOR_SHLIB_EXT)))
@$(INSTALL_NAME_CMD)libjulia-debug.$(SHLIB_EXT) $@
ifeq ($(OS), WINNT)
@$(call PRINT_ANALYZE, $(OBJCOPY) $(build_libdir)/$(notdir $@).tmp.a $(STRIP_EXPORTED_FUNCS) $(build_libdir)/$(notdir $@).a && rm $(build_libdir)/$(notdir $@).tmp.a)
Expand Down
Loading

0 comments on commit 3d1e89d

Please sign in to comment.