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

Fix imaging value for generating sysimages for multiple targets #48809

Merged
merged 4 commits into from
Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/jitlayers.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ GlobalVariable *jl_emit_RTLD_DEFAULT_var(Module *M) JL_NOTSAFEPOINT;
DataLayout jl_create_datalayout(TargetMachine &TM) JL_NOTSAFEPOINT;

static inline bool imaging_default() JL_NOTSAFEPOINT {
return jl_options.image_codegen || (jl_generating_output() && jl_options.use_pkgimages);
return jl_options.image_codegen || (jl_generating_output() && (!jl_options.incremental || jl_options.use_pkgimages));
}

struct OptimizationOptions {
Expand Down
31 changes: 31 additions & 0 deletions test/cmdlineargs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,37 @@ let exename = `$(Base.julia_cmd()) --startup-file=no --color=no`
end
end

# Object file with multiple cpu targets
@testset "Object file for multiple microarchitectures" begin
julia_path = joinpath(Sys.BINDIR, Base.julia_exename())
outputo_file = tempname()
write(outputo_file, "1")
object_file = tempname() * ".o"

# This is to test that even with `pkgimages=no`, we can create object file
# with multiple cpu-targets
# The cmd is checked for `--object-o` as soon as it is run. So, to avoid long
# testing times, intentionally don't pass `--sysimage`; when we reach the
# corresponding error, we know that `check_cmdline` has already passed
let v = readchomperrors(`$julia_path
--cpu-target='native;native'
--output-o=$object_file $outputo_file
--pkgimages=no`)

@test v[1] == false
@test v[2] == ""
@test !contains(v[3], "More than one command line CPU targets specified")
@test v[3] == "ERROR: File \"boot.jl\" not found"
end

# This is to test that with `pkgimages=yes`, multiple CPU targets are parsed.
# We intentionally fail fast due to a lack of an `--output-o` flag.
let v = readchomperrors(`$julia_path --cpu-target='native;native' --pkgimages=yes`)
@test v[1] == false
@test v[2] == ""
@test contains(v[3], "More than one command line CPU targets specified")
end
end

# Find the path of libjulia (or libjulia-debug, as the case may be)
# to use as a dummy shlib to open
Expand Down