You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am running into an error when trying to relocate a very simple compiled app to a different part of my machine (not even a different machine).
System and Library Info
MacOS 14.4.1 on M1 Max
PackageCompiler v2.1.17
julia install via juliaup: curl -fsSL https://install.julialang.org | sh
julia versioninfo()
Julia Version 1.10.3
Commit 0b4590a5507 (2024-04-30 10:59 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: macOS (arm64-apple-darwin22.4.0)
CPU: 10 × Apple M1 Max
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-15.0.7 (ORCJIT, apple-m1)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)
Minimum working example
I'm just trying to create a very simple app I'm calling AppSandbox
# AppSandbox.jl/src/AppSandbox.jlmodule AppSandbox
functionjulia_main()::Cintprint("Hello World from my compiled app!\n")
return0# if things finished successfullyendgreet() =print("Greetings from AppSandbox!")
export greet
end# module AppSandbox
Then to build, I run the following using a local fix for issue #738 (see comment with fix here)
# pwd AppSandbox.jl. Started Julia with `julia --project=.`using PackageCompiler
# re-define the create_sysimg_from_object_file functionusing PackageCompiler: get_extra_linker_flags, julia_libdir, julia_private_libdir, ldlibs, bitflag, march, run_compiler
function PackageCompiler.create_sysimg_from_object_file(object_files::Vector{String},
sysimage_path::String;
version,
compat_level::String,
soname::Union{Nothing, String})
if soname ===nothing&& (Sys.isunix() &&!Sys.isapple())
soname =basename(sysimage_path)
endmkpath(dirname(sysimage_path))
# Prevent compiler from stripping all symbols from the shared lib.if Sys.isapple()
cltools_version_cmd =`pkgutil --pkg-info=com.apple.pkg.CLTools_Executables`
cltools_version =match(r"version: (.*)\n", readchomp(cltools_version_cmd))[1]
ifstartswith(cltools_version, "15")
o_file_flags =`-Wl,-all_load $object_files -Wl,-ld_classic`else
o_file_flags =`-Wl,-all_load $object_files`endelse
o_file_flags =`-Wl,--whole-archive $object_files -Wl,--no-whole-archive`end
extra =get_extra_linker_flags(version, compat_level, soname)
cmd =`$(bitflag())$(march()) -shared -L$(julia_libdir()) -L$(julia_private_libdir()) -o $sysimage_path$o_file_flags$(Base.shell_split(ldlibs()))$extra`run_compiler(cmd; cplusplus=true)
returnnothingend# build the compiled app, overwritting compiled direction if it exists (force=true)create_app(".", "build", force=true)
The app builds and I can successfully run it in the location it was built
# pwd is AppSandbox.jl
./build/bin/AppSandbox
# output:# Hello World from my compiled app!
But if I try to relocate the app locally, I get the following error
cp -r build/ ~/Desktop/AppSandboxBuild
~/Desktop/AppSandboxBuild/bin/AppSandbox
# output
ERROR: System image file failed consistency check: maybe opened the wrong version?
[65750] signal (11.2): Segmentation fault: 11
in expression starting at none:0
[65750] signal (6): Abort trap: 6
in expression starting at none:0
Abort trap: 6
The text was updated successfully, but these errors were encountered:
Maybe macOS security mechanism kicks in. macOS caches information about the code’s signature in the kernel.
It seems that Apple M processors require all code to be validly signed (if only ad hoc) or the operating system will not execute it, instead killing it on launch.
The fix/workaround is identified in Mac's documentation. In short, use ditto to move instead of cp
cp -r build/ ~/Desktop/AppSandboxBuild
~/Desktop/AppSandboxBuild/bin/AppSandbox
# This will fail with the above error
ditto build/ ~/Desktop/AppSandboxBuild2
~/Desktop/AppSandboxBuild2/bin/AppSandbox
# This works
I am running into an error when trying to relocate a very simple compiled app to a different part of my machine (not even a different machine).
System and Library Info
curl -fsSL https://install.julialang.org | sh
Minimum working example
I'm just trying to create a very simple app I'm calling AppSandbox
Then to build, I run the following using a local fix for issue #738 (see comment with fix here)
The app builds and I can successfully run it in the location it was built
But if I try to relocate the app locally, I get the following error
The text was updated successfully, but these errors were encountered: