JuliaLang / PackageCompiler.jl

Compile your Julia Package
https://julialang.github.io/PackageCompiler.jl/dev/
MIT License
1.42k stars 189 forks source link

compiling app using v2.1.10 on Windows requires Admin privileges #866

Closed ctarn closed 11 months ago

ctarn commented 1 year ago

This issue is split from #864. I failed to compile a mini app using v2.1.10 on Windows, which reports requiring Admin privileges. Running as admin can solve it. However, the privileges are not always available, and thus it would be great to remove the requirement.

versioninfo

julia> versioninfo()
Julia Version 1.9.3
Commit bed2cd540a (2023-08-24 14:43 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 4 × Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, skylake)
  Threads: 1 on 4 virtual cores

error log

C:\Users\i\tmp>julia --project=.
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.9.3 (2023-08-24)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

(MiniApp) pkg> add PackageCompiler@2.1.10
   Resolving package versions...
    Updating `C:\Users\i\tmp\Project.toml`
  [9b87118b] + PackageCompiler v2.1.10
    Updating `C:\Users\i\tmp\Manifest.toml`
  [c27321d9] + Glob v1.3.1
  [9b87118b] + PackageCompiler v2.1.10
  [05181044] + RelocatableFolders v1.0.1
  [6c6a2e73] + Scratch v1.2.0
  [0dad84c5] + ArgTools v1.1.1
  [56f22d72] + Artifacts
  [2a0f44e3] + Base64
  [ade2ca70] + Dates
  [f43a241f] + Downloads v1.6.0
  [7b1f6079] + FileWatching
  [b77e0a4c] + InteractiveUtils
  [4af54fe1] + LazyArtifacts
  [b27032c2] + LibCURL v0.6.3
  [76f85450] + LibGit2
  [8f399da3] + Libdl
  [56ddb016] + Logging
  [d6f4376e] + Markdown
  [ca575930] + NetworkOptions v1.2.0
  [44cfe95a] + Pkg v1.9.2
  [de0858da] + Printf
  [3fa0cd96] + REPL
  [9a3f8284] + Random
  [ea8e919c] + SHA v0.7.0
  [9e88b42a] + Serialization
  [6462fe0b] + Sockets
  [fa267f1f] + TOML v1.0.3
  [a4e569a6] + Tar v1.10.0
  [cf7118a7] + UUIDs
  [4ec0a83e] + Unicode
  [deac9b47] + LibCURL_jll v7.84.0+0
  [29816b5a] + LibSSH2_jll v1.10.2+0
  [c8ffd9c3] + MbedTLS_jll v2.28.2+0
  [14a3606d] + MozillaCACerts_jll v2022.10.11
  [83775a58] + Zlib_jll v1.2.13+0
  [8e850ede] + nghttp2_jll v1.48.0+0
  [3f19e933] + p7zip_jll v17.4.0+0

julia> import PackageCompiler

julia> PackageCompiler.create_app(".", "build.tmp", force=true)
PackageCompiler: bundled libraries:
  ├── Base:
  │    ├── libLLVM-14jl.dll - 109.118 MiB
  │    ├── libatomic-1.dll - 269.943 KiB
  │    ├── libdSFMT.dll - 117.661 KiB
  │    ├── libgcc_s_seh-1.dll - 676.965 KiB
  │    ├── libgfortran-5.dll - 11.193 MiB
  │    ├── libgmp-10.dll - 1.070 MiB
  │    ├── libgmp.dll - 1.070 MiB
  │    ├── libgmpxx-4.dll - 321.332 KiB
  │    ├── libgmpxx.dll - 321.332 KiB
  │    ├── libgomp-1.dll - 1.439 MiB
  │    ├── libjulia-codegen.dll - 90.539 MiB
  │    ├── libjulia-internal.dll - 12.243 MiB
  │    ├── libmpfr-6.dll - 2.355 MiB
  │    ├── libmpfr.dll - 2.355 MiB
  │    ├── libopenlibm.dll - 369.265 KiB
  │    ├── libpcre2-16-0.dll - 697.275 KiB
  │    ├── libpcre2-16.dll - 697.275 KiB
  │    ├── libpcre2-32-0.dll - 668.666 KiB
  │    ├── libpcre2-32.dll - 668.666 KiB
  │    ├── libpcre2-8-0.dll - 759.307 KiB
  │    ├── libpcre2-8.dll - 759.307 KiB
  │    ├── libpcre2-posix-3.dll - 112.437 KiB
  │    ├── libquadmath-0.dll - 1.169 MiB
  │    ├── libssp-0.dll - 152.373 KiB
  │    ├── libstdc++-6.dll - 22.621 MiB
  │    ├── libuv-2.dll - 947.011 KiB
  │    ├── libwinpthread-1.dll - 330.251 KiB
  │    ├── libz.dll - 217.723 KiB
