Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions src/static_julia.jl
Original file line number Diff line number Diff line change
Expand Up @@ -122,33 +122,38 @@ function julia_compile(
math_mode, depwarn
)

shared && build_shared(s_file, joinpath(tmp_dir, o_file), verbose)
shared && build_shared(s_file, joinpath(tmp_dir, o_file), verbose, optimize, debug)

executable && compile_executable(s_file, e_file, cprog, verbose)
executable && compile_executable(s_file, e_file, cprog, verbose, optimize, debug)

julialibs && sync_julia_files(verbose)

end


function julia_flags()
function julia_flags(optimize, debug)
if julia_v07
command = `$(Base.julia_cmd()) --startup-file=no $(joinpath(dirname(Sys.BINDIR), "share", "julia", "julia-config.jl"))`
return `$(Base.shell_split(read(\`$command --allflags\`, String)))`
flags = `$(Base.shell_split(read(\`$command --allflags\`, String)))`
optimize == nothing || (flags = `$flags -O$optimize`)
debug != 2 || (flags = `$flags -g`)
return flags
else
command = `$(Base.julia_cmd()) --startup-file=no $(joinpath(dirname(JULIA_HOME), "share", "julia", "julia-config.jl"))`
cflags = `$(Base.shell_split(readstring(\`$command --cflags\`)))`
optimize == nothing || (cflags = `$cflags -O$optimize`)
debug != 2 || (cflags = `$cflags -g`)
ldflags = `$(Base.shell_split(readstring(\`$command --ldflags\`)))`
ldlibs = `$(Base.shell_split(readstring(\`$command --ldlibs\`)))`
return `$cflags $ldflags $ldlibs`
end
end


function build_shared(s_file, o_file, verbose = false)
function build_shared(s_file, o_file, verbose = false, optimize, debug)
cc = system_compiler()
bitness = bitness_flag()
flags = julia_flags()
flags = julia_flags(optimize, debug)
command = `$cc $bitness -shared -o $s_file $o_file $flags`
if isapple()
command = `$command -Wl,-install_name,@rpath/$s_file`
Expand All @@ -160,10 +165,10 @@ function build_shared(s_file, o_file, verbose = false)
end


function compile_executable(s_file, e_file, cprog, verbose = false)
function compile_executable(s_file, e_file, cprog, verbose = false, optimize, debug)
bitness = bitness_flag()
cc = system_compiler()
flags = julia_flags()
flags = julia_flags(optimize, debug)
command = `$cc $bitness -DJULIAC_PROGRAM_LIBNAME=\"$s_file\" -o $e_file $cprog $s_file $flags`
if iswindows()
RPMbindir = PackageCompiler.mingw_dir("bin")
Expand Down