Skip to content

Commit

Permalink
Merge branch 'master' of github.com:JuliaLang/julia into jb/inbounds
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Jul 5, 2013
2 parents 419d3a7 + d852e9c commit e0cdf63
Show file tree
Hide file tree
Showing 215 changed files with 11,634 additions and 5,148 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

/*.tar.gz
/tmp
/dist
/dist*

/julia
/julia-*
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
[submodule "deps/Rmath"]
path = deps/Rmath
url = git:https://github.com/JuliaLang/Rmath.git
[submodule "doc/juliadoc"]
path = doc/juliadoc
url = git:https://github.com/JuliaLang/JuliaDoc.git
4 changes: 4 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,7 @@ Blake Johnson <[email protected]> <[email protected]>

Marcus Silva <[email protected]> <[email protected]>
Marcus Silva <[email protected]> <[email protected]>

Amit Murthy <[email protected]> <[email protected]>

Tanmay Mohapatra <[email protected]> <[email protected]>
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ compiler:
- gcc
notifications:
email: false
webhooks:
urls:
- https://128.52.160.154/travis-hook
on_failure: never
before_install:
- BUILDOPTS="LLVM_CONFIG=llvm-config-3.2 USE_QUIET=0 USE_BLAS64=0"; for lib in LLVM ZLIB SUITESPARSE ARPACK BLAS FFTW LAPACK GMP MPFR PCRE LIBUNWIND READLINE GRISU OPENLIBM RMATH; do export BUILDOPTS="$BUILDOPTS USE_SYSTEM_$lib=1"; done
- sudo apt-get update -qq -y
Expand Down
78 changes: 78 additions & 0 deletions FAQ.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Frequently-asked questions

### Sessions and the REPL

#### How do I delete an object in memory?

Julia does not have an analog of MATLAB's `clear` function; once a name is defined in a Julia session (technically, in module `Main`), it is always present.

If memory usage is your concern, you can always replace objects with ones that consume less memory.
For example, if `A` is a gigabyte-sized array that you no longer need, you can free the memory with `A = 0`.
The memory will be released the next time the garbage collector runs; you can force this to happen with `gc()`.

#### How can I modify the declaration of a type/immutable in my session?

Perhaps you've defined a type and and then realize you need to add a new field.
If you try this at the REPL, you get the error
```
ERROR: invalid redefinition of constant MyType
```
Types in module `Main` cannot be redefined.

While this can be inconvenient when you are developing new code, there's an excellent workaround.
Modules can be replaced by redefining them, and so if you wrap all your new code inside a module you can redefine types and constants.
You can't import the type names into `Main` and then expect to be able to redefine them there, but you can use the module name to resolve the scope.
In other words, while developing you might use a workflow something like this:
```julia
include("mynewcode.jl") # this defines a module MyModule
obj1 = MyModule.ObjConstructor(a, b)
obj2 = MyModule.somefunction(obj1)
# Got an error. Change something in "mynewcode.jl"
include("mynewcode.jl") # reload the module
obj1 = MyModule.ObjConstructor(a, b) # old objects are no longer valid, must reconstruct
obj2 = MyModule.somefunction(obj1) # this time it worked!
obj3 = MyModule.someotherfunction(obj2, c)
...
```

### Developing Julia

#### How do I debug julia's C code? (running the julia REPL from within a debugger like gdb)

First, you should build the debug version of julia with `make debug`.
Below, lines starting with `(gdb)` mean things you should type at the gdb prompt.

##### From the shell

The main challenge is that Julia and gdb each need to have their own terminal, so you can interact with them both.
The first time you do this, you'll need to define a script, here called `oterm`, containing the following lines:
```
ps
sleep 600000
```
Make it executable with `chmod +x oterm`.

Now:

- From a shell (called shell 1), type `xterm -e oterm &`. You'll see a new window pop up; this will be called terminal 2.
- From within shell 1, `gdb julia-debug-basic`. You can find this executable within `julia/usr/bin`.
- From within shell 1, `(gdb) tty /dev/pts/#` where `#` is the number shown after `pts/` in terminal 2.
- From within shell 1, `(gdb) run`
- From within terminal 2, issue any preparatory commands in Julia that you need to get to the step you want to debug
- From within shell 1, hit Ctrl-C
- From within shell 1, insert your breakpoint, e.g., `(gdb) b codegen.cpp:2244`
- From within shell 1, `(gdb) c` to resume execution of julia
- From within terminal 2, issue the command that you want to debug. Shell 1 will stop at your breakpoint.


##### Within emacs

- `M-x gdb`, then enter `julia-debug-basic` (this is easiest from within julia/usr/bin, or you can specify the full path)
- `(gdb) run`
- Now you'll see the Julia prompt. Run any commands in Julia you need to get to the step you want to debug.
- Under emacs' "Signals" menu choose BREAK---this will return you to the `(gdb)` prompt
- Set a breakpoint, e.g.,
`(gdb) b codegen.cpp:2244`
- Go back to the Julia prompt via
`(gdb) c`
- Execute the Julia command you want to see running.
80 changes: 41 additions & 39 deletions Make.inc
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# -*- mode: makefile-gmake -*-

USE_MKL = 0
#MKLROOT = /opt/intel/composerxe/mkl/
MKLLIB = $(MKLROOT)/lib/intel64

# include twice to pickup user definitions
ifeq (exists, $(shell [ -e $(JULIAHOME)/Make.user ] && echo exists ))
include $(JULIAHOME)/Make.user
Expand Down Expand Up @@ -29,7 +33,9 @@ endif

ifeq ($(XC_HOST),)
CROSS_COMPILE=
HOSTCC = $(CC)
else
HOSTCC = gcc
override OPENBLAS_DYNAMIC_ARCH = 1
override CROSS_COMPILE=$(XC_HOST)-
ifneq (,$(findstring mingw,$(XC_HOST)))
Expand All @@ -56,7 +62,7 @@ endif

ifeq ($(OS), WINNT)
fPIC =
PATH := ${PATH}:${BUILD}/lib:${BUILD}/lib/julia
PATH := ${PATH}:${BUILD}/lib:${BUILD}/lib/julia:/c/Program Files/7-zip
EXE = .exe
else
fPIC = -fPIC
Expand Down Expand Up @@ -90,7 +96,6 @@ endif
endif

ifeq ($(USEGCC),1)
HOSTCC = gcc
CC = $(CROSS_COMPILE)gcc
CXX = $(CROSS_COMPILE)g++
JCFLAGS = -std=gnu99 -pipe $(fPIC) -fno-strict-aliasing -D_FILE_OFFSET_BITS=64
Expand All @@ -100,7 +105,6 @@ SHIPFLAGS = -O3 -falign-functions
endif

ifeq ($(USECLANG),1)
HOSTCC = clang
CC = $(CROSS_COMPILE)clang
CXX = $(CROSS_COMPILE)clang++
JCFLAGS = -pipe $(fPIC) -fno-strict-aliasing -D_FILE_OFFSET_BITS=64
Expand All @@ -114,26 +118,6 @@ JCFLAGS += -D_LARGEFILE_SOURCE -D_DARWIN_USE_64_BIT_INODE=1
endif
endif

BUILD_MACHINE := $(shell $(HOSTCC) -dumpmachine)
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")
endif
ifeq ($(OS),Darwin)
ifeq ($(OS),$(BUILD_OS))
## Mac is a nifty dual-arch platform (or was until 10.8), so we detect the currently running OS arch instead
## of the compiler "-dumpmachine" result, like I believe the compiler does, and make a substitution
ARCH := $(shell uname -m)
BUILD_MACHINE := $(ARCH)$(shell echo $(BUILD_MACHINE) | sed "s/[^-]*\(.*\)$$/\1/")
endif
endif

ifeq ($(USEGCC),1)
ifneq ($(ARCH), ppc64)
SHIPFLAGS += -momit-leaf-frame-pointer
endif
endif

FC = $(CROSS_COMPILE)gfortran
JFFLAGS = -O2 $(fPIC)
CPP = $(CC) -E
Expand Down Expand Up @@ -174,15 +158,34 @@ ifeq (exists, $(shell [ -e $(JULIAHOME)/Make.user ] && echo exists ))
include $(JULIAHOME)/Make.user
endif

# Snow Leopard specific configuration
ifeq ($(OS), Darwin)
ifeq ($(OSXVER), 10.6)
USE_SYSTEM_LIBM=1
USE_SYSTEM_BLAS=1
# ===========================================================================

BUILD_MACHINE := $(shell $(HOSTCC) -dumpmachine)
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")
endif
ifeq ($(BUILD_OS),Darwin)
## Mac is a rather amazing 64-bit user-space on 32-bit kernel architecture, so to determine arch we detect
## the capabilities of the hardware, rather than the compiler or kernel, and make a substitution
ifeq ($(ARCH),x86_64)
ARCH = i686
else ifeq ($(ARCH),i386)
ARCH = i686
endif
ifeq ($(ARCH),i686)
ifeq ($(shell sysctl -n hw.cpu64bit_capable),1)
ARCH = x86_64
endif
BUILD_MACHINE := $(ARCH)$(shell echo $(BUILD_MACHINE) | sed "s/[^-]*\(.*\)$$/\1/")
endif
endif

# ===========================================================================
ifeq ($(USEGCC),1)
ifneq ($(ARCH), ppc64)
SHIPFLAGS += -momit-leaf-frame-pointer
endif
endif

ifeq ($(USE_SYSTEM_LIBUNWIND), 1)
LIBUNWIND=-lunwind-generic -lunwind
Expand Down Expand Up @@ -223,8 +226,8 @@ ifeq ($(USE_SYSTEM_BLAS), 1)
ifeq ($(OS), Darwin)
USE_BLAS64 = 0
USE_SYSTEM_LAPACK = 0
LIBBLAS = -framework vecLib -lBLAS
LIBBLASNAME = libBLAS
LIBBLAS = -L$(BUILD)/lib -lgfortblas
LIBBLASNAME = libgfortblas
else
LIBBLAS = -lblas
LIBBLASNAME = libblas
Expand All @@ -244,7 +247,7 @@ ifeq ($(USE_SYSTEM_LAPACK), 1)
LIBLAPACK = -llapack
LIBLAPACKNAME = liblapack
else
LIBLAPACK = -L$(BUILD)/lib -llapack
LIBLAPACK = -L$(BUILD)/lib -llapack $(LIBBLAS)
LIBLAPACKNAME = liblapack
endif
endif
Expand Down Expand Up @@ -348,22 +351,21 @@ endif

# MKL

USE_MKL = 0
MKLLIB = $$MKLROOT/lib/intel64

ifeq ($(USE_MKL), 1)
USE_BLAS64 = 0
USE_SYSTEM_BLAS=1
USE_SYSTEM_LAPACK=1
LIBBLAS = -L$(MKLLIB) -lmkl_rt
LIBLAPACK = -L$(MKLLIB) -lmkl_rt
LIBBLASNAME = libmkl_rt
LIBLAPACKNAME = libmkl_rt
MKL_LDFLAGS = -L$(MKLLIB) -lmkl_rt
ifneq ($(strip $(MKLLIB)),)
ifeq ($(OS), Linux)
RPATH += -Wl,-rpath,$(MKLLIB)
RPATH_MKL = -Wl,-rpath,$(MKLLIB)
RPATH += $(RPATH_MKL)
MKL_LDFLAGS += $(RPATH_MKL)
endif
endif
LIBBLAS = $(MKL_LDFLAGS)
LIBLAPACK = $(MKL_LDFLAGS)
endif

# ATLAS
Expand Down
54 changes: 44 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ VERSDIR = v`cut -d. -f1-2 < VERSION`
all: default
default: release

DIRS = $(BUILD)/bin $(BUILD)/lib $(BUILD)/$(JL_PRIVATE_LIBDIR) $(BUILD)/share/julia
DIRS = $(BUILD)/bin $(BUILD)/lib $(BUILD)/$(JL_PRIVATE_LIBDIR) $(BUILD)/share/julia $(BUILD)/share/julia/man/man1

$(foreach dir,$(DIRS),$(eval $(call dir_target,$(dir))))
$(foreach link,extras base test doc examples,$(eval $(call symlink_target,$(link),$(BUILD)/share/julia)))
$(foreach link,base test doc examples,$(eval $(call symlink_target,$(link),$(BUILD)/share/julia)))

QUIET_MAKE =
ifeq ($(USE_QUIET), 1)
QUIET_MAKE = -s
endif

debug release: | $(DIRS) $(BUILD)/share/julia/extras $(BUILD)/share/julia/base $(BUILD)/share/julia/test $(BUILD)/share/julia/doc $(BUILD)/share/julia/examples
debug release: | $(DIRS) $(BUILD)/share/julia/base $(BUILD)/share/julia/test $(BUILD)/share/julia/doc $(BUILD)/share/julia/examples
@$(MAKE) $(QUIET_MAKE) julia-$@
@export JL_PRIVATE_LIBDIR=$(JL_PRIVATE_LIBDIR) && \
$(MAKE) $(QUIET_MAKE) LD_LIBRARY_PATH=$(BUILD)/lib:$(LD_LIBRARY_PATH) JULIA_EXECUTABLE="$(JULIA_EXECUTABLE_$@)" $(BUILD)/$(JL_PRIVATE_LIBDIR)/sys.ji
Expand All @@ -44,12 +44,16 @@ endif
$(BUILD)/share/julia/helpdb.jl: doc/helpdb.jl | $(BUILD)/share/julia
@cp $< $@

$(BUILD)/share/man/man1/julia.1: doc/man/julia.1 | $(BUILD)/share/julia
@mkdir -p $(BUILD)/share/man/man1
@cp $< $@

COMMIT:
@#this is a .PHONY target so that it will always run
echo `git rev-parse --short HEAD`-$(OS)-$(ARCH) \(`date +"%Y-%m-%d %H:%M:%S"`\) > COMMIT

# use sys.ji if it exists, otherwise run two stages
$(BUILD)/$(JL_PRIVATE_LIBDIR)/sys.ji: VERSION base/*.jl base/pkg/*.jl base/linalg/*.jl $(BUILD)/share/julia/helpdb.jl
$(BUILD)/$(JL_PRIVATE_LIBDIR)/sys.ji: VERSION base/*.jl base/pkg/*.jl base/linalg/*.jl base/sparse/*.jl $(BUILD)/share/julia/helpdb.jl $(BUILD)/share/man/man1/julia.1
@$(MAKE) $(QUIET_MAKE) COMMIT
$(QUIET_JULIA) cd base && \
(test -f $(BUILD)/$(JL_PRIVATE_LIBDIR)/sys.ji || $(call spawn,$(JULIA_EXECUTABLE)) -bf sysimg.jl) && $(call spawn,$(JULIA_EXECUTABLE)) -f sysimg.jl || echo "*** This error is usually fixed by running 'make clean'. If the error persists, try 'make cleanall'. ***"
Expand Down Expand Up @@ -115,14 +119,18 @@ ifeq ($(OS), Darwin)
-./contrib/mac/fixup-libgfortran.sh $(PREFIX)/$(JL_PRIVATE_LIBDIR)
endif
ifeq ($(OS), WINNT)
-[ -e dist-extras/7za.exe ] && cp dist-extras/7za.exe $(PREFIX)/bin/7z.exe
-[ -e dist-extras/PortableGit-1.8.1.2-preview20130201.7z ] && \
mkdir $(PREFIX)/Git && \
7z x dist-extras/PortableGit-1.8.1.2-preview20130201.7z -o"$(PREFIX)/Git"
[ ! -d dist-extras ] || ( cd dist-extras && \
cp 7z.exe 7z.dll libexpat-1.dll zlib1.dll ../$(PREFIX)/bin && \
mkdir ../$(PREFIX)/Git && \
7z x PortableGit.7z -o"../$(PREFIX)/Git" )
ifeq ($(BUILD_OS),WINNT)
cp $(call pathsearch,libgfortran-3.dll,$(PATH)) $(PREFIX)/$(JL_LIBDIR) ;
cp $(call pathsearch,libquadmath-0.dll,$(PATH)) $(PREFIX)/$(JL_LIBDIR) ;
ifeq ($(ARCH),i686)
cp $(call pathsearch,libgcc_s_sjlj-1.dll,$(PATH)) $(PREFIX)/$(JL_LIBDIR) ;
else
cp $(call pathsearch,libgcc_s_seh-1.dll,$(PATH)) $(PREFIX)/$(JL_LIBDIR) ;
endif
cp $(call pathsearch,libstdc++-6.dll,$(PATH)) $(PREFIX)/$(JL_LIBDIR) ;
#cp $(call pathsearch,libssp-0.dll,$(PATH)) $(PREFIX)/$(JL_LIBDIR) ;
else
Expand All @@ -136,6 +144,7 @@ endif
cp $(call wine_pathsearch,libstdc++-6.dll,$(WINE_PATH)) $(PREFIX)/$(JL_LIBDIR) ;
cp $(call wine_pathsearch,libssp-0.dll,$(WINE_PATH)) $(PREFIX)/$(JL_LIBDIR) ;
endif
cd $(PREFIX)/bin && rm -f llvm* llc.exe lli.exe opt.exe LTO.exe bugpoint.exe macho-dump.exe
7z a -mx9 julia-$(JULIA_COMMIT)-$(OS)-$(ARCH).zip julia-$(JULIA_COMMIT)
else
tar zcvf julia-$(JULIA_COMMIT)-$(OS)-$(ARCH).tar.gz julia-$(JULIA_COMMIT)
Expand All @@ -154,6 +163,8 @@ clean: | $(CLEAN_TARGETS)
@rm -f julia
@rm -f *~ *# *.tar.gz
@rm -fr $(BUILD)/$(JL_PRIVATE_LIBDIR)
# Temporarily add this line to the Makefile to remove extras
@rm -fr $(BUILD)/share/julia/extras

cleanall: clean
@$(MAKE) -C src clean-flisp clean-support
Expand Down Expand Up @@ -182,9 +193,32 @@ test-%: release
# download target for some hardcoded windows dependencies
.PHONY: win-extras, wine_path
win-extras:
[ -d dist-extras ] || mkdir dist-extras
ifneq (,$(filter $(ARCH), i386 i686))
cd dist-extras && \
wget -O 7za920.zip https://downloads.sourceforge.net/sevenzip/7za920.zip && \
wget -O PortableGit-1.8.1.2-preview20130201.7z https://msysgit.googlecode.com/files/PortableGit-1.8.1.2-preview20130201.7z
wget -O 7z920.exe https://downloads.sourceforge.net/sevenzip/7z920.exe && \
7z x -y 7z920.exe 7z.exe 7z.dll && \
wget -O mingw-libexpat.rpm https://download.opensuse.org/repositories/windows:/mingw:/win32/SLE_11_SP2/noarch/mingw32-libexpat-2.0.1-4.15.noarch.rpm && \
wget -O mingw-zlib.rpm https://download.opensuse.org/repositories/windows:/mingw:/win32/SLE_11_SP2/noarch/mingw32-zlib-1.2.7-1.16.noarch.rpm
else ifeq ($(ARCH),x86_64)
cd dist-extras && \
wget -O 7z920-x64.msi https://downloads.sourceforge.net/sevenzip/7z920-x64.msi && \
7z x -y 7z920-x64.msi _7z.exe _7z.dll && \
mv _7z.dll 7z.dll && \
mv _7z.exe 7z.exe && \
wget -O mingw-libexpat.rpm https://download.opensuse.org/repositories/windows:/mingw:/win64/SLE_11_SP2/noarch/mingw64-libexpat-2.0.1-3.15.noarch.rpm && \
wget -O mingw-zlib.rpm https://download.opensuse.org/repositories/windows:/mingw:/win64/SLE_11_SP2/noarch/mingw64-zlib-1.2.7-1.19.noarch.rpm
else
$(error no win-extras target for ARCH=$(ARCH))
endif
cd dist-extras && \
chmod a+x 7z.exe && \
7z x -y mingw-libexpat.rpm -so > mingw-libexpat.cpio && \
7z e -y mingw-libexpat.cpio && \
7z x -y mingw-zlib.rpm -so > mingw-zlib.cpio && \
7z e -y mingw-zlib.cpio && \
wget -O PortableGit.7z https://msysgit.googlecode.com/files/PortableGit-1.8.3-preview20130601.7z

wine_path:
$(info $(WINE_PATH))
@echo "wine cmd /c \"set \$$PATH=...\";%PATH% && program"
Expand Down
Loading

0 comments on commit e0cdf63

Please sign in to comment.