Skip to content

Commit

Permalink
contrib and test/perf cleanup for JuliaLang#16219
Browse files Browse the repository at this point in the history
  • Loading branch information
tkelman committed May 21, 2016
1 parent 55b03f5 commit 71a70db
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 57 deletions.
21 changes: 6 additions & 15 deletions contrib/BBEditTextWrangler-julia.plist
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,10 @@
<string>@ip_str</string>
<string>@label</string>
<string>@less</string>
<string>@linux</string>
<string>@linux_only</string>
<string>@math_const</string>
<string>@MIME</string>
<string>@MIME_str</string>
<string>@noinline</string>
<string>@non_windowsxp_only</string>
<string>@osx</string>
<string>@osx_only</string>
<string>@parallel</string>
<string>@printf</string>
<string>@profile</string>
Expand All @@ -95,6 +90,7 @@
<string>@spawn</string>
<string>@spawnat</string>
<string>@sprintf</string>
<string>@static</string>
<string>@sync</string>
<string>@task</string>
<string>@text_str</string>
Expand All @@ -104,15 +100,10 @@
<string>@timev</string>
<string>@uint128_str</string>
<string>@unexpected</string>
<string>@unix</string>
<string>@unix_only</string>
<string>@v_str</string>
<string>@vectorize_1arg</string>
<string>@vectorize_2arg</string>
<string>@which</string>
<string>@windows</string>
<string>@windows_only</string>
<string>@windowsxp_only</string>
<string>\</string>
<string>^</string>
<string>__precompile__</string>
Expand Down Expand Up @@ -588,12 +579,12 @@
<string>ipermutedims</string>
<string>irfft</string>
<string>iround</string>
<string>is_apple</string>
<string>is_assigned_char</string>
<string>is_valid_ascii</string>
<string>is_valid_char</string>
<string>is_valid_utf16</string>
<string>is_valid_utf32</string>
<string>is_valid_utf8</string>
<string>is_bsd</string>
<string>is_linux</string>
<string>is_unix</string>
<string>is_windows</string>
<string>isabspath</string>
<string>isalnum</string>
<string>isalpha</string>
Expand Down
38 changes: 21 additions & 17 deletions contrib/build_sysimg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
# Build a system image binary at sysimg_path.dlext. Allow insertion of a userimg via
# userimg_path. If sysimg_path.dlext is currently loaded into memory, don't continue
# unless force is set to true. Allow targeting of a CPU architecture via cpu_target
@unix_only function default_sysimg_path(debug=false)
splitext(Libdl.dlpath(debug ? "sys-debug" : "sys"))[1]
end

@windows_only function default_sysimg_path(debug=false)
joinpath(JULIA_HOME, "..", "lib", "julia", debug ? "sys-debug" : "sys")
function default_sysimg_path(debug=false)
if is_unix()
splitext(Libdl.dlpath(debug ? "sys-debug" : "sys"))[1]
else
joinpath(JULIA_HOME, "..", "lib", "julia", debug ? "sys-debug" : "sys")
end
end

function build_sysimg(sysimg_path=nothing, cpu_target="native", userimg_path=nothing; force=false, debug=false)
Expand Down Expand Up @@ -108,17 +108,19 @@ function find_system_compiler()
end

# On Windows, check to see if WinRPM is installed, and if so, see if gcc is installed
@windows_only try
eval(Main, :(using WinRPM))
winrpmgcc = joinpath(WinRPM.installdir,"usr","$(Sys.ARCH)-w64-mingw32",
"sys-root","mingw","bin","gcc.exe")
if success(`$winrpmgcc --version`)
return winrpmgcc
else
throw()
if is_windows()
try
eval(Main, :(using WinRPM))
winrpmgcc = joinpath(WinRPM.installdir,"usr","$(Sys.ARCH)-w64-mingw32",
"sys-root","mingw","bin","gcc.exe")
if success(`$winrpmgcc --version`)
return winrpmgcc
else
throw()
end
catch
warn("Install GCC via `Pkg.add(\"WinRPM\"); WinRPM.install(\"gcc\")` to generate sys.dll for faster startup times")
end
catch
warn("Install GCC via `Pkg.add(\"WinRPM\"); WinRPM.install(\"gcc\")` to generate sys.dll for faster startup times")
end


