Skip to content

Commit

Permalink
Merge branch 'master' of github.com:JuliaLang/julia
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Jun 28, 2014
2 parents 4f006e1 + 70b6680 commit a4ba5e5
Show file tree
Hide file tree
Showing 25 changed files with 391 additions and 122 deletions.
60 changes: 44 additions & 16 deletions Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ USE_INTEL_JITEVENTS = 0
# libc++ is standard on OS X 10.9, but not for earlier releases
USE_LIBCPP = 0

# Select the cpu architecture to target
# Current available options are "native", "core2" and "i386"
JULIA_CPU_TARGET = native

# we include twice to pickup user definitions better
ifeq (exists, $(shell [ -e $(JULIAHOME)/Make.user ] && echo exists ))
include $(JULIAHOME)/Make.user
Expand Down Expand Up @@ -266,16 +262,6 @@ LD := link
endif
RANLIB := $(CROSS_COMPILE)ranlib

ifeq ($(JULIA_CPU_TARGET),native)
JCPPFLAGS += -DJULIA_TARGET_NATIVE
else ifeq ($(JULIA_CPU_TARGET),core2)
JCPPFLAGS += -DJULIA_TARGET_CORE2
else ifeq ($(JULIA_CPU_TARGET),i386)
JCPPFLAGS += -DJULIA_TARGET_I386
else
$(error Unknown cpu target architecture)
endif


# Calculate relative paths to libdir and private_libdir
build_libdir_rel = $(shell $(JULIAHOME)/contrib/relative_path.sh $(build_bindir) $(build_libdir))
Expand Down Expand Up @@ -314,7 +300,17 @@ endif

# ===========================================================================

# Select the cpu architecture to target, or automatically detects the user's compiler
# ARCH is the first element of the triple, and gives the CPU class (e.g. x86_64)
# MARCH is the CPU type, and accepts anything that can be passed to the gcc -march flag
# it is set equal to ARCH (for cases where the two are the same, such as i686)
# it can be set to native to optimize all code for the user's machine (not just the JIT code)
# if MARCH is set newer than the native processor, be forewarned that the compile might fail
# JULIA_CPU_TARGET is the JIT-only complement to MARCH. Setting it explicitly is not generally necessary,
# since it is set equal to MARCH by default

BUILD_MACHINE := $(shell $(HOSTCC) -dumpmachine)
ifeq ($(ARCH),)
ARCH := $(shell $(CC) -dumpmachine | sed "s/\([^-]*\).*$$/\1/")
ifeq ($(ARCH),mingw32)
$(error "the mingw32 compiler you are using fails the openblas testsuite. please see the README.windows document for a replacement")
Expand All @@ -334,11 +330,43 @@ endif
BUILD_MACHINE := $(ARCH)$(shell echo $(BUILD_MACHINE) | sed "s/[^-]*\(.*\)$$/\1/")
endif
endif
else
XC_HOST := $(ARCH)$(shell echo $(BUILD_MACHINE) | sed "s/[^-]*\(.*\)$$/\1/")
MARCH = $(ARCH)
endif

ifneq ($(MARCH),)
CC += -march=$(MARCH)
CXX += -march=$(MARCH)
FC += -march=$(MARCH)
JULIA_CPU_TARGET ?= $(MARCH)
endif
JULIA_CPU_TARGET ?= native
JCPPFLAGS += -DJULIA_TARGET_ARCH=$(JULIA_CPU_TARGET)

# We map amd64 to x86_64 for compatibility with systems that identify 64-bit systems as such
ifeq ($(ARCH),amd64)
ARCH = x86_64
endif
override ARCH = x86_64
endif

ifeq ($(ARCH),i386)
BINARY=32
else ifeq ($(ARCH),i387)
BINARY=32
else ifeq ($(ARCH),i486)
BINARY=32
else ifeq ($(ARCH),i586)
BINARY=32
else ifeq ($(ARCH),i686)
BINARY=32
else ifeq ($(ARCH),x86_64)
BINARY=64
else
$(error "unknown word-size for arch: $(ARCH)")
endif
CC += -m$(BINARY)
CXX += -m$(BINARY)
FC += -m$(BINARY)

