Skip to content

Commit

Permalink
Merge pull request #48809 from ven-k/vkb/imageing-default
Browse files Browse the repository at this point in the history
Fix imaging value for generating sysimages for multiple targets
  • Loading branch information
staticfloat committed Apr 12, 2023
2 parents 1aa65c3 + acd51cf commit fc4b079
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
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

0 comments on commit fc4b079

Please sign in to comment.