-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce LLD_jll as stdlib #46455
Merged
Merged
Introduce LLD_jll as stdlib #46455
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hate that we have to duplicate this, but I understand why you're doing it.