Skip to content

Commit

Permalink
Make the runner scripts symlink tolerant
Browse files Browse the repository at this point in the history
  • Loading branch information
gtrepta committed Sep 29, 2023
1 parent b120acb commit 5bae7fe
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
12 changes: 6 additions & 6 deletions bin/llvm-kompile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -e

# This is configured generated code; shellcheck can't follow it properly
# shellcheck disable=SC1091
source "$(dirname "$0")/../lib/scripts/utils.sh"
source "$(dirname $(realpath "$0"))/../lib/scripts/utils.sh"

Check warning on line 6 in bin/llvm-kompile

View workflow job for this annotation

GitHub Actions / Shell check

Quote this to prevent word splitting.

usage() {
cat << HERE
Expand Down Expand Up @@ -56,13 +56,13 @@ HERE
}

print_bindings_path () {
bin_dir="$(dirname "$0")"
bin_dir="$(dirname $(realpath "$0"))"

Check warning on line 59 in bin/llvm-kompile

View workflow job for this annotation

GitHub Actions / Shell check

Quote this to prevent word splitting.
bindings_dir="$(realpath "$bin_dir/../lib/kllvm/python")"
echo "$bindings_dir"
}

print_include_path () {
bin_dir="$(dirname "$0")"
bin_dir="$(dirname $(realpath "$0"))"

Check warning on line 65 in bin/llvm-kompile

View workflow job for this annotation

GitHub Actions / Shell check

Quote this to prevent word splitting.
include_dir="$(realpath "$bin_dir/../include")"
echo "$include_dir"
}
Expand Down Expand Up @@ -215,7 +215,7 @@ if [[ "$compile" = "default" ]]; then

codegen_flags+=("--binary-ir")

run "$(dirname "$0")"/llvm-kompile-codegen "${codegen_flags[@]}" \
run "$(dirname $(realpath "$0"))"/llvm-kompile-codegen "${codegen_flags[@]}" \

Check warning on line 218 in bin/llvm-kompile

View workflow job for this annotation

GitHub Actions / Shell check

Quote this to prevent word splitting.
"$definition" "$dt_dir"/dt.yaml "$dt_dir" -o "$mod"

if [[ "$use_opt" = "true" ]]; then
Expand All @@ -236,7 +236,7 @@ elif [ "$compile" = "python_ast" ]; then
fi

if [[ "$main" =~ "python" ]]; then
bin_dir=$(dirname "$0")
bin_dir=$(dirname $(realpath "$0"))

Check warning on line 239 in bin/llvm-kompile

View workflow job for this annotation

GitHub Actions / Shell check

Quote this to prevent word splitting.
src_dir=$(realpath "$bin_dir/../lib/kllvm/python_src")

# Hook to allow Nix to patch this line easily
Expand Down Expand Up @@ -272,7 +272,7 @@ for (( idx = 0; idx < embed_length; idx++ )); do
kompile_clang_flags+=("$tmpdir/$name.cpp")
done

run "$(dirname "$0")"/llvm-kompile-clang \
run "$(dirname $(realpath "$0"))"/llvm-kompile-clang \

Check warning on line 275 in bin/llvm-kompile

View workflow job for this annotation

GitHub Actions / Shell check

Quote this to prevent word splitting.
"$modopt" "$main" \
@LLVM_KOMPILE_LTO@ -fno-stack-protector \
"${kompile_clang_flags[@]}" "${clang_args[@]}" \
10 changes: 5 additions & 5 deletions bin/llvm-kompile-clang
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# This is configured generated code; shellcheck can't follow it properly
# shellcheck disable=SC1091
source "$(dirname "$0")/../lib/scripts/utils.sh"
source "$(dirname $(realpath "$0"))/../lib/scripts/utils.sh"

# Set the printing depth for profiling and verbose execution information
export DEPTH=1
Expand Down Expand Up @@ -114,9 +114,9 @@ case "$modopt" in
;;
esac

LIBDIR="$(dirname "$0")/../lib/kllvm/"
INCDIR="$(dirname "$0")/../include/"
BINDIR="$(dirname "$0")"
LIBDIR="$(dirname $(realpath "$0"))/../lib/kllvm/"
INCDIR="$(dirname $(realpath "$0"))/../include/"
BINDIR="$(dirname $(realpath "$0"))"

if [ "$main" = "main" ]; then
MAINFILES="$LIBDIR"/llvm/main/main.ll
Expand Down Expand Up @@ -243,7 +243,7 @@ if $link; then
"$LIBDIR"/libjson.a \
"${flags[@]}" \
"${all_libraries[@]}" \
-I "$(dirname "$0")"/../include/kllvm \
-I "$(dirname $(realpath "$0"))"/../include/kllvm \
"${clangpp_args[@]}"

if [[ "$OSTYPE" == "darwin"* ]]; then
Expand Down
24 changes: 12 additions & 12 deletions bin/llvm-krun
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ interpreter_flags=()
dryRun=false
expandMacros=true

convert_term="$(dirname "$0")/kore-convert --from=text --to=binary /dev/stdin -F"
convert_term="$(dirname $(realpath "$0"))/kore-convert --from=text --to=binary /dev/stdin -F"

