Skip to content
5 changes: 2 additions & 3 deletions .ci/run_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ end

proj = abspath(joinpath(@__DIR__, ".."))
cmd = """Base.runtests(["LinearAlgebra"]; propagate_project=true, ncores=$ncores)"""
withenv("JULIA_NUM_THREADS" => 1) do
run(`$(Base.julia_cmd()) --project=$proj --compiled-modules=existing -e $cmd`)
end
run(addenv(`$(Base.julia_cmd()) --project=$proj --compiled-modules=existing -e $cmd`,
"JULIA_NUM_THREADS" => 1, "JULIA_PRUNE_OLD_LA" => true))
31 changes: 29 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,37 @@ This package performs some type piracy and is also included in the sysimage, whi
To use a development version of this package, you can choose one of the following methods:

1. **Change the UUID in the project file and load the package:**
This approach will produce warnings and may lead to method ambiguities between the development version and the one in the sysimage, but it can be used for basic experimentation.

Change the UUID line in `Project.toml` as
```diff
- uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
+ uuid = "27e2e46d-f89d-539d-b4ee-838fcccc9c8e"
```

Start `julia` as
```console
JULIA_PRUNE_OLD_LA=true julia +nightly --compiled-modules=existing --project
```
where it is assumed that one is already within the `LinearAlgebra` directory (otherwise, adjust
the project path accordingly). The `julia +nightly` command above assumes that `juliaup` is being used
to launch `julia`, but one may substitute this with the path to the julia executable.

Within the `julia` session, load the `LinearAlgebra` module after pruning the one in the sysimage. This may be done as
```julia
include("test/prune_old_LA.jl") && using LinearAlgebra
```

Note that loading the test files in the REPL will automatically carry out the pruning to ensure that the development version of the package is used in the tests.

If you are contributing to the repo using this method, it may be convenient to ignore the local changes to `Project.toml` by running
```console
git update-index --skip-worktree Project.toml
```

2. **Build Julia with the custom `LinearAlgebra` commit:**
Modify the commit in `stdlib/LinearAlgebra.version` and build Julia.

Modify the commit in [`stdlib/LinearAlgebra.version`](https://github.com/JuliaLang/julia/blob/master/stdlib/LinearAlgebra.version) and build Julia. This requires one to push the development branch
to `GitHub` or an equivalent platform.

3. **Build a custom sysimage with the new `LinearAlgebra`:**
- Install `PackageCompiler`.
Expand Down
4 changes: 3 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
include("../test/prune_old_LA.jl")
withenv("JULIA_PRUNE_OLD_LA" => "true") do
include("../test/prune_old_LA.jl")
end

using LinearAlgebra
using Documenter: DocMeta, makedocs, deploydocs, HTML
Expand Down
6 changes: 6 additions & 0 deletions test/bitarray.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

module TestBitArray

isdefined(Main, :pruned_old_LA) || @eval Main include("prune_old_LA.jl")

using LinearAlgebra, Test, Random
Expand Down Expand Up @@ -95,3 +99,5 @@ b2 = bitrand(v1)

b1 = bitrand(n1, n1)
@check_bit_operation diag(b1)

end # module
118 changes: 64 additions & 54 deletions test/prune_old_LA.jl
Original file line number Diff line number Diff line change
@@ -1,56 +1,58 @@
methods_to_delete =
[
:adjoint
:transpose
:inv
:literal_pow
:\
:/
:isapprox
:copyto!
:*
:muladd
:copyto!
:isone
:kron!
:kron
:^
:exp
:cis
:log
:sqrt
:cbrt
:inv
:cos
:sin
:sincos
:tan
:cosh
:sinh
:tanh
:acos
:asin
:atan
:acosh
:asinh
:atanh
:sec
:sech
:csc
:csch
:cot
:coth
:asec
:asech
:acsc
:acot
:acoth
:acsch
]

let
LA = get(Base.loaded_modules, Base.PkgId(Base.UUID("37e2e46d-f89d-539d-b4ee-838fcccc9c8e"), "LinearAlgebra"), nothing)
if LA !== nothing
methods_to_delete =
[
:adjoint
:transpose
:inv
:literal_pow
:\
:/
:isapprox
:copyto!
:*
:muladd
:copyto!
:isone
:kron!
:kron
:^
:exp
:cis
:log
:sqrt
:cbrt
:inv
:cos
:sin
:sincos
:tan
:cosh
:sinh
:tanh
:acos
:asin
:atan
:acosh
:asinh
:atanh
:sec
:sech
:csc
:csch
:cot
:coth
:asec
:asech
:acsc
:acot
:acoth
:acsch
]

prune_old_LA = parse(Bool, get(ENV, "JULIA_PRUNE_OLD_LA", "false"))
LinalgSysImg = Base.PkgId(Base.UUID("37e2e46d-f89d-539d-b4ee-838fcccc9c8e"), "LinearAlgebra")
LA = get(Base.loaded_modules, LinalgSysImg, nothing)
if LA !== nothing && prune_old_LA
@assert hasmethod(*, Tuple{Matrix{Float64}, Matrix{Float64}})
for methss in methods_to_delete
meths = getglobal(Base, methss)
Expand All @@ -61,9 +63,17 @@ let
end
end
end
Base.unreference_module(Base.PkgId(Base.UUID("37e2e46d-f89d-539d-b4ee-838fcccc9c8e"), "LinearAlgebra"))
end

@assert !hasmethod(*, Tuple{Matrix{Float64}, Matrix{Float64}})
# check in a separate block to ensure that the latest world age is used
let
prune_old_LA = parse(Bool, get(ENV, "JULIA_PRUNE_OLD_LA", "false"))
LinalgSysImg = Base.PkgId(Base.UUID("37e2e46d-f89d-539d-b4ee-838fcccc9c8e"), "LinearAlgebra")
LA = get(Base.loaded_modules, LinalgSysImg, nothing)
if LA !== nothing && prune_old_LA
@assert !hasmethod(*, Tuple{Matrix{Float64}, Matrix{Float64}})
end
prune_old_LA && Base.unreference_module(LinalgSysImg)
end

pruned_old_LA = true