Skip to content

Commit

Permalink
Merge pull request #14186 from JuliaLang/tk/backports-0.4.2
Browse files Browse the repository at this point in the history
[release-0.4, RFC] backports for 0.4.2
  • Loading branch information
tkelman committed Dec 6, 2015
2 parents 2092e10 + 652d1de commit 4f951cf
Show file tree
Hide file tree
Showing 87 changed files with 1,903 additions and 946 deletions.
67 changes: 41 additions & 26 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
language: cpp
os:
- linux
- osx
env:
- ARCH="i686"
- ARCH="x86_64"
sudo: false
matrix:
exclude:
- os: osx
include:
- os: linux
env: ARCH="i686"
addons:
apt:
packages:
- binutils:i386
- gcc:i386
- g++:i386
- make:i386
- cpp:i386
- libssl-dev:i386
- gfortran:i386
- os: linux
env: ARCH="x86_64"
addons:
apt:
packages:
- gfortran
- os: osx
env: ARCH="x86_64"
cache:
directories:
- $TRAVIS_BUILD_DIR/deps-i686
- $TRAVIS_BUILD_DIR/deps-x86_64
notifications:
email: false
irc:
Expand All @@ -23,28 +40,17 @@ notifications:
before_install:
- make check-whitespace
- if [ `uname` = "Linux" ]; then
sudo apt-get install jq -y;
contrib/travis_fastfail.sh || exit 1;
BUILDOPTS="-j3 USEGCC=1 LLVM_CONFIG=llvm-config-3.3 VERBOSE=1 USE_BLAS64=0 FORCE_ASSERTIONS=1 STAGE2_DEPS=utf8proc";
for lib in LLVM SUITESPARSE ARPACK BLAS FFTW LAPACK GMP MPFR LIBUNWIND OPENLIBM; do
export BUILDOPTS="$BUILDOPTS USE_SYSTEM_$lib=1";
done;
sudo add-apt-repository ppa:staticfloat/julia-deps -y;
sudo apt-get update -qq -y;
BUILDOPTS="-j3 VERBOSE=1 FORCE_ASSERTIONS=1";
if [ "$ARCH" = "i686" ]; then
export BUILDOPTS="$BUILDOPTS MARCH=pentium4";
sudo apt-get remove libblas3gf liblapack3gf libarmadillo2 -y;
sudo apt-get install binutils:i386 -y;
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;
else
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;
fi;
elif [ `uname` = "Darwin" ]; then
brew tap staticfloat/julia;
brew rm --force $(brew deps --HEAD julia);
brew update;
brew install -v jq;
contrib/travis_fastfail.sh || exit 1;
brew tap staticfloat/julia;
brew rm --force $(brew deps --HEAD julia);
brew install -v --only-dependencies --HEAD julia;
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";
BUILDOPTS="$BUILDOPTS LIBBLAS=-lopenblas LIBBLASNAME=libopenblas LIBLAPACK=-lopenblas LIBLAPACKNAME=libopenblas";
Expand All @@ -55,9 +61,11 @@ before_install:
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";
make $BUILDOPTS -C contrib -f repackage_system_suitesparse4.make;
fi
- git clone -q git://git.kitenet.net/moreutils
script:
- if [ -n "`ls deps-$ARCH`" ]; then cp -a deps-$ARCH/* deps; fi
- make $BUILDOPTS -C base version_git.jl.phony
- git clone -q git://git.kitenet.net/moreutils
- make $BUILDOPTS NO_GIT=1 -C deps > deps.log || cat deps.log
- make $BUILDOPTS NO_GIT=1 JULIA_SYSIMG_BUILD_FLAGS="--output-ji ../usr/lib/julia/sys.ji" prefix=/tmp/julia install | moreutils/ts -s "%.s"
- if [ `uname` = "Darwin" ]; then
for name in suitesparseconfig spqr umfpack colamd cholmod amd suitesparse_wrapper; do
Expand All @@ -68,6 +76,13 @@ script:
- 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
- /tmp/julia/bin/julia -e 'versioninfo()'
- 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
- cd - && mv julia2 julia
- sudo dmesg
- echo "Ready for packaging..."
- cd `dirname $TRAVIS_BUILD_DIR` && mv julia2 julia && rm -f julia/deps/julia-env/src/*/*/*.pyc
- case $TRAVIS_PULL_REQUEST-$TRAVIS_BRANCH in
false-master | false-release*)
cd julia && rm -rf deps-$ARCH && mkdir -p deps-$ARCH &&
for i in $(git ls-files -o --directory deps); do
mv $i deps-$ARCH;
done;;
esac
# uncomment the following if failures are suspected to be due to the out-of-memory killer
# - dmesg
2 changes: 1 addition & 1 deletion Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,7 @@ VERBOSE = 0
endif

WARNCOLOR="\033[33;1m"
ENDCOLOR="\033[0m"

ifeq ($(VERBOSE), 0)

Expand All @@ -946,7 +947,6 @@ JULIACOLOR="\033[32;1m"
SRCCOLOR="\033[33m"
BINCOLOR="\033[37;1m"
JULCOLOR="\033[34;1m"
ENDCOLOR="\033[0m"

GOAL=$(subst ','\'',$(subst $(abspath $(JULIAHOME))/,,$(abspath $@)))
Expand Down
2 changes: 1 addition & 1 deletion README.arm.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ If you run into issues building LLVM, see these notes:
# Raspberry Pi

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

# Raspberry Pi 2
Expand Down
121 changes: 112 additions & 9 deletions base/REPLCompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ end
function complete_keyword(s::ByteString)
const sorted_keywords = [
"abstract", "baremodule", "begin", "bitstype", "break", "catch", "ccall",
"const", "continue", "do", "else", "elseif", "end", "export", "finally",
"for", "function", "global", "if", "immutable", "import", "importall",
"let", "local", "macro", "module", "quote", "return", "try", "type",
"typealias", "using", "while"]
"const", "continue", "do", "else", "elseif", "end", "export", "false",
"finally", "for", "function", "global", "if", "immutable", "import",
"importall", "let", "local", "macro", "module", "quote", "return",
"true", "try", "type", "typealias", "using", "while"]
r = searchsorted(sorted_keywords, s)
i = first(r)
n = length(sorted_keywords)
Expand All @@ -109,7 +109,7 @@ function complete_keyword(s::ByteString)
sorted_keywords[r]
end

function complete_path(path::AbstractString, pos)
function complete_path(path::AbstractString, pos; use_envpath=false)
if Base.is_unix(OS_NAME) && ismatch(r"^~(?:/|$)", path)
# if the path is just "~", don't consider the expanded username as a prefix
if path == "~"
Expand Down Expand Up @@ -141,6 +141,49 @@ function complete_path(path::AbstractString, pos)
push!(matches, id ? file * (@windows? "\\\\" : "/") : file)
end
end

if use_envpath && length(dir) == 0
# Look for files in PATH as well
local pathdirs = split(ENV["PATH"], @unix? ":" : ";")

for pathdir in pathdirs
local actualpath
try
actualpath = realpath(pathdir)
catch
# Bash doesn't expect every folder in PATH to exist, so neither shall we
continue
end

if actualpath != pathdir && in(actualpath,pathdirs)
# Remove paths which (after resolving links) are in the env path twice.
# Many distros eg. point /bin to /usr/bin but have both in the env path.
continue
end

local filesinpath
try
filesinpath = readdir(pathdir)
catch e
# Bash allows dirs in PATH that can't be read, so we should as well.
if isa(e, SystemError)
continue
else
# We only handle SystemErrors here
rethrow(e)
end
end

for file in filesinpath
# In a perfect world, we would filter on whether the file is executable
# here, or even on whether the current user can execute the file in question.
if startswith(file, prefix) && isfile(joinpath(pathdir, file))
push!(matches, file)
end
end
end
end

matches = UTF8String[replace(s, r"\s", "\\ ") for s in matches]
startpos = pos - endof(prefix) + 1 - length(matchall(r" ", prefix))
# The pos - endof(prefix) + 1 is correct due to `endof(prefix)-endof(prefix)==0`,
Expand Down Expand Up @@ -222,14 +265,64 @@ get_value(sym::Symbol, fn) = isdefined(fn, sym) ? (fn.(sym), true) : (nothing, f
get_value(sym::QuoteNode, fn) = isdefined(fn, sym.value) ? (fn.(sym.value), true) : (nothing, false)
get_value(sym, fn) = sym, true

# Return the value of a getfield call expression
function get_value_getfield(ex::Expr, fn)
# Example :((top(getfield))(Base,:max))
val, found = get_value_getfield(ex.args[2],fn) #Look up Base in Main and returns the module
found || return (nothing, false)
get_value_getfield(ex.args[3],val) #Look up max in Base and returns the function if found.
end
get_value_getfield(sym, fn) = get_value(sym, fn)
# Determines the return type with Base.return_types of a function call using the type information of the arguments.
function get_type_call(expr::Expr)
f_name = expr.args[1]
# The if statement should find the f function. How f is found depends on how f is referenced
if isa(f_name, TopNode)
f = Base.(f_name.name)
found = true
elseif isa(f_name, Expr) && f_name.args[1] === TopNode(:getfield)
f, found = get_value_getfield(f_name, Main)
else
f, found = get_value(f_name, Main)
end
found || return (Any, false) # If the function f is not found return Any.
args = Any[]
for ex in expr.args[2:end] # Find the type of the function arguments
typ, found = get_type(ex, Main)
found ? push!(args, typ) : push!(args, Any)
end
return_types = Base.return_types(f,Tuple{args...})
length(return_types) == 1 || return (Any, false)
return (return_types[1], true)
end
# Returns the return type. example: get_type(:(Base.strip("",' ')),Main) returns (ASCIIString,true)
function get_type(sym::Expr, fn)
sym=expand(sym)
val, found = get_value(sym, fn)
found && return Base.typesof(val).parameters[1], found
if sym.head === :call
# getfield call is special cased as the evaluation of getfield provides good type information,
# is inexpensive and it is also performed in the complete_symbol function.
if sym.args[1] === TopNode(:getfield)
val, found = get_value_getfield(sym, Main)
return found ? Base.typesof(val).parameters[1] : Any, found
end
return get_type_call(sym)
end
(Any, false)
end
function get_type(sym, fn)
val, found = get_value(sym, fn)
return found ? Base.typesof(val).parameters[1] : Any, found
end
# Method completion on function call expression that look like :(max(1))
function complete_methods(ex_org::Expr)
args_ex = DataType[]
func, found = get_value(ex_org.args[1], Main)
(!found || (found && !isgeneric(func))) && return UTF8String[]
for ex in ex_org.args[2:end]
val, found = get_value(ex, Main)
found ? push!(args_ex, Base.typesof(val).parameters[1]) : push!(args_ex, Any)
val, found = get_type(ex, Main)
push!(args_ex, val)
end
out = UTF8String[]
t_in = Tuple{args_ex...} # Input types
Expand Down Expand Up @@ -390,8 +483,18 @@ function shell_completions(string, pos)
isempty(args.args[end].args) && return UTF8String[], 0:-1, false
arg = args.args[end].args[end]
if all(s -> isa(s, AbstractString), args.args[end].args)
# Treat this as a path (perhaps give a list of commands in the future as well?)
return complete_path(join(args.args[end].args), pos)
# Treat this as a path

# As Base.shell_parse throws away trailing spaces (unless they are escaped),
# we need to special case here.
# If the last char was a space, but shell_parse ignored it search on "".
ignore_last_word = arg != " " && scs[end] == ' '
prefix = ignore_last_word ? "" : join(args.args[end].args)

# Also try looking into the env path if the user wants to complete the first argument
use_envpath = !ignore_last_word && length(args.args) < 2

return complete_path(prefix, pos, use_envpath=use_envpath)
elseif isexpr(arg, :escape) && (isexpr(arg.args[1], :incomplete) || isexpr(arg.args[1], :error))
r = first(last_parse):prevind(last_parse, last(last_parse))
partial = scs[r]
Expand Down
3 changes: 0 additions & 3 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,6 @@ start(A::AbstractArray) = (@_inline_meta(); itr = eachindex(A); (itr, start(itr)
next(A::AbstractArray,i) = (@_inline_meta(); (idx, s) = next(i[1], i[2]); (A[idx], (i[1], s)))
done(A::AbstractArray,i) = done(i[1], i[2])

iterstate(i) = i
iterstate(i::Tuple{UnitRange{Int},Int}) = i[2]

# eachindex iterates over all indices. LinearSlow definitions are later.
eachindex(A::AbstractArray) = (@_inline_meta(); eachindex(linearindexing(A), A))

Expand Down
36 changes: 18 additions & 18 deletions base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,9 @@ end

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

Expand Down Expand Up @@ -830,36 +830,36 @@ function findmax(a)
if isempty(a)
throw(ArgumentError("collection must be non-empty"))
end
i = start(a)
mi = i
m, i = next(a, i)
while !done(a, i)
iold = i
ai, i = next(a, i)
s = start(a)
mi = i = 1
m, s = next(a, s)
while !done(a, s)
ai, s = next(a, s)
i += 1
if ai > m || m!=m
m = ai
mi = iold
mi = i
end
end
return (m, iterstate(mi))
return (m, mi)
end

function findmin(a)
if isempty(a)
throw(ArgumentError("collection must be non-empty"))
end
i = start(a)
mi = i
m, i = next(a, i)
while !done(a, i)
iold = i
ai, i = next(a, i)
s = start(a)
mi = i = 1
m, s = next(a, s)
while !done(a, s)
ai, s = next(a, s)
i += 1
if ai < m || m!=m
m = ai
mi = iold
mi = i
end
end
return (m, iterstate(mi))
return (m, mi)
end

indmax(a) = findmax(a)[2]
Expand Down
Loading

0 comments on commit 4f951cf

Please sign in to comment.