Expand All @@ -143,7 +145,9 @@ function link_sysimg(sysimg_path=nothing, cc=find_system_compiler(), debug=false

push!(FLAGS, "-shared")
push!(FLAGS, debug ? "-ljulia-debug" : "-ljulia")
@windows_only push!(FLAGS, "-lssp")
if is_windows()
push!(FLAGS, "-lssp")
end

info("Linking sys.$(Libdl.dlext)")
run(`$cc $FLAGS -o $sysimg_path.$(Libdl.dlext) $sysimg_path.o`)
Expand Down
57 changes: 33 additions & 24 deletions contrib/julia-config.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,71 +9,80 @@ const options =
];

function imagePath()
opts = Base.JLOptions();
String(opts.image_file);
opts = Base.JLOptions()
String(opts.image_file)
end

function libDir()
abspath(dirname(Libdl.dlpath("libjulia")));
abspath(dirname(Libdl.dlpath("libjulia")))
end

function includeDir()
joinpath(match(r"(.*)(bin)",JULIA_HOME).captures[1],"include","julia");
joinpath(match(r"(.*)(bin)",JULIA_HOME).captures[1],"include","julia")
end

function unixInitDir()
filePart = split(imagePath(),"/")[end]
return match(Regex("(.*)(/julia/$filePart)"),imagePath()).captures[1];
return match(Regex("(.*)(/julia/$filePart)"),imagePath()).captures[1]
end

function windowsInitDir()
if imagePath()[end-1:end] == "ji"
return match(r"(.*)(\\julia\\sys.ji)",imagePath()).captures[1];
return match(r"(.*)(\\julia\\sys.ji)",imagePath()).captures[1]
else
return match(r"(.*)(\\julia\\sys.dll)",imagePath()).captures[1];
return match(r"(.*)(\\julia\\sys.dll)",imagePath()).captures[1]
end
end

function initDir()
@unix_only return unixInitDir();
@windows_only return windowsInitDir();
if is_unix()
return unixInitDir()
else
return windowsInitDir()
end
end

function ldflags()
replace("""-L$(libDir())""","\\","\\\\");
replace("""-L$(libDir())""","\\","\\\\")
end

function ldlibs()
@unix_only return replace("""-Wl,-rpath,$(libDir()) -ljulia""","\\","\\\\");
@windows_only return replace("""-ljulia""","\\","\\\\");
if is_unix()
return replace("""-Wl,-rpath,$(libDir()) -ljulia""","\\","\\\\")
else
return replace("""-ljulia""","\\","\\\\")
end
end

function cflags()
arg1 = replace(initDir(),"\\","\\\\\\\\");
arg2 = replace(includeDir(),"\\","\\\\");
@unix_only return """-fPIC -DJULIA_INIT_DIR=\\"$arg1\\" -I$arg2""";
return """-DJULIA_INIT_DIR=\\"$arg1\\" -I$arg2""";
arg1 = replace(initDir(),"\\","\\\\\\\\")
arg2 = replace(includeDir(),"\\","\\\\")
if is_unix()
return """-fPIC -DJULIA_INIT_DIR=\\"$arg1\\" -I$arg2"""
else
return """-DJULIA_INIT_DIR=\\"$arg1\\" -I$arg2"""
end
end

function check_args(args)
checked = intersect(args,options);
checked = intersect(args,options)
if length(checked) == 0 || length(checked) != length(args)
println(STDERR,"Usage: julia-config [",reduce((x,y)->"$x|$y",options),"]");
exit(1);
println(STDERR,"Usage: julia-config [",reduce((x,y)->"$x|$y",options),"]")
exit(1)
end
end

function main()
check_args(ARGS);
check_args(ARGS)
for args in ARGS
if args == "--ldflags"
println(ldflags());
println(ldflags())
elseif args == "--cflags"
println(cflags());
println(cflags())
elseif args == "--ldlibs"
println(ldlibs());
println(ldlibs())
end
end
end

main();
main()
2 changes: 1 addition & 1 deletion test/perf/perfutil.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ end

function maxrss(name)
# FIXME: call uv_getrusage instead here
@linux_only begin
@static if is_linux()
rus = Array(Int64, div(144,8))
fill!(rus, 0x0)
res = ccall(:getrusage, Int32, (Int32, Ptr{Void}), 0, rus)
Expand Down

0 comments on commit 71a70db

Please sign in to comment.