Skip to content

Commit 01ec06a

Browse files
authored
be more correct when it comes to env handling (#338)
1 parent c45639a commit 01ec06a

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

src/PackageCompiler.jl

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ function move_default_sysimage_if_windows()
6767
end
6868
end
6969

70-
function windows_compiler_artifact_path(f, compiler)
70+
function run_with_env(cmd, compiler)
7171
if Sys.iswindows()
72-
withenv("PATH" => string(ENV["PATH"], ";", dirname(compiler))) do
73-
f()
74-
end
72+
env = copy(ENV)
73+
env["PATH"] = string(env["PATH"], ";", dirname(compiler))
74+
run(Cmd(cmd; env=env))
7575
else
76-
f()
76+
run(cmd)
7777
end
7878
end
7979

@@ -441,9 +441,7 @@ function create_sysimg_from_object_file(input_object::String, sysimage_path::Str
441441
m = something(march(), ``)
442442
cmd = `$compiler $(bitflag()) $m -shared -L$(julia_libdir) -o $sysimage_path $o_file -ljulia $extra`
443443
@debug "running $cmd"
444-
windows_compiler_artifact_path(compiler) do
445-
run(cmd)
446-
end
444+
run_with_env(cmd, compiler)
447445
return nothing
448446
end
449447

@@ -646,10 +644,7 @@ function create_executable_from_sysimg(;sysimage_path::String,
646644
m = something(march(), ``)
647645
cmd = `$compiler -DJULIAC_PROGRAM_LIBNAME=$(repr(sysimage_path)) $(bitflag()) $m -o $(executable_path) $(wrapper) $(sysimage_path) -O2 $rpath $flags`
648646
@debug "running $cmd"
649-
run(cmd)
650-
windows_compiler_artifact_path(compiler) do
651-
run(cmd)
652-
end
647+
run_with_env(cmd, compiler)
653648
return nothing
654649
end
655650

0 commit comments

Comments
 (0)