-
Notifications
You must be signed in to change notification settings - Fork 11
[21] add Koutheir's pretty printers for STL in libcxx #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
d-w-moore
wants to merge
6
commits into
irods:main
Choose a base branch
from
d-w-moore:koutheir
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4769c4d
[21] add Koutheir's pretty printers for STL in libcxx
d-w-moore 989a7e8
generalize parameters in koutheir configure script
d-w-moore f05d7db
generalize for max version of named package/dir pattern
d-w-moore ede49ff
generalization of script for CLANG,LLVM choice
d-w-moore 699814b
improvements includeing clang version hint
d-w-moore a926e9d
codacy
d-w-moore File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
#!/bin/bash | ||
|
||
# ***** While CHECK_* macros are still here, we are still testing :) . | ||
|
||
if [ -n "${CHECK_USER-1}" ] ; then # TODO - remove this if clause | ||
[ $(id -u) = 0 ] || { echo "Please run this script as root." >&2; exit 1; } | ||
fi | ||
|
||
# -- Configuration Values. | ||
|
||
CLANG_VERSION_HINT="6.*" | ||
CMAKE_PREFIX="/opt/irods-externals/cmake" | ||
CLANG_PREFIX="/opt/irods-externals/clang" | ||
CLANG_RUNTIME_PREFIX="/opt/irods-externals/clang-runtime" | ||
|
||
declare -A LLVM_TO_KOUTHEIR_VERSION_LOOKUP=( | ||
["6.0.0"]="5ffbf2487bf8da7f08bc1c8650a4396d2ff15403" | ||
) | ||
|
||
# -- Process Command Line Options. | ||
|
||
eval "set --$(/usr/bin/getopt --longoptions "clang-version-hint:" --options "c:" -- "$@")" | ||
for option in "$@"; do | ||
case $option in | ||
--clang-version-hint|-c) CLANG_VERSION_HINT=$2 ; shift 2 ;; | ||
*) shift; break;; | ||
esac | ||
done | ||
|
||
# | ||
# -- Function package_max_version | ||
# To determine the maximum of several versions of a package in iRODS externals | ||
# | ||
package_max_version() ( # deliberate subshell | ||
[ -z "$1" ] && exit | ||
PACKAGE_PREFIX=$1 | ||
shopt -s nullglob | ||
if [ -n "$2" ]; then | ||
version_string_pattern="$2" | ||
else | ||
version_string_pattern="[0-9][-.0-9]*" | ||
fi | ||
max="" | ||
paths=( ${PACKAGE_PREFIX}${version_string_pattern} ) | ||
[ ${#paths[*]} -gt 0 ] && \ | ||
for y in ${paths[*]}; do | ||
max=$(get_max "${y#${PACKAGE_PREFIX}}" "$max") | ||
done | ||
echo "$max" | ||
) | ||
|
||
get_max() { # -- get max of two (X,Y,Z) tuples -- | ||
local z y=0 gt="" | ||
local IFS=".-" # for splitting version numbers of the form "X[-.]Y..." into (X,Y,...) | ||
read -a z <<<"$2" | ||
for x in ${1}; do [ "${x:-0}" -gt "${z[$((y++))]:-0}" ] && gt=1; done | ||
if [ "$gt" ]; then echo "$1" | ||
else echo "$2"; fi | ||
} | ||
|
||
CLANG_VERSION=$(package_max_version $CLANG_PREFIX "$CLANG_VERSION_HINT") | ||
|
||
if [ -z "$CLANG_VERSION" ] ; then | ||
echo >&2 "ERROR - no Clang compiler found among installed irods-externals*" | ||
exit 2 | ||
fi | ||
|
||
LLVM_VERSION=${CLANG_VERSION//[-.]/.} | ||
|
||
LIBCXX_PRETTY_PRINTERS_COMMIT=${LLVM_TO_KOUTHEIR_VERSION_LOOKUP[$LLVM_VERSION]} | ||
|
||
if [ -z "$LIBCXX_PRETTY_PRINTERS_COMMIT" ]; then | ||
echo >&2 "WARNING - no optimal version of libc++ Pretty-Printers found." | ||
echo >&2 " Using the default branch" | ||
fi | ||
|
||
if [ -x /usr/bin/zypper ] ;then | ||
pkgtool=zypper # SuSE | ||
elif [ -x /usr/bin/yum ]; then | ||
pkgtool=yum # CentOS, RHEL | ||
yum install -y epel-release | ||
else | ||
pkgtool=apt # Debian, Ubuntu | ||
apt update | ||
fi | ||
|
||
# Need: | ||
# - python so that GDB and RR can load pretty printers | ||
# - git to fetch LLVM source | ||
# - make to build debug libraries | ||
|
||
${pkgtool} install -y make git python python3 | ||
|
||
# Build debug versions of stdc++ lib shared objects. | ||
|
||
echo >&2 -e "\n--> Checking out llvm and building debug libraries for cxx and cxxabi.\n" | ||
|
||
CMAKE_VERSION=$(package_max_version $CMAKE_PREFIX) | ||
CLANG_PATH=${CLANG_PREFIX}${CLANG_VERSION} | ||
CLANG_RUNTIME_PATH=${CLANG_RUNTIME_PREFIX}${CLANG_VERSION} | ||
|
||
|
||
if [ ! -d "$CLANG_RUNTIME_PATH" ]; then | ||
echo >&2 "Warning - No clang runtime corresponding to clang '${CLANG_VERSION}'." | ||
echo >&2 " Please install it before running this script." | ||
exit 3 | ||
fi | ||
|
||
CMAKE_VERSION=$(package_max_version $CMAKE_PREFIX) | ||
|
||
# | ||
# Print debug values and quit if requested by CHECK_QUIT != "" - TODO - remove this | ||
# | ||
if [ -n "${CHECK_QUIT}" ] ; then | ||
echo CMAKE_VERSION "($CMAKE_VERSION)" | ||
echo CLANG_PATH "($CLANG_PATH)" | ||
echo CLANG_RUNTIME_PATH "($CLANG_RUNTIME_PATH)" | ||
echo LIBCXX_PRETTY_PRINTERS_COMMIT "($LIBCXX_PRETTY_PRINTERS_COMMIT)" | ||
exit 10 | ||
fi | ||
|
||
if [ -n "${CMAKE_VERSION}" ]; then | ||
cd ~ ; git clone http://github.com/llvm/llvm-project | ||
cd llvm-project && \ | ||
git checkout "llvmorg-${LLVM_VERSION}" && \ | ||
mkdir build && \ | ||
cd build && \ | ||
"${CMAKE_PREFIX}${CMAKE_VERSION}/bin/cmake" \ | ||
-G "Unix Makefiles" -DLLVM_ENABLE_PROJECTS="libcxx;libcxxabi" ../llvm && \ | ||
make -j7 cxx cxxabi | ||
else | ||
echo >&2 "Error - Need at least one irods-externals-cmake* package installed" | ||
exit 4 | ||
fi | ||
|
||
# -- Backup existing shared objects and copy debug versions in to replace them. | ||
|
||
echo >&2 -e "\n--> Writing debug shared objects.\n" | ||
for SHLIB in lib/libc++*.so*; do | ||
for DIR in /opt/irods-externals/clang{,-runtime}${CLANG_VERSION}/; do | ||
[ -f "$DIR/$SHLIB" -o -L "$DIR/$SHLIB" ] && mv "$DIR/$SHLIB"{,.orig} | ||
cp -rp "$SHLIB" "$DIR"/lib/. | ||
done | ||
done | ||
|
||
# -- Install & configure pretty-printers | ||
|
||
if [ -z "${LIBCXX_PRETTY_PRINTERS_COMMIT}" ]; then | ||
GIT_PPRINTER_CHECKOUT_CMD=":" | ||
else | ||
GIT_PPRINTER_CHECKOUT_CMD="git checkout '${LIBCXX_PRETTY_PRINTERS_COMMIT}'" | ||
fi | ||
|
||
echo >&2 -e "\n--> Creating $HOME/.gdbinit for gdb and rr.\n" | ||
|
||
cd ~ ; git clone https://github.com/koutheir/libcxx-pretty-printers | ||
|
||
if cd libcxx-pretty-printers | ||
then | ||
if ! eval "$GIT_PPRINTER_CHECKOUT_CMD" ; then | ||
echo >&2 "Error - Could not find pretty printers repository directory." | ||
exit 5 | ||
fi | ||
PP_SRC_DIR=~/libcxx-pretty-printers/src | ||
cp $PP_SRC_DIR/gdbinit ~/.gdbinit && sed -i -e "s@<path.*>@$PP_SRC_DIR@" ~/.gdbinit | ||
else | ||
echo >&2 "Error - Could not find pretty printers repository directory." | ||
exit 6 | ||
fi |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we clone this repository into the irods namespace? we do this for most everything else we use...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so. Clone away, and I will change the reference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now available at https://github.com/irods/libcxx-pretty-printers