Closed wilsonk closed 10 months ago
Thanks a bunch for the PR!
Cast is the monkey-wrench that always works, but not necessarily correctly. The refcounter relies on being able to track whether an array is mutable or immutable. Thus, even though it's slower, it's preferred to .dup
the array instead, creating a mutable copy; analogously, .freeze
turns the array into an immutable copy.
Maybe the llvm-config search could be pulled out into a separate script that both scripts source?
Actually, that is interesting because I originally .dup'ed
pretty much every case in the PR, but then thought it was the wrong way to do things, as I figured it would be slower. Makes sense that the RC would work better with a .dup'ed
array, though. Thanks for pointing that out explicitly (perhaps it should be in the documentation on arrays also?).
I noticed the .freeze
call for the opposite effect also. I like that ability in the language.
Not sure on the bash scripting, as I am not expert on that stuff, that is for sure. I can take a quick look though.
I realized that I didn't put this in a branch and then continued to push a fix for the bash scripts...duh. Anyways, to fix the scripting stuff you can just pull out the LLVM_CONFIG lines into llvm-search.sh (or some such) and put them into a function:
function llvm_search() {
if [ -v LLVM_CONFIG ]
then
:
elif [ -f "/usr/lib/llvm-15/bin/llvm-config" ]
then
LLVM_CONFIG="/usr/lib/llvm-15/bin/llvm-config"
elif [ -f "/usr/lib/llvm/15/bin/llvm-config" ]
then
LLVM_CONFIG="/usr/lib/llvm/15/bin/llvm-config"
elif [ -f "/usr/lib/llvm15/bin/llvm-config" ]
then
LLVM_CONFIG="/usr/lib/llvm15/bin/llvm-config"
else
echo "Cannot find llvm-15 llvm-config!"
exit 1
fi
}
and then add the script and call it from build.sh and unittest.sh like this:
. ./llvm-search.sh
llvm_search
where the original LLVM_CONFIG code was in each file. I don't imagine this is worth a PR (and to tell the truth, now that I have pushed this up accidentally to master...I don't know how to push a new branch without these changes anyways!!! I tried once and it was all mixed together! What a pain...I hate git sometimes :( )
Alright, fixed every file in this PR (without cast) and generalized llvm-config search out into separate function. I think I got everything; feel free to reopen if I forgot a file.
I am not sure I made the correct changes for these demos...just putting this here so that you may see the locations of the problems. Perhaps some of these changes are appropriate.
I also added a similar LLVM_CONFIG search in unittest.sh as exists in build.sh, as I was having some issues on WSL getting the unittests to run out-of-the-box.