Proposal to make functions in `julia-config.jl` and `build_sysimg.jl` reusable

proposal

#1

It would be useful to make some of the functions in julia-config.jl and build_sysimg.jl accessible and reusable by other scripts.

Some functions are for instance currently used by juliac.jl (see static-julia, which I am contributing to), but awkward code is needed to access them from outside the original scripts:

command = `$(Base.julia_cmd()) --startup-file=no $(joinpath(dirname(JULIA_HOME), "share", "julia", "julia-config.jl"))`
cflags = Base.shell_split(readstring(`$command --cflags`))
ldflags = Base.shell_split(readstring(`$command --ldflags`))
ldlibs = Base.shell_split(readstring(`$command --ldlibs`))

Here is in my opinion the list of functions in julia-config.jl and build_sysimg.jl which should be made reusable (maybe there are others as well):

  • cflags
  • ldflags
  • ldlibs
  • allflags
  • find_system_compiler

I would like to ask your opinion on this, and if you agree to ask suggestions on the best approach to follow. At present I would think to include them in a separate module (for instance BuildTools.jl), and then to make julia-config.jl and build_sysimg.jl (as well as other scripts such as juliac.jl) use that module. Moreover, as discussed here, julia-config.jl could be better renamed build_config.jl. In future, once juliac.jl is finalized, maybe also its main function julia_compile could be added to BuildTools.jl, so that it could be accessed and used programmatically by other scripts.