ifeq ($(USEGCC),1)
ifneq ($(ARCH), ppc64)
Expand Down
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ endif
# Copy in all .jl sources as well
cp -R -L $(build_datarootdir)/julia $(DESTDIR)$(datarootdir)/
# Remove git repository of juliadoc
-rm -r $(DESTDIR)$(datarootdir)/julia/doc/juliadoc/.git
-rm -rf $(DESTDIR)$(datarootdir)/julia/doc/juliadoc/.git
-rm $(DESTDIR)$(datarootdir)/julia/doc/juliadoc/.gitignore
# Copy in beautiful new man page!
$(INSTALL_F) $(build_datarootdir)/man/man1/julia.1 $(DESTDIR)$(datarootdir)/man/man1/
Expand Down Expand Up @@ -260,8 +260,6 @@ endif
# If you want to make a distribution with a hardcoded path, you take care of installation
ifeq ($(OS), Darwin)
-cat ./contrib/mac/juliarc.jl >> $(DESTDIR)$(prefix)/etc/julia/juliarc.jl
else ifeq ($(OS), WINNT)
-cat ./contrib/windows/juliarc.jl >> $(DESTDIR)$(prefix)/etc/julia/juliarc.jl
endif

# purge sys.{dll,so,dylib} as that file is not relocatable across processor architectures
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,15 @@ Julia does not install anything outside the directory it was cloned into. Julia
* Instead of setting `LDFLAGS`, putting the library directory into the environment variable `LD_LIBRARY_PATH` (at both compile and run time) also works.
* See also the [external dependencies](#Required-Build-Tools-External-Libraries).

#### Architecture Customization

Julia can be built for a non-generic architecture by configuring the `ARCH` Makefile variable. See the appropriate section of `Make.inc` for additional customization options, such as `MARCH` and `JULIA_CPU_TARGET`.

For example, to build for i486, set `ARCH=i486` and install the necessary system libraries for linking. On Ubuntu, these may include lib32gfortran3 (also manually call `ln -s /usr/lib32/libgfortran3.so.0 /usr/lib32/libgfortran3.so`) and lib32gcc1, lib32stdc++6, among others.

You can also set `MARCH=native` for a maximum-performance build customized for the current machine CPU.


#### Ubuntu

The [julia-deps PPA](https://launchpad.net/~staticfloat/+archive/julia-deps/) contains updated packages for julia dependencies if you want to use system libraries instead of having them downloaded and built during the build process. See [System Provided Libraries](#System-Provided-Libraries).
Expand Down
4 changes: 2 additions & 2 deletions base/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ build_h.jl.phony:
@echo "# This file is automatically generated in base/Makefile" > $@
@$(CPP_STDOUT) build.h -I../src/support | grep . >> $@
@echo "const ARCH = :$(ARCH)" >> $@
ifeq ($(OS),$(BUILD_OS))
ifeq ($(XC_HOST),)
@echo "const MACHINE = \"$(BUILD_MACHINE)\"" >> $@
else
@echo "const MACHINE = \"$(shell $(CC) -dumpmachine)\"" >> $@
@echo "const MACHINE = \"$(XC_HOST)\"" >> $@
endif
@echo "const libm_name = \"$(LIBMNAME)\"" >> $@
@echo "const libblas_name = \"$(LIBBLASNAME)\"" >> $@
Expand Down
13 changes: 10 additions & 3 deletions base/REPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -635,9 +635,16 @@ function setup_interface(repl::LineEditREPL; extra_repl_keymap = Dict{Any,Any}[]
:shell => shell_mode,
:help => help_mode])
if !repl.no_history_file
f = open(find_hist_file(), true, true, true, false, false)
finalizer(replc, replc->close(f))
hist_from_file(hp, f)
try
f = open(find_hist_file(), true, true, true, false, false)
finalizer(replc, replc->close(f))
hist_from_file(hp, f)
catch e
print_response(repl, e, catch_backtrace(), true, Base.have_color)
println(outstream(repl))
info("Disabling history file for this session.")
repl.no_history_file = true
end
end
history_reset_state(hp)
julia_prompt.hist = hp
Expand Down
20 changes: 10 additions & 10 deletions base/complex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -542,12 +542,12 @@ end
function asin(z::Complex)
zr, zi = reim(z)
if isinf(zr) && isinf(zi)
return Complex(copysign(pi/4, zr),zi)
return Complex(copysign(oftype(zr, pi/4), zr),zi)
elseif isnan(zi) && isinf(zr)
return Complex(zi, oftype(zr, Inf))
end
ξ = zr == 0 ? zr :
!isfinite(zr) ? pi/2*sign(zr) :
!isfinite(zr) ? oftype(zr, pi/2)*sign(zr) :
atan2(zr, real(sqrt(1-z)*sqrt(1+z)))
η = asinh(copysign(imag(sqrt(conj(1-z))*sqrt(1+z)), imag(z)))
Complex(ξ,η)
Expand All @@ -560,18 +560,18 @@ function acos{T<:FloatingPoint}(z::Complex{T})
else return Complex(zr, zr) end
elseif isnan(zi)
if isinf(zr) return Complex(zi, abs(zr))
elseif zr==0 return Complex(pi/2, zi)
elseif zr==0 return Complex(oftype(zr, pi/2), zi)
else return Complex(zi, zi) end
elseif zr==zi==0
return Complex(pi/2, -zi)
return Complex(oftype(zr, pi/2), -zi)
elseif zr==Inf && zi===0.0
return Complex(zi, -zr)
elseif zr==-Inf && zi===-0.0
return Complex(oftype(zi, pi), -zr)
end
ξ = 2*atan2(real(sqrt(1-z)), real(sqrt(1+z)))
η = asinh(imag(sqrt(conj(1+z))*sqrt(1-z)))
if isinf(zr) && isinf(zi) ξ -= pi/4 * sign(zr) end
if isinf(zr) && isinf(zi) ξ -= oftype(η, pi/4) * sign(zr) end
Complex(ξ,η)
end
acos(z::Complex) = acos(float(z))
Expand Down Expand Up @@ -629,12 +629,12 @@ function acosh(z::Complex)
return Complex(oftype(zr, NaN), oftype(zi, NaN))
end
elseif zr==-Inf && zi===-0.0 #Edge case is wrong - WHY?
return Complex(Inf, -pi)
return Complex(inf(zr), oftype(zi, -pi))
end
ξ = asinh(real(sqrt(conj(z-1))*sqrt(z+1)))
η = 2atan2(imag(sqrt(z-1)),real(sqrt(z+1)))
if isinf(zr) && isinf(zi)
η -= pi/4 * sign(zi) * sign(zr)
η -= oftype(η, pi/4) * sign(zi) * sign(zr)
end
Complex(ξ, η)
end
Expand All @@ -655,17 +655,17 @@ function atanh{T<:FloatingPoint}(z::Complex{T})
end
end
if isinf(y)
return Complex(copysign(zero(x),x), copysign(pi/2, y))
return Complex(copysign(zero(x),x), copysign(oftype(y, pi/2), y))
end
return Complex(real(1/z), copysign(pi/2, y))
return Complex(real(1/z), copysign(oftype(y, pi/2), y))
elseif ax==1
if y == 0
ξ = copysign(oftype(x,Inf),x)
η = zero(y)
else
ym = ay+ρ
ξ = log(sqrt(sqrt(4+y*y))/sqrt(ym))
η = copysign(pi/2+atan(ym/2), y)/2
η = copysign(oftype(y, pi/2)+atan(ym/2), y)/2
end
else #Normal case
ysq = (ay+ρ)^2
Expand Down
2 changes: 1 addition & 1 deletion base/dict.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function _truncate_at_width_or_chars(str, width, chars="", truncmark="…")
(wid >= width || c in chars) && break
end

str[lastidx] in chars && (lastidx = prevind(str, lastidx))
lastidx != 0 && str[lastidx] in chars && (lastidx = prevind(str, lastidx))
truncidx == 0 && (truncidx = lastidx)
if lastidx < sizeof(str)
return bytestring(SubString(str, 1, truncidx) * truncmark)
Expand Down
1 change: 1 addition & 0 deletions base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,7 @@ export
isperm,
issorted,
last,
linrange,
linspace,
logspace,
mapslices,
Expand Down
2 changes: 2 additions & 0 deletions base/range.jl
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ range(a::FloatingPoint, st::FloatingPoint, len::Integer) = FloatRange(a,st,len,o
range(a::Real, st::FloatingPoint, len::Integer) = FloatRange(float(a), st, len, one(st))
range(a::FloatingPoint, st::Real, len::Integer) = FloatRange(a, float(st), len, one(a))

linrange(a::Real,b::Real,len::Integer) = len >= 2 ? range(a, (b-a)/(len-1),len) : len == 1 && a == b ? range(a, zero((b-a)/(len-1)), 1) : error("invalid range length")

## interface implementations

similar(r::Range, T::Type, dims::Dims) = Array(T, dims)
Expand Down
3 changes: 2 additions & 1 deletion base/stat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ for f in {
:issetgid
:issticky
:isreadable
:iswritable
:isexecutable
:uperm
:gperm
Expand All @@ -107,6 +106,8 @@ end

islink(path...) = islink(lstat(path...))

@windows_only iswritable(path...) = ccall(:_waccess, Cint, (Ptr{Uint16}, Cint), utf16(joinpath(path...)), 2) == 0
@unix_only iswritable(path...) = ccall(:access, Cint, (Ptr{Uint8}, Cint), joinpath(path...), 2) == 0

# some convenience functions

Expand Down
1 change: 0 additions & 1 deletion base/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ end
function check_blas()
blas = blas_vendor()
if blas == :openblas
@windows_only ccall((:gotoblas_init, Base.libblas_name), Void, ())
openblas_config = openblas_get_config()
openblas64 = ismatch(r".*USE64BITINT.*", openblas_config)
if Base.USE_BLAS64 != openblas64
Expand Down
48 changes: 47 additions & 1 deletion contrib/windows/build-installer.nsi
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
!include "MUI.nsh"
!include "MUI2.nsh"
!include "nsDialogs.nsh"
!include "winmessages.nsh"

Name "The Julia Language"
OutFile "julia-installer.exe"
Expand All @@ -7,6 +9,25 @@ CRCCheck on
SetDataBlockOptimize on
ShowInstDetails show
RequestExecutionLevel user
BrandingText "Julia ${Version}"

# User interface changes
var Checkbox

# Add the desktop checkbox to the final page.
Function desktopCheckbox
${NSD_CreateCheckbox} 120u 130u 100% 10u "Create &desktop shortcut"
Pop $Checkbox
SetCtlColors $Checkbox "" "ffffff"
FunctionEnd

# Create the desktop link only, if the desktop checkbox is active.
Function createDesktopLink
${NSD_GetState} $Checkbox $0
${If} $0 <> 0
CreateShortCut "$DESKTOP\Julia.lnk" "$INSTDIR\bin\julia.exe"
${EndIf}
FunctionEnd

# Icon settings
!define MUI_ICON "contrib\windows\julia.ico"
Expand All @@ -30,19 +51,42 @@ InstallDir "$LOCALAPPDATA\Julia-${Version}"

!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES

!define MUI_PAGE_CUSTOMFUNCTION_SHOW desktopCheckbox
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE createDesktopLink
!insertmacro MUI_PAGE_FINISH

!insertmacro MUI_LANGUAGE "English"

# Add/Remove Programs entry
!define ARP "Software\Microsoft\Windows\CurrentVersion\Uninstall\Julia ${Version}"

Section "Dummy Section" SecDummy
SetOutPath $INSTDIR
File /a /r "julia-${Commit}\*"
WriteUninstaller "$INSTDIR\Uninstall.exe"
CreateShortcut "$INSTDIR\julia.lnk" "$INSTDIR\bin\julia.exe"

# ARP entries
WriteRegStr HKCU "${ARP}" \
"DisplayName" "Julia Language ${Version}"
WriteRegStr HKCU "${ARP}" \
"Publisher" "The Julia Project"
WriteRegStr HKCU "${ARP}" \
"DisplayIcon" "$INSTDIR\bin\julia.exe"
WriteRegStr HKCU "${ARP}" \
"UninstallString" "$\"$INSTDIR\uninstall.exe$\""
WriteRegStr HKCU "${ARP}" \
"QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S"
WriteRegDWORD HKCU "${ARP}" "EstimatedSize" "300"
WriteRegDWORD HKCU "${ARP}" "NoModify" "1"
WriteRegDWORD HKCU "${ARP}" "NoRepair" "1"
SectionEnd

Section "uninstall"
Delete "$INSTDIR/uninstall.exe"
Delete "$DESKTOP\Julia.lnk"
DeleteRegKey HKCU "${ARP}"
RMDir /r "$SMPROGRAMS\${StartMenuFolder}"
RMDir /r "$INSTDIR/"
SectionEnd
Expand All @@ -53,6 +97,8 @@ Function AddToStartMenu
CreateShortcut "$SMPROGRAMS\${StartMenuFolder}\julia.lnk" "$INSTDIR\julia.lnk" "" "" "" "" "" "The Julia Language"
CreateShortcut "$SMPROGRAMS\${StartMenuFolder}\Uninstall.lnk" "$instdir\Uninstall.exe"
FunctionEnd

# Opens the installation folder
Function ShowInstallFolder
ExecShell "open" $INSTDIR
FunctionEnd
Expand Down
4 changes: 1 addition & 3 deletions contrib/windows/juliarc.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
let user_data_dir
ENV["PATH"] = JULIA_HOME*";"*joinpath(JULIA_HOME,"..","Git","bin")*";"*ENV["PATH"]
haskey(ENV,"JULIA_EDITOR") || (ENV["JULIA_EDITOR"] = "start")
user_data_dir = abspath(ENV["AppData"],"julia")
isdir(user_data_dir) || mkdir(user_data_dir)
#haskey(ENV,"JULIA_EDITOR") || (ENV["JULIA_EDITOR"] = "start") #start is not a program, so this doesn't work
end
Loading

0 comments on commit a4ba5e5

Please sign in to comment.