# Where is juliac developed

**URL:** <https://discourse.julialang.org/t/where-is-juliac-developed/113004>\
**Category:** Internals & Design\
**Tags:** question\
**Created:** [April 16, 2024, 11:27am UTC](https://discourse.julialang.org/t/where-is-juliac-developed/113004 "2024-04-16T11:27:55Z")\
**Posts on this page:** 19\
**Page:** 2

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [October 3, 2024, 2:16pm UTC](https://discourse.julialang.org/t/where-is-juliac-developed/113004/21 "2024-10-03T14:16:52Z")

</div>

Likely inference limits on depth and tuple length, I suppose 😉

---

<div class="post-metadata">

**Author:** ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Post date:** [October 3, 2024, 2:29pm UTC](https://discourse.julialang.org/t/where-is-juliac-developed/113004/22 "2024-10-03T14:29:57Z")

</div>

> [@jules](#):
>
> I’ve seen in your juliac PR that you needed to change some occurrences of `all` or `map` to more verbose, explicit code in order to “help inference”.

Link?

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [October 3, 2024, 2:32pm UTC](https://discourse.julialang.org/t/where-is-juliac-developed/113004/23 "2024-10-03T14:32:30Z")

</div>

> <https://github.com/fredrikekre/Runic.jl/pull/56/files#diff-59fff72b4a4f3221b6f50d272e2bed8f87df1ae3aad690814134a3c15715ed66R10-R21>

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [October 3, 2024, 3:01pm UTC](https://discourse.julialang.org/t/where-is-juliac-developed/113004/24 "2024-10-03T15:01:28Z")

</div>

The `map` and `mapreduce` implementation in Julia right now is a bit of an abomination. it needs a rewerite.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [October 3, 2024, 3:18pm UTC](https://discourse.julialang.org/t/where-is-juliac-developed/113004/25 "2024-10-03T15:18:46Z")

</div>

What are concrete problems with them? Abomination sounds bad but what could be so wrong about them? They seem simple functions on the surface. Never checked their implementation, though.

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [October 3, 2024, 3:40pm UTC](https://discourse.julialang.org/t/where-is-juliac-developed/113004/26 "2024-10-03T15:40:34Z")

</div>

They sure _feel_ like they should be simple, but they’re super performance critical and encapsulate many do-what-you-mean behaviors in not-very-well-defined ways. You can just scan through the [fold label on GitHub](https://github.com/JuliaLang/julia/issues?q=label%3Afold+) to get a sense of the concrete issues.

---

<div class="post-metadata">

**Author:** ![stephenll](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stephenll/32/28751_2.png) [@stephenll](https://discourse.julialang.org/u/stephenll)\
**Post date:** [October 3, 2024, 8:20pm UTC](https://discourse.julialang.org/t/where-is-juliac-developed/113004/27 "2024-10-03T20:20:48Z")

</div>

Honestly, after seeing a type dispatch error I just assumed (guessed) that rather then pass a Matrix{Float64} that I should convert to Symmetric and that’s all I needed to do.

---

<div class="post-metadata">

**Author:** ![GeorgeGkountouras](https://avatars.discourse-cdn.com/v4/letter/g/77aa72/32.png) [@GeorgeGkountouras](https://discourse.julialang.org/u/GeorgeGkountouras)\
**Post date:** [October 4, 2024, 6:18pm UTC](https://discourse.julialang.org/t/where-is-juliac-developed/113004/28 "2024-10-04T18:18:19Z")

</div>

Does `--output-lib` require an entry point? The `--compile-ccallable` option seems to include the target functions in the shared library.

---

<div class="post-metadata">

**Author:** ![jbytecode](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jbytecode/32/17719_2.png) [@jbytecode](https://discourse.julialang.org/u/jbytecode)\
**Post date:** [October 4, 2024, 6:42pm UTC](https://discourse.julialang.org/t/where-is-juliac-developed/113004/29 "2024-10-04T18:42:31Z")

</div>

I haven’t tried the `--output-lib` option, but it shouldn’t be necessary to have an entry point in a shared library. When an entry point is included in a file and compiled with `--output-exe`, the compiler links and compiles the functions called by the entry point. Any unused code is removed in the compiled file, so we need to link them or, at the very least, prevent the compiler from deleting them. Specifically, `--compile-ccallable` (if exists) seems to be handling this issue.

---

<div class="post-metadata">

**Author:** ![GeorgeGkountouras](https://avatars.discourse-cdn.com/v4/letter/g/77aa72/32.png) [@GeorgeGkountouras](https://discourse.julialang.org/u/GeorgeGkountouras)\
**Post date:** [October 4, 2024, 6:48pm UTC](https://discourse.julialang.org/t/where-is-juliac-developed/113004/30 "2024-10-04T18:48:48Z")

</div>

Then what does `--output-lib` without `--compile-ccallable` do? Note that the `@ccallable` I am experimenting with works with StaticCompiler and doesn’t require a runtime. I would assume a more general version needs a workload (as seen from the entry point) to compile (and initializes the runtime somehow?) .

---

<div class="post-metadata">

**Author:** ![jbytecode](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jbytecode/32/17719_2.png) [@jbytecode](https://discourse.julialang.org/u/jbytecode)\
**Post date:** [October 4, 2024, 6:56pm UTC](https://discourse.julialang.org/t/where-is-juliac-developed/113004/31 "2024-10-04T18:56:01Z")

</div>

I think `--compile-lib` without any additional arguments + an entry point should not include the library functions (one can try it out using `nm library.so | grep funcname`) and you might be right, because the entry point triggers `jl_init()` call.

---

<div class="post-metadata">

**Author:** ![jbytecode](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jbytecode/32/17719_2.png) [@jbytecode](https://discourse.julialang.org/u/jbytecode)\
**Post date:** [October 4, 2024, 7:06pm UTC](https://discourse.julialang.org/t/where-is-juliac-developed/113004/32 "2024-10-04T19:06:16Z")

</div>

Suppose the code is

```julia
module MyLibrary

Base.@ccallable function myfunc(x::Float64)::Float64
    return x^2
end

end

```

When it’s compiled using

```bash
julia +nightly juliac.jl --output-lib mylib.so --trim mylib.jl

```

generates `mylib.so` without the exported function `myfunc`. When we introduce the `--compile-callable` option

```bash
julia +nightly juliac.jl --output-lib mylib.so --trim --compile-ccallable mylib.jl

```

produces the `mylib.so` with the function `myfunc` included:

```bash
#> nm ./mylib.so | grep myfunc
000000000000de00 t jfptr_myfunc_21486
0000000000023ed0 t jlcapi_myfunc_21488
000000000001d0c0 t julia_myfunc_21485
0000000000023ed0 T myfunc

```

---

<div class="post-metadata">

**Author:** ![terasakisatoshi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/terasakisatoshi/32/9187_2.png) [@terasakisatoshi](https://discourse.julialang.org/u/terasakisatoshi)\
**Post date:** [October 5, 2024, 2:37am UTC](https://discourse.julialang.org/t/where-is-juliac-developed/113004/33 "2024-10-05T02:37:36Z")

</div>

> generates `mylib.so` without the exported function `myfunc` . When we introduce the `--compile-callable` option

This helps me a lot. Thank you!!!

> **[GitHub - terasakisatoshi/libcalcpi\_juliac: \`juliac\` in action](https://github.com/terasakisatoshi/libcalcpi_juliac)**
>
> \`juliac\` in action

---

<div class="post-metadata">

**Author:** ![jbytecode](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jbytecode/32/17719_2.png) [@jbytecode](https://discourse.julialang.org/u/jbytecode)\
**Post date:** [October 5, 2024, 8:22am UTC](https://discourse.julialang.org/t/where-is-juliac-developed/113004/34 "2024-10-05T08:22:40Z")

</div>

That example is very helpful for those who plan to generate dynamic link libraries and later use them within C, C++, Rust or any other language with useful FFI. Thank you.

I think it is now time to fix the `juliac.jl --help` documentation. The other step is to prepare the official docs about the compiler.

---

<div class="post-metadata">

**Author:** ![The\_Mastermage](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/the_mastermage/32/49444_2.png) [@The\_Mastermage](https://discourse.julialang.org/u/The_Mastermage)\
**Post date:** [October 7, 2024, 8:56pm UTC](https://discourse.julialang.org/t/where-is-juliac-developed/113004/35 "2024-10-07T20:56:07Z")

</div>

just as a very quick question in here. Does juliac only work with Linux or does it also work on Windows?

---

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [October 8, 2024, 8:49am UTC](https://discourse.julialang.org/t/where-is-juliac-developed/113004/36 "2024-10-08T08:49:50Z")

</div>

I’m not on Windows to confirm, but it seems it would work. I see nothing platform-specific in the files juliac-buildscript.jl and juliac.jl, only in julia-config.jl, that is used by Juliac:

```julia
function ldflags(doframework)
    doframework && return "-F$(shell_escape(frameworkDir()))"
    fl = "-L$(shell_escape(libDir()))"
    if Sys.iswindows()
        fl = fl * " -Wl,--stack,8388608"
    elseif !Sys.isapple()
        fl = fl * " -Wl,--export-dynamic"
    end
    return fl
end

```

---

<div class="post-metadata">

**Author:** ![terasakisatoshi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/terasakisatoshi/32/9187_2.png) [@terasakisatoshi](https://discourse.julialang.org/u/terasakisatoshi)\
**Post date:** [October 9, 2024, 1:22am UTC](https://discourse.julialang.org/t/where-is-juliac-developed/113004/37 "2024-10-09T01:22:03Z")

</div>

If your Windows machine has `cc` command (C compiler), `juliac.jl` should work. In fact, my script in my repository `libcalcpi_juliac` could be generated as `libcalcpi.dll`.

This article [Installing the MinGW-w64 toolchain](https://code.visualstudio.com/docs/cpp/config-mingw#_installing-the-mingww64-toolchain) guides us how to install the `cc` command on Windows.

---

<div class="post-metadata">

**Author:** ![bluebug](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bluebug/32/212160_2.png) [@bluebug](https://discourse.julialang.org/u/bluebug)\
**Post date:** [October 12, 2024, 2:44am UTC](https://discourse.julialang.org/t/where-is-juliac-developed/113004/38 "2024-10-12T02:44:52Z")

</div>

I wrote a script build.jl to make juliac and clang work together in Windows, but there is an error when executing the compiled exe:

1. There is no output when running the exe directly
2. Copy the exe to the Julia bin directory and run it. The error is as follows:

```cmd
[26424] signal 11: SIGSEGV
in expression starting at none:0
crt_sig_handler at C:/workdir/src\signals-win.c:99
.text at C:\Users\***\AppData\Local\julias\julia-latest\bin\cal.exe (unknown line)
_C_specific_handler at C:\Windows\SYSTEM32\ntdll.dll (unknown line)
_chkstk at C:\Windows\SYSTEM32\ntdll.dll (unknown line)
RtlFindCharInUnicodeString at C:\Windows\SYSTEM32\ntdll.dll (unknown line)
KiUserExceptionDispatcher at C:\Windows\SYSTEM32\ntdll.dll (unknown line)
crc32c_sse42 at C:/workdir/src\crc32c.c:112
ijl_restore_system_image_data at C:/workdir/src\staticdata.c:4033
jl_load_sysimg_so at C:/workdir/src\staticdata.c:660 [inlined]
ijl_restore_system_image at C:/workdir/src\staticdata.c:4005
_finish_julia_init at C:/workdir/src\init.c:858
static_init at E:\codes\compile_jl\.\jl_nXpgrg\init.c:5
__do_global_ctors at C:\Users\***\AppData\Local\julias\julia-latest\bin\cal.exe (unknown line)        
__main at C:\Users\***\AppData\Local\julias\julia-latest\bin\cal.exe (unknown line)
__tmainCRTStartup at C:\Users\***\AppData\Local\julias\julia-latest\bin\cal.exe (unknown line)        
.l_start at C:\Users\***\AppData\Local\julias\julia-latest\bin\cal.exe (unknown line)
BaseThreadInitThunk at C:\Windows\System32\KERNEL32.DLL (unknown line)
RtlUserThreadStart at C:\Windows\SYSTEM32\ntdll.dll (unknown line)
Allocations: 0 (Pool: 0; Big: 0); GC: 0

```

the build.jl:

```julia
using Clang_jll

function update_juliac()
    Base.run(`curl https://raw.githubusercontent.com/JuliaLang/julia/refs/heads/master/contrib/juliac-buildscript.jl -o juliac-buildscript.jl`)
    Base.run(`curl https://raw.githubusercontent.com/JuliaLang/julia/refs/heads/master/contrib/juliac.jl -o juliac.jl`)
end

if findfirst(x -> x == "--update", ARGS) !== nothing
    update_juliac()
    exit(0)
else
    if !isfile("juliac.jl") || !isfile("juliac-buildscript.jl")
        update_juliac()
    end

    if Sys.iswindows()
        clang_lib = normpath(joinpath(Clang_jll.PATH[], "../bin"))
        paths = clang_lib * ";" * Clang_jll.PATH[] * join(Clang_jll.LIBPATH, ";") * ";" * ENV["PATH"]
        # hack cmd to use clang instead of cc
        run = (cmd::Cmd) -> begin
            println("📌")
            cc = withenv(clang, "PATH" => paths)
            for flag in cmd.exec[2:end]
                push!(cc.exec, flag)
            end
            println(cc.exec)
            Base.run(cc)
            println()
        end
        # hack temp dir into current working directory
        mktempdir(; cleanup=true) = Base.mktempdir(normpath("."), cleanup=cleanup)
    end

    include("juliac.jl")
end

```

---

<div class="post-metadata">

**Author:** ![jbytecode](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jbytecode/32/17719_2.png) [@jbytecode](https://discourse.julialang.org/u/jbytecode)\
**Post date:** [October 21, 2024, 9:27pm UTC](https://discourse.julialang.org/t/where-is-juliac-developed/113004/39 "2024-10-21T21:27:38Z")

</div>

`juliac` has new commits!

now, the `--verbose` option works for a more loud compilation.

> <https://github.com/JuliaLang/julia/commit/6d7e29f33018b8750ac1f2cf446a51910d25a1d7>
>
> This comments out an assert thats currently faulty and also marks
> apply\_iterate… as safe when we can special case it to not dispatch

One can try compiling their code like

`julia +nightly juliac.jl --output-exe hello --trim --verbose hello.jl`

after downloading the latest `contrib` folder

[Previous page](https://discourse.julialang.org/t/where-is-juliac-developed/113004.md?page=1)
