From d86285dba8b0e30faab777fde09734d1748647c2 Mon Sep 17 00:00:00 2001 From: Venkateshprasad <32921645+ven-k@users.noreply.github.com> Date: Mon, 27 Feb 2023 14:08:12 +0530 Subject: [PATCH 1/4] fix: return true while either generating the output "or" using pkgimages --- src/jitlayers.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jitlayers.h b/src/jitlayers.h index 1b62c87910a7f..cf160843710f5 100644 --- a/src/jitlayers.h +++ b/src/jitlayers.h @@ -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.use_pkgimages; } struct OptimizationOptions { From 4f4842c8896c774cd1ac5adbfea51c3a04671fa3 Mon Sep 17 00:00:00 2001 From: Venkateshprasad <32921645+ven-k@users.noreply.github.com> Date: Tue, 28 Feb 2023 15:26:50 +0530 Subject: [PATCH 2/4] test: pkgimages and object files with multiple cpu targets --- test/cmdlineargs.jl | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/test/cmdlineargs.jl b/test/cmdlineargs.jl index eafcb4ebe89d0..64d06d080659d 100644 --- a/test/cmdlineargs.jl +++ b/test/cmdlineargs.jl @@ -726,6 +726,42 @@ let exename = `$(Base.julia_cmd()) --startup-file=no --color=no` end end +let exename = `$(Base.julia_cmd(; cpu_target="native;native")) --startup-file=no --color=no` + # --pkgimages with multiple cpu targets + @testset let v = readchomperrors(`$exename --pkgimages=no`) + @test !v[1] + @test isempty(v[2]) + @test v[3] == "ERROR: More than one command line CPU targets specified without a `--output-` flag specified" + end + + @test readchomp(`$exename --pkgimages=yes -e ' + println("cpu_target = $(unsafe_string(Base.JLOptions().cpu_target)) and use_pkgimages = $(Base.JLOptions().use_pkgimages)")'`) == + "cpu_target = native;native and use_pkgimages = 1" +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 +end # Find the path of libjulia (or libjulia-debug, as the case may be) # to use as a dummy shlib to open From 3fa1bcbd7854647f6b753b649ce750fd429a3efc Mon Sep 17 00:00:00 2001 From: Elliot Saba Date: Tue, 11 Apr 2023 15:41:56 +0000 Subject: [PATCH 3/4] Incorporate review feedback --- src/jitlayers.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jitlayers.h b/src/jitlayers.h index cf160843710f5..d8c06df44176f 100644 --- a/src/jitlayers.h +++ b/src/jitlayers.h @@ -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 { From acd51cfd42b7a9a470c6c2bbf985ea5e8a955053 Mon Sep 17 00:00:00 2001 From: Elliot Saba Date: Tue, 11 Apr 2023 21:15:29 +0000 Subject: [PATCH 4/4] Adjust tests --- test/cmdlineargs.jl | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/test/cmdlineargs.jl b/test/cmdlineargs.jl index 64d06d080659d..903f6e0663b5d 100644 --- a/test/cmdlineargs.jl +++ b/test/cmdlineargs.jl @@ -726,19 +726,6 @@ let exename = `$(Base.julia_cmd()) --startup-file=no --color=no` end end -let exename = `$(Base.julia_cmd(; cpu_target="native;native")) --startup-file=no --color=no` - # --pkgimages with multiple cpu targets - @testset let v = readchomperrors(`$exename --pkgimages=no`) - @test !v[1] - @test isempty(v[2]) - @test v[3] == "ERROR: More than one command line CPU targets specified without a `--output-` flag specified" - end - - @test readchomp(`$exename --pkgimages=yes -e ' - println("cpu_target = $(unsafe_string(Base.JLOptions().cpu_target)) and use_pkgimages = $(Base.JLOptions().use_pkgimages)")'`) == - "cpu_target = native;native and use_pkgimages = 1" -end - # Object file with multiple cpu targets @testset "Object file for multiple microarchitectures" begin julia_path = joinpath(Sys.BINDIR, Base.julia_exename()) @@ -761,6 +748,14 @@ end @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)