How to detect whether the build (compiler options) is a production build

nsajko
Sat, 04 May 2024 12:05:34 +0000
General Usage

Enabling code coverage changes how Julia code is compiled and executed. In particular, code coverage may cause allocations in code that would otherwise be constant-folded:

github.com/JuliaLang/julia

Effects on master are influenced by generation of coverage data

opened 02:57PM - 28 May 23 UTC

Seelengrab

effects code coverage

Found while debugging the failures of [FieldFlags.jl](https://github.com/Seeleng…rab/FieldFlags.jl/actions/runs/5104788857/jobs/9175949759#step:6:108) on nightly - the tests run fine on 1.9, haven't yet tried to bisect. Since it's not (yet) through its registration period, you'll have to `]add` the github repo directly for reproducing. Either way, the failures are reproducible with ``` julia --color=yes --project=. -e 'import Pkg; Pkg.test(;coverage=true)' ``` but not with ``` julia --color=yes --project=. -e 'import Pkg; Pkg.test(;coverage=false)' ``` which make the tests run through. I'll see if I can minimize the failure a bit more. EDIT: For posteriority, a smaller MWE without dependencies: ```julia [sukera@tower ~]$ julia --code-coverage -q julia> h(x) = iseven(x) ? "string" : 1 h (generic function with 1 method) julia> g() = h(2) g (generic function with 1 method) julia> Base.infer_effects(g,()) (+c,!e,+n,+t,+s,+m,+i) ``` ```julia [sukera@tower ~]$ julia -q julia> h(x) = iseven(x) ? "string" : 1 h (generic function with 1 method) julia> g() = h(2) g (generic function with 1 method) julia> Base.infer_effects(g,()) (+c,+e,+n,+t,+s,+m,+i) ```

On the other hand, it’s sometimes good to have tests in a package’s testsuite to check whether certain calls allocate or not. It seems these tests need to be disabled while coverage is enabled.

But how to detect whether coverage is enabled?

4 posts - 2 participants