Skip to content

Commit

Permalink
rename JULIA_HOME => Sys.BINDIR [fix #20899]
Browse files Browse the repository at this point in the history
ENV["JULIA_HOME"] => ENV["JULIA_BINDIR"]
  • Loading branch information
StefanKarpinski committed Dec 18, 2017
1 parent 43eee7f commit e83ce4b
Show file tree
Hide file tree
Showing 39 changed files with 109 additions and 91 deletions.
7 changes: 5 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,9 @@ Compiler/Runtime improvements
Deprecated or removed
---------------------

* The `JULIA_HOME` environment variable has been renamed to `JULIA_BINDIR` and
`Base.JULIA_HOME` has been moved to `Sys.BINDIR` ([#20899]).

* The keyword `immutable` is fully deprecated to `struct`, and
`type` is fully deprecated to `mutable struct` ([#19157], [#20418]).

Expand Down Expand Up @@ -613,8 +616,8 @@ Deprecated or removed
`serialize` ([#6466]).

* The default `juliarc.jl` file on Windows has been removed. Now must explicitly include the
full path if you need access to executables or libraries in the `JULIA_HOME` directory, e.g.
`joinpath(JULIA_HOME, "7z.exe")` for `7z.exe` ([#21540]).
full path if you need access to executables or libraries in the `Sys.BINDIR` directory, e.g.
`joinpath(Sys.BINDIR, "7z.exe")` for `7z.exe` ([#21540]).

* `sqrtm` has been deprecated in favor of `sqrt` ([#23504]).

Expand Down
8 changes: 4 additions & 4 deletions base/client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -327,11 +327,11 @@ end

function load_juliarc()
# If the user built us with a specific Base.SYSCONFDIR, check that location first for a juliarc.jl file
# If it is not found, then continue on to the relative path based on JULIA_HOME
if !isempty(Base.SYSCONFDIR) && isfile(joinpath(JULIA_HOME, Base.SYSCONFDIR, "julia", "juliarc.jl"))
include(Main, abspath(JULIA_HOME, Base.SYSCONFDIR, "julia", "juliarc.jl"))
# If it is not found, then continue on to the relative path based on Sys.BINDIR
if !isempty(Base.SYSCONFDIR) && isfile(joinpath(Sys.BINDIR, Base.SYSCONFDIR, "julia", "juliarc.jl"))
include(Main, abspath(Sys.BINDIR, Base.SYSCONFDIR, "julia", "juliarc.jl"))
else
try_include(Main, abspath(JULIA_HOME, "..", "etc", "julia", "juliarc.jl"))
try_include(Main, abspath(Sys.BINDIR, "..", "etc", "julia", "juliarc.jl"))
end
try_include(Main, abspath(homedir(), ".juliarc.jl"))
nothing
Expand Down
3 changes: 3 additions & 0 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2164,6 +2164,9 @@ end
@deprecate parse(str::AbstractString, pos::Int, ; kwargs...) Meta.parse(str, pos; kwargs...)
@deprecate_binding ParseError Meta.ParseError

# issue #20899
# TODO: delete JULIA_HOME deprecation in src/init.c

@eval LinAlg begin
@deprecate chol!(x::Number, uplo) chol(x) false
end
Expand Down
1 change: 0 additions & 1 deletion base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ export
C_NULL,
ENDIAN_BOM,
ENV,
JULIA_HOME,
LOAD_PATH,
PROGRAM_FILE,
STDERR,
Expand Down
17 changes: 5 additions & 12 deletions base/initdefs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,18 @@ code.
const LOAD_PATH = String[]
const LOAD_CACHE_PATH = String[]

function init_load_path(JULIA_HOME = JULIA_HOME)
function init_load_path(BINDIR = Sys.BINDIR)
vers = "v$(VERSION.major).$(VERSION.minor)"
if haskey(ENV, "JULIA_LOAD_PATH")
prepend!(LOAD_PATH, split(ENV["JULIA_LOAD_PATH"], @static Sys.iswindows() ? ';' : ':'))
end
push!(LOAD_PATH, abspath(JULIA_HOME, "..", "local", "share", "julia", "site", vers))
push!(LOAD_PATH, abspath(JULIA_HOME, "..", "share", "julia", "site", vers))
#push!(LOAD_CACHE_PATH, abspath(JULIA_HOME, "..", "lib", "julia")) #TODO: add a builtin location?
push!(LOAD_PATH, abspath(BINDIR, "..", "local", "share", "julia", "site", vers))
push!(LOAD_PATH, abspath(BINDIR, "..", "share", "julia", "site", vers))
#push!(LOAD_CACHE_PATH, abspath(BINDIR, "..", "lib", "julia")) #TODO: add a builtin location?
end

function early_init()
global const JULIA_HOME = ccall(:jl_get_julia_home, Any, ())
Sys._early_init()
# make sure OpenBLAS does not set CPU affinity (#1070, #9639)
ENV["OPENBLAS_MAIN_FREE"] = get(ENV, "OPENBLAS_MAIN_FREE",
get(ENV, "GOTOBLAS_MAIN_FREE", "1"))
Expand All @@ -80,13 +80,6 @@ function early_init()
end
end

"""
JULIA_HOME
A string containing the full path to the directory containing the `julia` executable.
"""
:JULIA_HOME

const atexit_hooks = []

"""
Expand Down
2 changes: 1 addition & 1 deletion base/interactiveutil.jl
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ function runtests(tests = ["all"], numcores = ceil(Int, Sys.CPU_CORES / 2);
ENV2 = copy(ENV)
ENV2["JULIA_CPU_CORES"] = "$numcores"
try
run(setenv(`$(julia_cmd()) $(joinpath(JULIA_HOME,
run(setenv(`$(julia_cmd()) $(joinpath(Sys.BINDIR,
Base.DATAROOTDIR, "julia", "test", "runtests.jl")) $tests`, ENV2))
catch
buf = PipeBuffer()
Expand Down
2 changes: 1 addition & 1 deletion base/libgit2/libgit2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ function __init__()
ENV["SSL_CERT_FILE"]
else
# If we have a bundled ca cert file, point libgit2 at that so SSL connections work.
abspath(ccall(:jl_get_julia_home, Any, ()), Base.DATAROOTDIR, "julia", "cert.pem")
abspath(ccall(:jl_get_julia_bindir, Any, ()), Base.DATAROOTDIR, "julia", "cert.pem")
end
set_ssl_cert_locations(cert_loc)
end
Expand Down
2 changes: 1 addition & 1 deletion base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ end

function find_source_file(path::String)
(isabspath(path) || isfile(path)) && return path
base_path = joinpath(JULIA_HOME, DATAROOTDIR, "julia", "base", path)
base_path = joinpath(Sys.BINDIR, DATAROOTDIR, "julia", "base", path)
return isfile(base_path) ? base_path : nothing
end

Expand Down
2 changes: 1 addition & 1 deletion base/options.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
struct JLOptions
quiet::Int8
banner::Int8
julia_home::Ptr{UInt8}
julia_bindir::Ptr{UInt8}
julia_bin::Ptr{UInt8}
commands::Ptr{Ptr{UInt8}} # (e)eval, (E)print, (L)load
image_file::Ptr{UInt8}
Expand Down
2 changes: 1 addition & 1 deletion base/sysimg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ include("threadcall.jl")
include("loading.jl")

# set up load path to be able to find stdlib packages
init_load_path(ccall(:jl_get_julia_home, Any, ()))
init_load_path(ccall(:jl_get_julia_bindir, Any, ()))

INCLUDE_STATE = 3 # include = include_relative

Expand Down
15 changes: 13 additions & 2 deletions base/sysinfo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ module Sys
Provide methods for retrieving information about hardware and the operating system.
""" -> Sys

export CPU_CORES,
export BINDIR,
CPU_CORES,
CPU_NAME,
WORD_SIZE,
ARCH,
Expand All @@ -26,6 +27,17 @@ export CPU_CORES,

import ..Base: show

"""
Sys.BINDIR
A string containing the full path to the directory containing the `julia` executable.
"""
BINDIR = ccall(:jl_get_julia_bindir, Any, ())

_early_init() = global BINDIR = ccall(:jl_get_julia_bindir, Any, ())

# helper to avoid triggering precompile warnings

global CPU_CORES
"""
Sys.CPU_CORES
Expand Down Expand Up @@ -66,7 +78,6 @@ Standard word size on the current machine, in bits.
const WORD_SIZE = Core.sizeof(Int) * 8

function __init__()
# set CPU core count
global CPU_CORES =
haskey(ENV,"JULIA_CPU_CORES") ? parse(Int,ENV["JULIA_CPU_CORES"]) :
Int(ccall(:jl_cpu_cores, Int32, ()))
Expand Down
2 changes: 1 addition & 1 deletion base/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ println_with_color(color::Union{Int, Symbol}, io::IO, msg...; bold::Bool = false
println_with_color(color::Union{Int, Symbol}, msg...; bold::Bool = false) =
println_with_color(color, STDOUT, msg...; bold = bold)

function julia_cmd(julia=joinpath(JULIA_HOME, julia_exename()))
function julia_cmd(julia=joinpath(Sys.BINDIR, julia_exename()))
opts = JLOptions()
cpu_target = unsafe_string(opts.cpu_target)
image_file = unsafe_string(opts.image_file)
Expand Down
6 changes: 3 additions & 3 deletions contrib/build_sysimg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function default_sysimg_path(debug=false)
if Sys.isunix()
splitext(Libdl.dlpath(debug ? "sys-debug" : "sys"))[1]
else
joinpath(dirname(JULIA_HOME), "lib", "julia", debug ? "sys-debug" : "sys")
joinpath(dirname(Sys.BINDIR), "lib", "julia", debug ? "sys-debug" : "sys")
end
end

Expand All @@ -17,7 +17,7 @@ end
Rebuild the system image. Store it in `sysimg_path`, which defaults to a file named `sys.ji`
that sits in the same folder as `libjulia.{so,dylib}`, except on Windows where it defaults
to `JULIA_HOME/../lib/julia/sys.ji`. Use the cpu instruction set given by `cpu_target`.
to `Sys.BINDIR/../lib/julia/sys.ji`. Use the cpu instruction set given by `cpu_target`.
Valid CPU targets are the same as for the `-C` option to `julia`, or the `-march` option to
`gcc`. Defaults to `native`, which means to use all CPU instructions available on the
current processor. Include the user image file given by `userimg_path`, which should contain
Expand Down Expand Up @@ -46,7 +46,7 @@ function build_sysimg(sysimg_path=nothing, cpu_target="native", userimg_path=not
# Enter base and setup some useful paths
base_dir = dirname(Base.find_source_file("sysimg.jl"))
cd(base_dir) do
julia = joinpath(JULIA_HOME, debug ? "julia-debug" : "julia")
julia = joinpath(Sys.BINDIR, debug ? "julia-debug" : "julia")
cc, warn_msg = find_system_compiler()

# Ensure we have write-permissions to wherever we're trying to write to
Expand Down
4 changes: 2 additions & 2 deletions contrib/julia-config.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ function libDir()
end
end

private_libDir() = abspath(JULIA_HOME, Base.PRIVATE_LIBDIR)
private_libDir() = abspath(Sys.BINDIR, Base.PRIVATE_LIBDIR)

function includeDir()
return abspath(JULIA_HOME, Base.INCLUDEDIR, "julia")
return abspath(Sys.BINDIR, Base.INCLUDEDIR, "julia")
end

function ldflags()
Expand Down
4 changes: 2 additions & 2 deletions contrib/mac/juliarc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

# Set up environment for Julia OSX binary distribution
let
ROOT = abspath(JULIA_HOME,"..")
ENV["PATH"]="$JULIA_HOME:$(ENV["PATH"])"
ROOT = abspath(Sys.BINDIR,"..")
ENV["PATH"]="$(Sys.BINDIR):$(ENV["PATH"])"
ENV["FONTCONFIG_PATH"] = joinpath(ROOT, "etc", "fonts")
ENV["TK_LIBRARY"] = "/System/Library/Frameworks/Tk.framework/Versions/8.5/Resources/Scripts"
end
2 changes: 1 addition & 1 deletion doc/src/devdocs/sysimg.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ named `build_sysimg.jl` that lives in `DATAROOTDIR/julia/`. That is, to include
Julia session, type:

```julia
include(joinpath(JULIA_HOME, Base.DATAROOTDIR, "julia", "build_sysimg.jl"))
include(joinpath(Sys.BINDIR, Base.DATAROOTDIR, "julia", "build_sysimg.jl"))
```

This will include a `build_sysimg` function:
Expand Down
4 changes: 2 additions & 2 deletions doc/src/manual/embedding.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ the above test program `test.c` with `gcc` using:
gcc -o test -fPIC -I$JULIA_DIR/include/julia -L$JULIA_DIR/lib test.c -ljulia $JULIA_DIR/lib/julia/libstdc++.so.6
```
Then if the environment variable `JULIA_HOME` is set to `$JULIA_DIR/bin`, the output `test` program
Then if the environment variable `JULIA_BINDIR` is set to `$JULIA_DIR/bin`, the output `test` program
can be executed.
Alternatively, look at the `embedding.c` program in the Julia source tree in the `examples/` folder.
Expand Down Expand Up @@ -125,7 +125,7 @@ too, and the makefile can be used to take advantage of that. The above example
use a Makefile:
```
JL_SHARE = $(shell julia -e 'print(joinpath(JULIA_HOME,Base.DATAROOTDIR,"julia"))')
JL_SHARE = $(shell julia -e 'print(joinpath(Sys.BINDIR, Base.DATAROOTDIR, "julia"))')
CFLAGS += $(shell $(JL_SHARE)/julia-config.jl --cflags)
CXXFLAGS += $(shell $(JL_SHARE)/julia-config.jl --cflags)
LDFLAGS += $(shell $(JL_SHARE)/julia-config.jl --ldflags)
Expand Down
20 changes: 10 additions & 10 deletions doc/src/manual/environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,26 @@ those for which `JULIA` appears in the name.

## File locations

### `JULIA_HOME`
### `JULIA_BINDIR`

The absolute path of the directory containing the Julia executable, which sets
the global variable [`Base.JULIA_HOME`](@ref). If `$JULIA_HOME` is not set, then
Julia determines the value `Base.JULIA_HOME` at run-time.
the global variable [`Sys.BINDIR`](@ref). If `$JULIA_BINDIR` is not set, then
Julia determines the value `Sys.BINDIR` at run-time.

The executable itself is one of

```
$JULIA_HOME/julia
$JULIA_HOME/julia-debug
$JULIA_BINDIR/julia
$JULIA_BINDIR/julia-debug
```

by default.

The global variable `Base.DATAROOTDIR` determines a relative path from
`Base.JULIA_HOME` to the data directory associated with Julia. Then the path
`Sys.BINDIR` to the data directory associated with Julia. Then the path

```
$JULIA_HOME/$DATAROOTDIR/julia/base
$JULIA_BINDIR/$DATAROOTDIR/julia/base
```

determines the directory in which Julia initially searches for source files (via
Expand All @@ -45,15 +45,15 @@ Likewise, the global variable `Base.SYSCONFDIR` determines a relative path to th
configuration file directory. Then Julia searches for a `juliarc.jl` file at

```
$JULIA_HOME/$SYSCONFDIR/julia/juliarc.jl
$JULIA_HOME/../etc/julia/juliarc.jl
$JULIA_BINDIR/$SYSCONFDIR/julia/juliarc.jl
$JULIA_BINDIR/../etc/julia/juliarc.jl
```

by default (via `Base.load_juliarc()`).

For example, a Linux installation with a Julia executable located at
`/bin/julia`, a `DATAROOTDIR` of `../share`, and a `SYSCONFDIR` of `../etc` will
have `JULIA_HOME` set to `/bin`, a source-file search path of
have `JULIA_BINDIR` set to `/bin`, a source-file search path of

```
/share/julia/base
Expand Down
2 changes: 1 addition & 1 deletion doc/src/manual/unicode-input.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function tab_completions(symbols...)
end
function unicode_data()
file = normpath(JULIA_HOME, "..", "..", "doc", "UnicodeData.txt")
file = normpath(Sys.BINDIR, "..", "..", "doc", "UnicodeData.txt")
names = Dict{UInt32, String}()
open(file) do unidata
for line in readlines(unidata)
Expand Down
2 changes: 1 addition & 1 deletion doc/src/stdlib/constants.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Base.ARGS
Base.C_NULL
Base.VERSION
Base.LOAD_PATH
Base.JULIA_HOME
Base.Sys.BINDIR
Base.Sys.CPU_CORES
Base.Sys.WORD_SIZE
Base.Sys.KERNEL
Expand Down
2 changes: 1 addition & 1 deletion examples/embedding/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ SRCDIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
EXE := $(suffix $(abspath $(JULIA)))

# get compiler and linker flags. (see: `contrib/julia-config.jl`)
JULIA_CONFIG := $(JULIA) -e 'include(joinpath(JULIA_HOME, Base.DATAROOTDIR, "julia", "julia-config.jl"))' --
JULIA_CONFIG := $(JULIA) -e 'include(joinpath(Sys.BINDIR, Base.DATAROOTDIR, "julia", "julia-config.jl"))' --
CPPFLAGS_ADD :=
CFLAGS_ADD = $(shell $(JULIA_CONFIG) --cflags)
LDFLAGS_ADD = -lm $(shell $(JULIA_CONFIG) --ldflags --ldlibs)
Expand Down
2 changes: 1 addition & 1 deletion examples/embedding/embedding-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using Test

if Sys.iswindows()
# libjulia needs to be in the same directory as the embedding executable or in path
ENV["PATH"] = string(JULIA_HOME, ";", ENV["PATH"])
ENV["PATH"] = string(Sys.BINDIR, ";", ENV["PATH"])
end

@test length(ARGS) == 1
Expand Down
2 changes: 1 addition & 1 deletion src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1680,7 +1680,7 @@ extern "C" int isabspath(const char *in);

static void write_log_data(logdata_t &logData, const char *extension)
{
std::string base = std::string(jl_options.julia_home);
std::string base = std::string(jl_options.julia_bindir);
base = base + "/../share/julia/base/";
logdata_t::iterator it = logData.begin();
for (; it != logData.end(); it++) {
Expand Down
2 changes: 1 addition & 1 deletion src/dlload.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static int endswith_extension(const char *path)

#define PATHBUF 512

extern char *julia_home;
extern char *julia_bindir;

#define JL_RTLD(flags, FLAG) (flags & JL_RTLD_ ## FLAG ? RTLD_ ## FLAG : 0)

Expand Down
Loading

0 comments on commit e83ce4b

Please sign in to comment.