Replies: 1 comment
-
I agree there is something not always right when I installed odin on my mac's. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've always been concerned about how the official distribution of odin for macOS depends on having LLVM installed on the system in a specific location.
If you download the odin binary for macos from the github releases page you get a ~2.7MB file that requires llvm to be installed at
/usr/local/opt/llvm@11/
, or at least that's what the error message is telling me:I suspect the path is this way because of how homebrew sets things up.
I removed the llvm installed from brew on my system (long story) and instead downloaded the official llvm release (which at this time was version 14) and it is basically just a folder. So I copied the folder to a specific location on my system (
~/programs/llvm
) and added thebin
directory from there to my PATH environment variable.Now, I wanted to compile odin using that installation of llvm, and I wanted odin to be statically linked so that I can delete the llvm folder (or rename it) and still have the odin compiler work.
I struggled for a while but it worked after I made the following changes to the build script:
The resulting binary was roughly 90MB, which was a good sign because it means llvm is statically linked into it.
I renamed the llvm folder on my system so that if the compiler tries to look for it, it won't find it. Then I used the compiler, and it worked!
I successfully created a build of the compiler that does not have any runtime dependencies beside those present on the system.
Basically I needed to add this
-isysroot $(xcrun --show-sdk-path)
to the compiler flags because the official llvm distribution for macos can't seem to find the system sdk on its own.Replacing
-lLLVM-C
with$($LLVM_CONFIG --libs --system-libs)
probably has to do with how homebrew sets things up. I suppose theLLVM-C
is the clurpit causing the llvm libraries to be dynamically instead of statically linked. I'm not sure where it comes from, but it's not included in the official llvm distribution that I downloaded.It seems the build script for macOS not only requires llvm, but assumes that llvm is installed via homebrew. Because, why else would it try to link against
LLVM-C
instead of asking llvm-config to provide the library names?Running
dyld_info odin
against the version I compiled with the above changes shows it's only dynamically linked to system libraries:Where as running the same command on the official odin distributed compiler shows:
I suspect some system libraries (libz, libxml, libcurses) are not listed because they are dependencies of LLVM-C, and the
dyld_info
tool only prints the direct dependencies.This means that if someone downloads the official llvm distribution and copies it to the path required by the odin compiler, it still will not work, because there's no
libLLVM-C.dylib
in it.In other words, not only does odin currently require llvm to be installed, it also requires homebrew to be installed, and for llvm to be installed via homebrew.
Beta Was this translation helpful? Give feedback.
All reactions