ERROR: IOError: On Windows, creating symlinks requires Administrator privileges.
symlink("libstdc++-6.dll", "build.tmp\\bin\\libstdc++.dll"): operation not permitted (EPERM)
Stacktrace:
 [1] uv_error
   @ .\libuv.jl:100 [inlined]
 [2] symlink(target::String, link::String; dir_target::Bool)
   @ Base.Filesystem .\file.jl:1106
 [3] symlink
   @ .\file.jl:1068 [inlined]
 [4] bundle_julia_libraries(dest_dir::String, stdlibs::Vector{String})
   @ PackageCompiler C:\Users\i\.julia\packages\PackageCompiler\LLlSZ\src\PackageCompiler.jl:1297
 [5] create_app(package_dir::String, app_dir::String; executables::Nothing, precompile_execution_file::Vector{String}, precompile_statements_file::Vector{String}, incremental::Bool, filter_stdlibs::Bool, force::Bool, c_driver_program::String, cpu_target::String, include_lazy_artifacts::Bool, sysimage_build_args::Cmd, include_transitive_dependencies::Bool, include_preferences::Bool, script::Nothing)
   @ PackageCompiler C:\Users\i\.julia\packages\PackageCompiler\LLlSZ\src\PackageCompiler.jl:826
 [6] top-level scope
   @ REPL[3]:1
sloede commented 12 months ago

I agree, this is annoying. I will take a look at it (since it being it my fault), however, it might take me some time to get to it.

In the meantime, I think it should suffice for you to put the lines https://github.com/JuliaLang/PackageCompiler.jl/blob/846292c50a7177ea27f1fdb607be8c42174e030e/src/PackageCompiler.jl#L1291-L1298 inside an

if !Sys.iswindows()
    ...
end

block to guard against this behavior.

Eventually, I think the right choice would be to do this library selection woopla for libstdc++ only on Linux systems, since this is the only OS for which this fancy libstdc++ loading is used in Julia.

maximilianluc commented 12 months ago

Also facing this issue. Thanks @sloede, also for the possible workaround. I'll give it a try!

YuliyaCl commented 11 months ago

Hi Facing this issue too. Hope it will be fixed soon !

sloede commented 11 months ago

I've implemented a potential solution in #869. It would be great if you could confirm that this PR fixes your issue.

ThummeTo commented 11 months ago

Hi,

because of this issue, v2.1.10 is a breaking release under Windows causing issues with other libraries like in my case FMIExport.jl. Could this please be fixed by (a) revoking the release and release as breaking v2.2.0 or (b) deploying a fixing patch v2.1.11 in the near future?

That would be great. Thanks in advance!

sloede commented 11 months ago

@ThummeTo Since I do not have a Windows system with which to reproduce this error, it would be great if you could confirm that #869 fixes the issue. If yes, I could merge #869 and create a new release.

ThummeTo commented 11 months ago

Deal! I will check for that, just need a few minutes...

ThummeTo commented 11 months ago

This solves the issue for me on windows! (however, I run into #873 - but this is another story)

sloede commented 11 months ago

v2.1.11 was just tagged, which should fix the Windows issues. It would be great if someone who reported the issue here could confirm that it is done.

ThummeTo commented 11 months ago

I can confirm that v2.1.11 solves this issue on my machine (Win10, Julia 1.9.3)!

sloede commented 11 months ago

Thanks!