Skip to content

Commit 4f951cf

Browse files
committed
Merge pull request #14186 from JuliaLang/tk/backports-0.4.2
[release-0.4, RFC] backports for 0.4.2
2 parents 2092e10 + 652d1de commit 4f951cf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+1903
-946
lines changed

.travis.yml

Lines changed: 41 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,31 @@
11
language: cpp
2-
os:
3-
- linux
4-
- osx
5-
env:
6-
- ARCH="i686"
7-
- ARCH="x86_64"
2+
sudo: false
83
matrix:
9-
exclude:
10-
- os: osx
4+
include:
5+
- os: linux
116
env: ARCH="i686"
7+
addons:
8+
apt:
9+
packages:
10+
- binutils:i386
11+
- gcc:i386
12+
- g++:i386
13+
- make:i386
14+
- cpp:i386
15+
- libssl-dev:i386
16+
- gfortran:i386
17+
- os: linux
18+
env: ARCH="x86_64"
19+
addons:
20+
apt:
21+
packages:
22+
- gfortran
23+
- os: osx
24+
env: ARCH="x86_64"
25+
cache:
26+
directories:
27+
- $TRAVIS_BUILD_DIR/deps-i686
28+
- $TRAVIS_BUILD_DIR/deps-x86_64
1229
notifications:
1330
email: false
1431
irc:
@@ -23,28 +40,17 @@ notifications:
2340
before_install:
2441
- make check-whitespace
2542
- if [ `uname` = "Linux" ]; then
26-
sudo apt-get install jq -y;
2743
contrib/travis_fastfail.sh || exit 1;
28-
BUILDOPTS="-j3 USEGCC=1 LLVM_CONFIG=llvm-config-3.3 VERBOSE=1 USE_BLAS64=0 FORCE_ASSERTIONS=1 STAGE2_DEPS=utf8proc";
29-
for lib in LLVM SUITESPARSE ARPACK BLAS FFTW LAPACK GMP MPFR LIBUNWIND OPENLIBM; do
30-
export BUILDOPTS="$BUILDOPTS USE_SYSTEM_$lib=1";
31-
done;
32-
sudo add-apt-repository ppa:staticfloat/julia-deps -y;
33-
sudo apt-get update -qq -y;
44+
BUILDOPTS="-j3 VERBOSE=1 FORCE_ASSERTIONS=1";
3445
if [ "$ARCH" = "i686" ]; then
3546
export BUILDOPTS="$BUILDOPTS MARCH=pentium4";
36-
sudo apt-get remove libblas3gf liblapack3gf libarmadillo2 -y;
37-
sudo apt-get install binutils:i386 -y;
38-
sudo apt-get install gcc:i386 g++:i386 make:i386 cpp:i386 g++-4.6:i386 gcc-4.6:i386 libssl-dev:i386 patchelf:i386 gfortran:i386 llvm-3.3-dev:i386 libsuitesparse-dev:i386 libopenblas-dev:i386 libopenblas-base:i386 libblas-dev:i386 liblapack-dev:i386 liblapack3:i386 libarpack2-dev:i386 libarpack2:i386 libfftw3-dev:i386 libgmp-dev:i386 libpcre3-dev:i386 libunwind7-dev:i386 libopenlibm-dev:i386 libmpfr-dev:i386 -y;
39-
else
40-
sudo apt-get install patchelf gfortran llvm-3.3-dev libsuitesparse-dev libopenblas-dev liblapack-dev libarpack2-dev libfftw3-dev libgmp-dev libpcre3-dev libunwind7-dev libopenlibm-dev libmpfr-dev -y;
4147
fi;
4248
elif [ `uname` = "Darwin" ]; then
43-
brew tap staticfloat/julia;
44-
brew rm --force $(brew deps --HEAD julia);
4549
brew update;
4650
brew install -v jq;
4751
contrib/travis_fastfail.sh || exit 1;
52+
brew tap staticfloat/julia;
53+
brew rm --force $(brew deps --HEAD julia);
4854
brew install -v --only-dependencies --HEAD julia;
4955
BUILDOPTS="-j3 USECLANG=1 LLVM_CONFIG=$(brew --prefix llvm33-julia)/bin/llvm-config-3.3 VERBOSE=1 USE_BLAS64=0 SUITESPARSE_INC=-I$(brew --prefix suite-sparse-julia)/include FORCE_ASSERTIONS=1 STAGE2_DEPS=utf8proc";
5056
BUILDOPTS="$BUILDOPTS LIBBLAS=-lopenblas LIBBLASNAME=libopenblas LIBLAPACK=-lopenblas LIBLAPACKNAME=libopenblas";
@@ -55,9 +61,11 @@ before_install:
5561
export DYLD_FALLBACK_LIBRARY_PATH="/usr/local/lib:/lib:/usr/lib:$(brew --prefix openblas-julia)/lib:$(brew --prefix suite-sparse-julia)/lib:$(brew --prefix arpack-julia)/lib";
5662
make $BUILDOPTS -C contrib -f repackage_system_suitesparse4.make;
5763
fi
64+
- git clone -q git://git.kitenet.net/moreutils
5865
script:
66+
- if [ -n "`ls deps-$ARCH`" ]; then cp -a deps-$ARCH/* deps; fi
5967
- make $BUILDOPTS -C base version_git.jl.phony
60-
- git clone -q git://git.kitenet.net/moreutils
68+
- make $BUILDOPTS NO_GIT=1 -C deps > deps.log || cat deps.log
6169
- make $BUILDOPTS NO_GIT=1 JULIA_SYSIMG_BUILD_FLAGS="--output-ji ../usr/lib/julia/sys.ji" prefix=/tmp/julia install | moreutils/ts -s "%.s"
6270
- if [ `uname` = "Darwin" ]; then
6371
for name in suitesparseconfig spqr umfpack colamd cholmod amd suitesparse_wrapper; do
@@ -68,6 +76,13 @@ script:
6876
- cp /tmp/julia/lib/julia/sys.ji local.ji && /tmp/julia/bin/julia -J local.ji -e 'true' && /tmp/julia/bin/julia-debug -J local.ji -e 'true' && rm local.ji
6977
- /tmp/julia/bin/julia -e 'versioninfo()'
7078
- export JULIA_CPU_CORES=2 && cd /tmp/julia/share/julia/test && /tmp/julia/bin/julia --check-bounds=yes runtests.jl all && /tmp/julia/bin/julia --check-bounds=yes runtests.jl pkg
71-
- cd - && mv julia2 julia
72-
- sudo dmesg
73-
- echo "Ready for packaging..."
79+
- cd `dirname $TRAVIS_BUILD_DIR` && mv julia2 julia && rm -f julia/deps/julia-env/src/*/*/*.pyc
80+
- case $TRAVIS_PULL_REQUEST-$TRAVIS_BRANCH in
81+
false-master | false-release*)
82+
cd julia && rm -rf deps-$ARCH && mkdir -p deps-$ARCH &&
83+
for i in $(git ls-files -o --directory deps); do
84+
mv $i deps-$ARCH;
85+
done;;
86+
esac
87+
# uncomment the following if failures are suspected to be due to the out-of-memory killer
88+
# - dmesg

Make.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -932,6 +932,7 @@ VERBOSE = 0
932932
endif
933933

934934
WARNCOLOR="\033[33;1m"
935+
ENDCOLOR="\033[0m"
935936

936937
ifeq ($(VERBOSE), 0)
937938

@@ -946,7 +947,6 @@ JULIACOLOR="\033[32;1m"
946947
SRCCOLOR="\033[33m"
947948
BINCOLOR="\033[37;1m"
948949
JULCOLOR="\033[34;1m"
949-
ENDCOLOR="\033[0m"
950950

951951
GOAL=$(subst ','\'',$(subst $(abspath $(JULIAHOME))/,,$(abspath $@)))
952952

README.arm.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ If you run into issues building LLVM, see these notes:
5050
# Raspberry Pi
5151

5252
The Raspberry Pi ARM CPU type is not detected by LLVM.
53-
Before starting the build, it is recommended to do `export JULIA_CPU_ARCH=arm1176jzf-s`
53+
Before starting the build, it is recommended to do `export JULIA_CPU_TARGET=arm1176jzf-s`
5454
at the shell to tune the generated code for your CPU architecture.
5555

5656
# Raspberry Pi 2

base/REPLCompletions.jl

Lines changed: 112 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,10 @@ end
9595
function complete_keyword(s::ByteString)
9696
const sorted_keywords = [
9797
"abstract", "baremodule", "begin", "bitstype", "break", "catch", "ccall",
98-
"const", "continue", "do", "else", "elseif", "end", "export", "finally",
99-
"for", "function", "global", "if", "immutable", "import", "importall",
100-
"let", "local", "macro", "module", "quote", "return", "try", "type",
101-
"typealias", "using", "while"]
98+
"const", "continue", "do", "else", "elseif", "end", "export", "false",
99+
"finally", "for", "function", "global", "if", "immutable", "import",
100+
"importall", "let", "local", "macro", "module", "quote", "return",
101+
"true", "try", "type", "typealias", "using", "while"]
102102
r = searchsorted(sorted_keywords, s)
103103
i = first(r)
104104
n = length(sorted_keywords)
@@ -109,7 +109,7 @@ function complete_keyword(s::ByteString)
109109
sorted_keywords[r]
110110
end
111111

112-
function complete_path(path::AbstractString, pos)
112+
function complete_path(path::AbstractString, pos; use_envpath=false)
113113
if Base.is_unix(OS_NAME) && ismatch(r"^~(?:/|$)", path)
114114
# if the path is just "~", don't consider the expanded username as a prefix
115115
if path == "~"
@@ -141,6 +141,49 @@ function complete_path(path::AbstractString, pos)
141141
push!(matches, id ? file * (@windows? "\\\\" : "/") : file)
142142
end
143143
end
144+
145+
if use_envpath && length(dir) == 0
146+
# Look for files in PATH as well
147+
local pathdirs = split(ENV["PATH"], @unix? ":" : ";")
148+
149+
for pathdir in pathdirs
150+
local actualpath
151+
try
152+
actualpath = realpath(pathdir)
153+
catch
154+
# Bash doesn't expect every folder in PATH to exist, so neither shall we
155+
continue
156+
end
157+
158+
if actualpath != pathdir && in(actualpath,pathdirs)
159+
# Remove paths which (after resolving links) are in the env path twice.
160+
# Many distros eg. point /bin to /usr/bin but have both in the env path.
161+
continue
162+
end
163+
164+
local filesinpath
165+
try
166+
filesinpath = readdir(pathdir)
167+
catch e
168+
# Bash allows dirs in PATH that can't be read, so we should as well.
169+
if isa(e, SystemError)
170+
continue
171+
else
172+
# We only handle SystemErrors here
173+
rethrow(e)
174+
end
175+
end
176+
177+
for file in filesinpath
178+
# In a perfect world, we would filter on whether the file is executable
179+
# here, or even on whether the current user can execute the file in question.
180+
if startswith(file, prefix) && isfile(joinpath(pathdir, file))
181+
push!(matches, file)
182+
end
183+
end
184+
end
185+
end
186+
144187
matches = UTF8String[replace(s, r"\s", "\\ ") for s in matches]
145188
startpos = pos - endof(prefix) + 1 - length(matchall(r" ", prefix))
146189
# The pos - endof(prefix) + 1 is correct due to `endof(prefix)-endof(prefix)==0`,
@@ -222,14 +265,64 @@ get_value(sym::Symbol, fn) = isdefined(fn, sym) ? (fn.(sym), true) : (nothing, f
222265
get_value(sym::QuoteNode, fn) = isdefined(fn, sym.value) ? (fn.(sym.value), true) : (nothing, false)
223266
get_value(sym, fn) = sym, true
224267

268+
# Return the value of a getfield call expression
269+
function get_value_getfield(ex::Expr, fn)
270+
# Example :((top(getfield))(Base,:max))
271+
val, found = get_value_getfield(ex.args[2],fn) #Look up Base in Main and returns the module
272+
found || return (nothing, false)
273+
get_value_getfield(ex.args[3],val) #Look up max in Base and returns the function if found.
274+
end
275+
get_value_getfield(sym, fn) = get_value(sym, fn)
276+
# Determines the return type with Base.return_types of a function call using the type information of the arguments.
277+
function get_type_call(expr::Expr)
278+
f_name = expr.args[1]
279+
# The if statement should find the f function. How f is found depends on how f is referenced
280+
if isa(f_name, TopNode)
281+
f = Base.(f_name.name)
282+
found = true
283+
elseif isa(f_name, Expr) && f_name.args[1] === TopNode(:getfield)
284+
f, found = get_value_getfield(f_name, Main)
285+
else
286+
f, found = get_value(f_name, Main)
287+
end
288+
found || return (Any, false) # If the function f is not found return Any.
289+
args = Any[]
290+
for ex in expr.args[2:end] # Find the type of the function arguments
291+
typ, found = get_type(ex, Main)
292+
found ? push!(args, typ) : push!(args, Any)
293+
end
294+
return_types = Base.return_types(f,Tuple{args...})
295+
length(return_types) == 1 || return (Any, false)
296+
return (return_types[1], true)
297+
end
298+
# Returns the return type. example: get_type(:(Base.strip("",' ')),Main) returns (ASCIIString,true)
299+
function get_type(sym::Expr, fn)
300+
sym=expand(sym)
301+
val, found = get_value(sym, fn)
302+
found && return Base.typesof(val).parameters[1], found
303+
if sym.head === :call
304+
# getfield call is special cased as the evaluation of getfield provides good type information,
305+
# is inexpensive and it is also performed in the complete_symbol function.
306+
if sym.args[1] === TopNode(:getfield)
307+
val, found = get_value_getfield(sym, Main)
308+
return found ? Base.typesof(val).parameters[1] : Any, found
309+
end
310+
return get_type_call(sym)
311+
end
312+
(Any, false)
313+
end
314+
function get_type(sym, fn)
315+
val, found = get_value(sym, fn)
316+
return found ? Base.typesof(val).parameters[1] : Any, found
317+
end
225318
# Method completion on function call expression that look like :(max(1))
226319
function complete_methods(ex_org::Expr)
227320
args_ex = DataType[]
228321
func, found = get_value(ex_org.args[1], Main)
229322
(!found || (found && !isgeneric(func))) && return UTF8String[]
230323
for ex in ex_org.args[2:end]
231-
val, found = get_value(ex, Main)
232-
found ? push!(args_ex, Base.typesof(val).parameters[1]) : push!(args_ex, Any)
324+
val, found = get_type(ex, Main)
325+
push!(args_ex, val)
233326
end
234327
out = UTF8String[]
235328
t_in = Tuple{args_ex...} # Input types
@@ -390,8 +483,18 @@ function shell_completions(string, pos)
390483
isempty(args.args[end].args) && return UTF8String[], 0:-1, false
391484
arg = args.args[end].args[end]
392485
if all(s -> isa(s, AbstractString), args.args[end].args)
393-
# Treat this as a path (perhaps give a list of commands in the future as well?)
394-
return complete_path(join(args.args[end].args), pos)
486+
# Treat this as a path
487+
488+
# As Base.shell_parse throws away trailing spaces (unless they are escaped),
489+
# we need to special case here.
490+
# If the last char was a space, but shell_parse ignored it search on "".
491+
ignore_last_word = arg != " " && scs[end] == ' '
492+
prefix = ignore_last_word ? "" : join(args.args[end].args)
493+
494+
# Also try looking into the env path if the user wants to complete the first argument
495+
use_envpath = !ignore_last_word && length(args.args) < 2
496+
497+
return complete_path(prefix, pos, use_envpath=use_envpath)
395498
elseif isexpr(arg, :escape) && (isexpr(arg.args[1], :incomplete) || isexpr(arg.args[1], :error))
396499
r = first(last_parse):prevind(last_parse, last(last_parse))
397500
partial = scs[r]

base/abstractarray.jl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -408,9 +408,6 @@ start(A::AbstractArray) = (@_inline_meta(); itr = eachindex(A); (itr, start(itr)
408408
next(A::AbstractArray,i) = (@_inline_meta(); (idx, s) = next(i[1], i[2]); (A[idx], (i[1], s)))
409409
done(A::AbstractArray,i) = done(i[1], i[2])
410410

411-
iterstate(i) = i
412-
iterstate(i::Tuple{UnitRange{Int},Int}) = i[2]
413-
414411
# eachindex iterates over all indices. LinearSlow definitions are later.
415412
eachindex(A::AbstractArray) = (@_inline_meta(); eachindex(linearindexing(A), A))
416413

base/array.jl

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -429,9 +429,9 @@ end
429429

430430
function push!{T}(a::Array{T,1}, item)
431431
# convert first so we don't grow the array if the assignment won't work
432-
item = convert(T, item)
432+
itemT = convert(T, item)
433433
ccall(:jl_array_grow_end, Void, (Any, UInt), a, 1)
434-
a[end] = item
434+
a[end] = itemT
435435
return a
436436
end
437437

@@ -830,36 +830,36 @@ function findmax(a)
830830
if isempty(a)
831831
throw(ArgumentError("collection must be non-empty"))
832832
end
833-
i = start(a)
834-
mi = i
835-
m, i = next(a, i)
836-
while !done(a, i)
837-
iold = i
838-
ai, i = next(a, i)
833+
s = start(a)
834+
mi = i = 1
835+
m, s = next(a, s)
836+
while !done(a, s)
837+
ai, s = next(a, s)
838+
i += 1
839839
if ai > m || m!=m
840840
m = ai
841-
mi = iold
841+
mi = i
842842
end
843843
end
844-
return (m, iterstate(mi))
844+
return (m, mi)
845845
end
846846

847847
function findmin(a)
848848
if isempty(a)
849849
throw(ArgumentError("collection must be non-empty"))
850850
end
851-
i = start(a)
852-
mi = i
853-
m, i = next(a, i)
854-
while !done(a, i)
855-
iold = i
856-
ai, i = next(a, i)
851+
s = start(a)
852+
mi = i = 1
853+
m, s = next(a, s)
854+
while !done(a, s)
855+
ai, s = next(a, s)
856+
i += 1
857857
if ai < m || m!=m
858858
m = ai
859-
mi = iold
859+
mi = i
860860
end
861861
end
862-
return (m, iterstate(mi))
862+
return (m, mi)
863863
end
864864

865865
indmax(a) = findmax(a)[2]

0 commit comments

Comments
 (0)