forked from JuliaLang/julia
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce LLD_jll as stdlib (JuliaLang#46455)
* Introduce LLD_jll to stdlib * Add symlinks to lld to libexecdir * Allow to compile LLD from source (during LLVM compilation) + remove symlinks * Fix directory of libraries for Windows
- Loading branch information
Showing
9 changed files
with
167 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name = "LLD_jll" | ||
uuid = "d55e3150-da41-5e91-b323-ecfd1eec6109" | ||
version = "14.0.5+3" | ||
|
||
[deps] | ||
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" | ||
Zlib_jll = "83775a58-1f1d-513f-b197-d71354ab007a" | ||
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb" | ||
TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76" | ||
libLLVM_jll = "8f36deef-c2a5-5394-99ed-8e07531fb29a" | ||
Artifacts = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" | ||
|
||
[compat] | ||
julia = "1.9" | ||
libLLVM_jll = "14.0.5" | ||
|
||
[extras] | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
|
||
[targets] | ||
test = ["Test"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
|
||
# This file is a part of Julia. License is MIT: https://julialang.org/license | ||
|
||
## dummy stub for https://github.com/JuliaBinaryWrappers/LLD_jll.jl | ||
|
||
baremodule LLD_jll | ||
using Base, Libdl | ||
Base.Experimental.@compiler_options compile=min optimize=0 infer=false | ||
|
||
const PATH_list = String[] | ||
const LIBPATH_list = String[] | ||
|
||
export lld | ||
|
||
# These get calculated in __init__() | ||
const PATH = Ref("") | ||
const LIBPATH = Ref("") | ||
artifact_dir = "" | ||
lld_path = "" | ||
if Sys.iswindows() | ||
const lld_exe = "lld.exe" | ||
else | ||
const lld_exe = "lld" | ||
end | ||
|
||
if Sys.iswindows() | ||
const LIBPATH_env = "PATH" | ||
const LIBPATH_default = "" | ||
const pathsep = ';' | ||
elseif Sys.isapple() | ||
const LIBPATH_env = "DYLD_FALLBACK_LIBRARY_PATH" | ||
const LIBPATH_default = "~/lib:/usr/local/lib:/lib:/usr/lib" | ||
const pathsep = ':' | ||
else | ||
const LIBPATH_env = "LD_LIBRARY_PATH" | ||
const LIBPATH_default = "" | ||
const pathsep = ':' | ||
end | ||
|
||
function adjust_ENV!(env::Dict, PATH::String, LIBPATH::String, adjust_PATH::Bool, adjust_LIBPATH::Bool) | ||
if adjust_LIBPATH | ||
LIBPATH_base = get(env, LIBPATH_env, expanduser(LIBPATH_default)) | ||
if !isempty(LIBPATH_base) | ||
env[LIBPATH_env] = string(LIBPATH, pathsep, LIBPATH_base) | ||
else | ||
env[LIBPATH_env] = LIBPATH | ||
end | ||
end | ||
if adjust_PATH && (LIBPATH_env != "PATH" || !adjust_LIBPATH) | ||
if adjust_PATH | ||
if !isempty(get(env, "PATH", "")) | ||
env["PATH"] = string(PATH, pathsep, env["PATH"]) | ||
else | ||
env["PATH"] = PATH | ||
end | ||
end | ||
end | ||
return env | ||
end | ||
|
||
function lld(f::Function; adjust_PATH::Bool = true, adjust_LIBPATH::Bool = true) | ||
env = adjust_ENV!(copy(ENV), PATH[], LIBPATH[], adjust_PATH, adjust_LIBPATH) | ||
withenv(env...) do | ||
return f(lld_path) | ||
end | ||
end | ||
function lld(; adjust_PATH::Bool = true, adjust_LIBPATH::Bool = true) | ||
env = adjust_ENV!(copy(ENV), PATH[], LIBPATH[], adjust_PATH, adjust_LIBPATH) | ||
return Cmd(Cmd([lld_path]); env) | ||
end | ||
|
||
function init_lld_path() | ||
# Prefer our own bundled lld, but if we don't have one, pick it up off of the PATH | ||
# If this is an in-tree build, `lld` will live in `tools`. Otherwise, it'll be in `libexec` | ||
for bundled_lld_path in (joinpath(Sys.BINDIR, Base.LIBEXECDIR, lld_exe), | ||
joinpath(Sys.BINDIR, "..", "tools", lld_exe), | ||
joinpath(Sys.BINDIR, lld_exe)) | ||
if isfile(bundled_lld_path) | ||
global lld_path = abspath(bundled_lld_path) | ||
return | ||
end | ||
end | ||
global lld_path = something(Sys.which(lld_exe), lld_exe) | ||
end | ||
|
||
function __init__() | ||
global artifact_dir = dirname(Sys.BINDIR) | ||
init_lld_path() | ||
PATH[] = dirname(lld_path) | ||
push!(PATH_list, PATH[]) | ||
if Sys.iswindows() | ||
# On windows, the dynamic libraries (.dll) are in Sys.BINDIR ("usr\\bin") | ||
append!(LIBPATH_list, [joinpath(Sys.BINDIR, Base.LIBDIR, "julia"), Sys.BINDIR]) | ||
else | ||
append!(LIBPATH_list, [joinpath(Sys.BINDIR, Base.LIBDIR, "julia"), joinpath(Sys.BINDIR, Base.LIBDIR)]) | ||
end | ||
LIBPATH[] = join(LIBPATH_list, pathsep) | ||
end | ||
|
||
# JLLWrappers API compatibility shims. Note that not all of these will really make sense. | ||
# For instance, `find_artifact_dir()` won't actually be the artifact directory, because | ||
# there isn't one. It instead returns the overall Julia prefix. | ||
is_available() = true | ||
find_artifact_dir() = artifact_dir | ||
dev_jll() = error("stdlib JLLs cannot be dev'ed") | ||
best_wrapper = nothing | ||
|
||
end # module libLLD_jll |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# This file is a part of Julia. License is MIT: https://julialang.org/license | ||
|
||
using Test, Libdl, LLD_jll | ||
|
||
@testset "LLD_jll" begin | ||
@test isfile(LLD_jll.lld_path) | ||
flavor = Sys.isapple() ? "darwin" : (Sys.iswindows() ? "link" : "gnu") | ||
@test success(`$(LLD_jll.lld()) -flavor $flavor --version`) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters