From 71a70dbe2ddea48a2a93282802d0fdfd18c69f41 Mon Sep 17 00:00:00 2001 From: Tony Kelman Date: Fri, 20 May 2016 17:04:22 -0700 Subject: [PATCH] contrib and test/perf cleanup for #16219 --- contrib/BBEditTextWrangler-julia.plist | 21 +++------- contrib/build_sysimg.jl | 38 +++++++++-------- contrib/julia-config.jl | 57 +++++++++++++++----------- test/perf/perfutil.jl | 2 +- 4 files changed, 61 insertions(+), 57 deletions(-) diff --git a/contrib/BBEditTextWrangler-julia.plist b/contrib/BBEditTextWrangler-julia.plist index b4c88a9ccfc55..8dac9555ff0a1 100644 --- a/contrib/BBEditTextWrangler-julia.plist +++ b/contrib/BBEditTextWrangler-julia.plist @@ -75,15 +75,10 @@ @ip_str @label @less - @linux - @linux_only @math_const @MIME @MIME_str @noinline - @non_windowsxp_only - @osx - @osx_only @parallel @printf @profile @@ -95,6 +90,7 @@ @spawn @spawnat @sprintf + @static @sync @task @text_str @@ -104,15 +100,10 @@ @timev @uint128_str @unexpected - @unix - @unix_only @v_str @vectorize_1arg @vectorize_2arg @which - @windows - @windows_only - @windowsxp_only \ ^ __precompile__ @@ -588,12 +579,12 @@ ipermutedims irfft iround + is_apple is_assigned_char - is_valid_ascii - is_valid_char - is_valid_utf16 - is_valid_utf32 - is_valid_utf8 + is_bsd + is_linux + is_unix + is_windows isabspath isalnum isalpha diff --git a/contrib/build_sysimg.jl b/contrib/build_sysimg.jl index c281345ce9483..0d5ee14eba250 100644 --- a/contrib/build_sysimg.jl +++ b/contrib/build_sysimg.jl @@ -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) @@ -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 @@ -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`) diff --git a/contrib/julia-config.jl b/contrib/julia-config.jl index a5b2fc1c54b27..203e46e2549d8 100755 --- a/contrib/julia-config.jl +++ b/contrib/julia-config.jl @@ -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() diff --git a/test/perf/perfutil.jl b/test/perf/perfutil.jl index ea7957d4677ec..c10650bc1c06d 100644 --- a/test/perf/perfutil.jl +++ b/test/perf/perfutil.jl @@ -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)