# PackageCompiler.jl cannot create a sysimage with CUDA

**URL:** <https://discourse.julialang.org/t/packagecompiler-jl-cannot-create-a-sysimage-with-cuda/123019>\
**Category:** General Usage\
**Created:** [November 24, 2024, 3:56pm UTC](https://discourse.julialang.org/t/packagecompiler-jl-cannot-create-a-sysimage-with-cuda/123019 "2024-11-24T15:56:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abhro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abhro/32/220753_2.png) [@Abhro](https://discourse.julialang.org/u/Abhro)\
**Post date:** [November 24, 2024, 3:56pm UTC](https://discourse.julialang.org/t/packagecompiler-jl-cannot-create-a-sysimage-with-cuda/123019/1 "2024-11-24T15:56:33Z")

</div>

The compilation fails during linking BFloat16s.jl with g++. The full text of a minimal working example is available on [GitHub Gist](https://gist.github.com/abhro/3e17c9ee109f7519aaab43cc7f1efd13), and a truncated version is presented below:

```julia-repl
julia> versioninfo()
Julia Version 1.11.1
Commit 8f5b7ca12a (2024-10-16 10:53 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 32 × 13th Gen Intel(R) Core(TM) i9-13900K
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, alderlake)
Threads: 1 default, 0 interactive, 1 GC (on 32 virtual cores)

pkg> activate --temp

pkg> add CUDA PackageCompiler
   Resolving package versions...
    Updating `$HOME\AppData\Local\Temp\jl_W5DHw4\Project.toml`
  [052768ef] + CUDA v5.5.2
  [9b87118b] + PackageCompiler v2.1.24
[...]

julia> using PackageCompiler

julia> create_sysimage(["CUDA"], sysimage_path = "CUDA.jl-sysimage.dll")
[...]
$HOME\AppData\Local\Temp\jl_ZA7qvMLupC-o.a(text#0.o): In function `BFloat16':
$HOME\.julia\packages\BFloat16s\u3WQc\src/bfloat16.jl:158: undefined reference to `__truncdfbf2'
$HOME\.julia\packages\BFloat16s\u3WQc\src/bfloat16.jl:158: undefined reference to `__truncdfbf2'
collect2.exe: error: ld returned 1 exit status
ERROR: failed process: Process(setenv(`'$HOME\.julia\artifacts\fdff308295487f361ef6e8dc2d27f5abe8a6eee9\mingw64\bin\g++.exe' -m64 -march=x86-64 -shared '-L$HOME\.julia\juliaup\julia-1.11.1+0.x64.w64.mingw32\bin' '-L$HOME\.julia\juliaup\julia-1.11.1+0.x64.w64.mingw32\bin' -o CUDA.jl-sysimage.dll -Wl,--whole-archive '$HOME\AppData\Local\Temp\jl_ZA7qvMLupC-o.a' -Wl,--no-whole-archive -ljulia -ljulia-internal -lopenlibm -Wl,--export-all-symbols`,["WINDIR=C:\\WINDOWS", "HOMEPATH=$HOME" … "TEMP=$HOME\\AppData\\Local\\Temp"]), ProcessExited(1)) [1]

Stacktrace:
 [1] pipeline_error
   @ .\process.jl:598 [inlined]
 [2] run(::Cmd; wait::Bool)
   @ Base .\process.jl:513
 [3] run
   @ .\process.jl:510 [inlined]
 [4] run_compiler(cmd::Cmd; cplusplus::Bool)
   @ PackageCompiler $HOME\.julia\packages\PackageCompiler\gMDVC\src\PackageCompiler.jl:200
 [5] run_compiler
   @ $HOME\.julia\packages\PackageCompiler\gMDVC\src\PackageCompiler.jl:196 [inlined]
 [6] create_sysimg_from_object_file(object_files::Vector{String}, sysimage_path::String; version::Nothing, compat_level::String, soname::Nothing)
   @ PackageCompiler $HOME\.julia\packages\PackageCompiler\gMDVC\src\PackageCompiler.jl:725
 [7] create_sysimg_from_object_file
   @ $HOME\.julia\packages\PackageCompiler\gMDVC\src\PackageCompiler.jl:711 [inlined]
 [8] create_sysimage(packages::Vector{…}; sysimage_path::String, project::String, precompile_execution_file::Vector{…}, precompile_statements_file::Vector{…}, incremental::Bool, filter_stdlibs::Bool, cpu_target::String, script::Nothing, sysimage_build_args::Cmd, include_transitive_dependencies::Bool, base_sysimage::Nothing, julia_init_c_file::Nothing, julia_init_h_file::Nothing, version::Nothing, soname::Nothing, compat_level::String, extra_precompiles::String, import_into_main::Bool)
   @ PackageCompiler $HOME\.julia\packages\PackageCompiler\gMDVC\src\PackageCompiler.jl:691
 [9] top-level scope
   @ REPL[4]:1
Some type information was truncated. Use `show(err)` to see complete types.

```

I’ve since installed clang through [https://releases.llvm.org](https://releases.llvm.org) and using `JULIA_CC=clang` as an environment variable, however that presents a different set of problems where clang is unable to open a julia.lib file.

---

<div class="post-metadata">

**Author:** ![pxshen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pxshen/32/38776_2.png) [@pxshen](https://discourse.julialang.org/u/pxshen)\
**Post date:** [November 30, 2024, 7:05pm UTC](https://discourse.julialang.org/t/packagecompiler-jl-cannot-create-a-sysimage-with-cuda/123019/2 "2024-11-30T19:05:10Z")

</div>

Oddly I get same error on windows but not linux

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [November 30, 2024, 8:00pm UTC](https://discourse.julialang.org/t/packagecompiler-jl-cannot-create-a-sysimage-with-cuda/123019/3 "2024-11-30T20:00:40Z")

</div>

Can you create an issue at [GitHub · Where software is built](https://github.com/JuliaLang/PackageCompiler.jl/issues) ?

---

<div class="post-metadata">

**Author:** ![Abhro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abhro/32/220753_2.png) [@Abhro](https://discourse.julialang.org/u/Abhro)\
**Post date:** [November 30, 2024, 10:46pm UTC](https://discourse.julialang.org/t/packagecompiler-jl-cannot-create-a-sysimage-with-cuda/123019/4 "2024-11-30T22:46:03Z")

</div>

I do have an issue filed on BFloat16s.jl: [Creating sysimage fails on Windows · Issue #88 · JuliaMath/BFloat16s.jl · GitHub](https://github.com/JuliaMath/BFloat16s.jl/issues/88). Since it’s the same issue and I’m not sure which package needs to be fixed, I wasn’t sure where to file the issue either
