diff --git a/.ci/run_tests.jl b/.ci/run_tests.jl index 8a54ef62..879b73b1 100644 --- a/.ci/run_tests.jl +++ b/.ci/run_tests.jl @@ -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)) diff --git a/README.md b/README.md index a39a7248..c0951dcc 100644 --- a/README.md +++ b/README.md @@ -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`. diff --git a/docs/make.jl b/docs/make.jl index a1d3a2d0..0f8b79d9 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -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 diff --git a/test/bitarray.jl b/test/bitarray.jl index a185873e..10b9d4b8 100644 --- a/test/bitarray.jl +++ b/test/bitarray.jl @@ -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 @@ -95,3 +99,5 @@ b2 = bitrand(v1) b1 = bitrand(n1, n1) @check_bit_operation diag(b1) + +end # module diff --git a/test/prune_old_LA.jl b/test/prune_old_LA.jl index f628cddf..7e64cfa3 100644 --- a/test/prune_old_LA.jl +++ b/test/prune_old_LA.jl @@ -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) @@ -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