print_usage () {
cat <<HERE
Expand Down Expand Up @@ -251,7 +251,7 @@ for name in "${params[@]}"; do
{
cat "${!binary_file_name}"
echo "inj{Sort$sort{}, SortKItem{}}()" | $convert_term -ka
"$(dirname "$0")/kore-arity" 1
"$(dirname $(realpath "$0"))/kore-arity" 1
} >> "$temp_file"
)
printf -v "$binary_file_name" %s "$temp_file"
Expand Down Expand Up @@ -306,7 +306,7 @@ HERE
if [ "$verbose" -ge 2 ]; then
set -x
fi
"$(dirname "$0")/kore-convert" "${!binary_file_name}" >> "$input_file"
"$(dirname $(realpath "$0"))/kore-convert" "${!binary_file_name}" >> "$input_file"
)
else
echo "${!var_name}" >> "$input_file"
Expand Down Expand Up @@ -362,7 +362,7 @@ construct_binary_input()
if [ "$verbose" -ge 2 ]; then
set -x
fi
"$(dirname "$0")/kore-strip" -k -i "${!binary_file_name}" -o "$temp_file"
"$(dirname $(realpath "$0"))/kore-strip" -k -i "${!binary_file_name}" -o "$temp_file"
)
cat "$temp_file" >> "$input_file"
else
Expand All @@ -380,10 +380,10 @@ construct_binary_input()
fi
{
echo "Lbl'UndsPipe'-'-GT-Unds'{}()" | $convert_term -ka
"$(dirname "$0")/kore-arity" 2
"$(dirname $(realpath "$0"))/kore-arity" 2

echo "Lbl'Unds'Map'Unds'{}()" | $convert_term -ka
"$(dirname "$0")/kore-arity" 2
"$(dirname $(realpath "$0"))/kore-arity" 2
} >> "$input_file"
)
done
Expand All @@ -393,7 +393,7 @@ construct_binary_input()
set -x
fi
echo "$initializer()" | $convert_term -ka >> "$input_file"
"$(dirname "$0")/kore-arity" 1 >> "$input_file"
"$(dirname $(realpath "$0"))/kore-arity" 1 >> "$input_file"
)
}

Expand All @@ -408,7 +408,7 @@ if $expandMacros; then
if [ "$verbose" -ge 2 ]; then
set -x
fi
"$(dirname "$0")/kore-expand-macros" "$dir" "$input_file" > "$expanded_input_file"
"$(dirname $(realpath "$0"))/kore-expand-macros" "$dir" "$input_file" > "$expanded_input_file"
)
else
cp "$input_file" "$expanded_input_file"
Expand All @@ -420,14 +420,14 @@ if $dryRun; then
if [ "$verbose" -ge 1 ]; then
set -x
fi
"$(dirname "$0")/kore-convert" "$expanded_input_file" -o "$real_output_file"
"$(dirname $(realpath "$0"))/kore-convert" "$expanded_input_file" -o "$real_output_file"
)
elif [ $binary_input != $binary_output ]; then
(
if [ "$verbose" -ge 1 ]; then
set -x
fi
"$(dirname "$0")/kore-convert" -F "$expanded_input_file"
"$(dirname $(realpath "$0"))/kore-convert" -F "$expanded_input_file"
)
elif [ -n "$real_output_file" ]; then
cat "$expanded_input_file" > "$real_output_file"
Expand All @@ -454,7 +454,7 @@ if [ -n "${real_output_file}" ]; then
if [ "$verbose" -ge 1 ]; then
set -x
fi
"$(dirname "$0")/kprint" "$dir" "$output_file" > "$real_output_file"
"$(dirname $(realpath "$0"))/kprint" "$dir" "$output_file" > "$real_output_file"
)
else
mv -f "$output_file" "$real_output_file"
Expand All @@ -465,7 +465,7 @@ elif $pretty_print; then
if [ "$verbose" -ge 1 ]; then
set -x
fi
"$(dirname "$0")/kprint" "$dir" "$output_file"
"$(dirname $(realpath "$0"))/kprint" "$dir" "$output_file"
)
else
cat "$output_file"
Expand Down
4 changes: 2 additions & 2 deletions nix/llvm-backend.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ stdenv.mkDerivation {
--replace '"-ltinfo"' '"-L${ncurses}/lib" "-ltinfo"' \
--replace '"-L@BREW_PREFIX@/opt/libffi/lib"' ' ' \
--replace '-L@BREW_PREFIX@/lib' '-L${libcxxabi}/lib' \
--replace '-I "$(dirname "$0")"/../include/kllvm' \
'-I "$(dirname "$0")"/../include/kllvm -I ${boost.dev}/include -I ${fmt.dev}/include'
--replace '-I "$(dirname $(realpath "$0"))"/../include/kllvm' \
'-I "$(dirname $(realpath "$0"))"/../include/kllvm -I ${boost.dev}/include -I ${fmt.dev}/include'
'';

cmakeFlags =
Expand Down

0 comments on commit 5bae7fe

Please sign in to comment.