Skip to content
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

Stdlib pkgimages seems to be compiled with generic target #54464

Closed
KristofferC opened this issue May 14, 2024 · 2 comments · Fixed by #54471
Closed

Stdlib pkgimages seems to be compiled with generic target #54464

KristofferC opened this issue May 14, 2024 · 2 comments · Fixed by #54471
Labels
compiler:precompilation Precompilation of modules pkgimage
Milestone

Comments

@KristofferC
Copy link
Member

Making this an issue so I can add it to the milestone:

julia> cd(joinpath(Sys.BINDIR, "../share/julia/compiled/v1.11/Test"))

julia> Base.parse_image_targets(Base.parse_cache_header("JfdTE_4EB71.ji")[7])
1-element Vector{Base.ImageTarget}:
 generic; flags=0; features_en=(cx16)

julia> VERSION
v"1.11.0-beta1"

Ref #54093

@KristofferC KristofferC added the compiler:precompilation Precompilation of modules label May 14, 2024
@KristofferC KristofferC added this to the 1.11 milestone May 14, 2024
@giordano
Copy link
Contributor

giordano commented May 14, 2024

I believe the problem is more general than stdlibs, it looks like setting JULIA_CPU_TARGET always results in compiling code only for the generic target, if we can trust the parsing done by Base.parse_image_targets and Base.parse_cache_header. Consider this script

# Cleanup Example precompile dir
example_dir = joinpath(first(Base.DEPOT_PATH), "compiled", "v$(Base.thisminor(Base.VERSION))"[begin:end-2], "Example")
rm(example_dir; force=true, recursive=true)

# Install Example
using Pkg
Pkg.activate(; temp=true, io=devnull)
Pkg.add("Example"; io=stdout)

# Find compile cache
pkg = Base.identify_package("Example")
cachefiles = Base.find_all_in_cache_path(pkg)
isempty(cachefiles) && error(pkg, " has not yet been precompiled for julia ", Base.VERSION, ". Reinstall the package with `Pkg.add(\"Example\"; io=stdout)` to see why")
pkgpath = Base.locate_package(pkg)
idx = findfirst(cachefiles) do cf
    Base.stale_cachefile(pkgpath, cf) !== true
end
targets = Base.parse_image_targets(Base.parse_cache_header(cachefiles[idx])[7])
# Show target
@show targets

With Julia v1.10.3 I get

% julia example_targets.jl 
targets = Base.ImageTarget[haswell; flags=0; features_en=(sse3, pclmul, ssse3, fma, cx16, sse4.1, sse4.2, movbe, popcnt, aes, xsave, avx, f16c, fsgsbase, bmi, avx2, bmi2, sahf, lzcnt)]
% JULIA_CPU_TARGET='generic;sandybridge,-xsaveopt,clone_all;haswell,-rdrnd,base(1);x86-64-v4,-rdrnd,base(1)' julia example_targets.jl 
targets = Base.ImageTarget[generic; flags=0; features_en=(cx16)]

Moreover, shuffling the targets:

% JULIA_CPU_TARGET='sandybridge,-xsaveopt,clone_all;generic;haswell,-rdrnd,base(0);x86-64-v4,-rdrnd,base(0)' julia example_targets.jl 
targets = Base.ImageTarget[sandybridge; flags=0; features_en=(sse3, pclmul, ssse3, cx16, sse4.1, sse4.2, popcnt, xsave, avx, sahf)]

So we always compile only for the first target of the list, whatever that is.

CC: @gbaraldi @vchuravy @timholy.

@KristofferC
Copy link
Member Author

That's not too surprising since stdlibs are compiled identically to normal packages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:precompilation Precompilation of modules pkgimage
Projects
None yet
2 participants