Skip to content

Commit

Permalink
Merge pull request #411 from qzhuyan/building-runtime-debug-types
Browse files Browse the repository at this point in the history
add KERL_RELEASE_TARGET
  • Loading branch information
jadeallenx committed May 31, 2022
2 parents fd03a20 + b2ed2b8 commit 1c711e8
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 8 deletions.
11 changes: 11 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ jobs:
;;
esac
echo "export _KERL_VSN=${_VERSION}" >> $BASH_ENV
echo 'export KERL_RELEASE_TARGET="debug opt gcov gprof valgrind lcnt" ' >> $BASH_ENV
- run:
no_output_timeout: 45m
command: |
Expand All @@ -111,6 +112,16 @@ jobs:
source $(./kerl path install_"$_KERL_VSN")/activate
erl -s crypto -s init stop
erl_call
- run:
name: Test KERL_RELEASE_TARGET
command: |
. $BASH_ENV
source $(./kerl path install_"$_KERL_VSN")/activate
for r_type in debug opt gcov gprof valgrind lcnt;
do
[[ "${r_type}" == $(cerl -"$r_type" -noshell -eval 'io:format(erlang:system_info(build_type)),halt()') ]] \
|| exit 1;
done
kerl_deactivate
- run:
|
Expand Down
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,21 @@ NB: This setting has no effect when using `kerl build git...`, which invokes ker
Allows building, alongside the regular VM, a debug VM (available via `cerl -debug`).
NB: Enable this build using `KERL_BUILD_DEBUG_VM=true`

### KERL_RELEASE_TARGET

Allows building, alongside the regular VM, a list of various runtime types for debugging
(such as `cerl -debug` or `cerl -asan`)

NB: Enable this build using `KERL_RELEASE_TARGET="debug asan"`

NB: available types: opt, gcov, gprof, debug, valgrind, asan or lcnt

For more information:

see "How to Build a Debug Enabled Erlang RunTime System" in

https://www.erlang.org/doc/installation_guide/install


### OTP_GITHUB_URL

Expand Down
48 changes: 40 additions & 8 deletions kerl
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ fi
if [ -n "$KERL_BUILD_BACKEND" ]; then
_KBB="$KERL_BUILD_BACKEND"
fi
if [ -n "$KERL_RELEASE_TARGET" ]; then
_KRT="$KERL_RELEASE_TARGET"
fi

OTP_GITHUB_URL=https://github.com/erlang/otp
KERL_CONFIGURE_OPTIONS=
Expand All @@ -151,6 +154,7 @@ KERL_BUILD_PLT=
KERL_BUILD_DOCS=
KERL_DOC_TARGETS=chunks
KERL_BUILD_BACKEND=
KERL_RELEASE_TARGET=

# ensure the base dir exists
mkdir -p "$KERL_BASE_DIR" || exit 1
Expand Down Expand Up @@ -200,6 +204,9 @@ fi
if [ -n "$_KBB" ]; then
KERL_BUILD_BACKEND="$_KBB"
fi
if [ -n "$_KRT" ]; then
KERL_RELEASE_TARGET="$_KRT"
fi

if [ -z "$KERL_SASL_STARTUP" ]; then
INSTALL_OPT='-minimal'
Expand Down Expand Up @@ -1040,11 +1047,32 @@ _do_build() {
ERL_TOP="$ERL_TOP" ./otp_build release -a "$KERL_BUILD_DIR/$2/release_$1" >/dev/null 2>&1
cd "$KERL_BUILD_DIR/$2/release_$1" || exit 1
./Install $INSTALL_OPT "$KERL_BUILD_DIR/$2/release_$1" >/dev/null 2>&1

# keep for backward compatibility
# preferably use "$KERL_RELEASE_TARGET"
if [ -n "$KERL_BUILD_DEBUG_VM" ]; then
l=n stderr "Also building Erlang/OTP $1 ($2) debug VM, please wait..."
cd $ERL_TOP/erts/emulator || exit 1
make debug ERL_TOP=$ERL_TOP >>"$LOGFILE" 2>&1
fi

if [ -n "$KERL_RELEASE_TARGET" ]; then
# where `$TYPE` is `opt`, `gcov`, `gprof`, `debug`, `valgrind`, `asan` or `lcnt`.
for r_type in $KERL_RELEASE_TARGET;
do
case $r_type in
opt|gcov|gprof|debug|valgrind|asan|lcnt)
l=n stderr "Also building Erlang/OTP $1 ($2) $r_type VM, please wait..."
cd $ERL_TOP/erts/emulator || exit 1
make "$r_type" ERL_TOP=$ERL_TOP >>"$LOGFILE" 2>&1;
[ $? ] || l=w stderr "Build with runtime type: ${r_type} failed, maybe this OTP $1 is not supported"
;;
*)
l=w stderr "Invalid '$r_type' runtime type"
;;
esac
done
fi
}

do_install() {
Expand All @@ -1065,14 +1093,18 @@ do_install() {
l=e stderr "Couldn't install Erlang/OTP $rel ($1) in $absdir"
exit 1
fi
BEAM_DEBUG_SMP=$(\find . -name beam.debug.smp)
if [ "$BEAM_DEBUG_SMP" != "" ]; then
ERL_CHILD_SETUP_DEBUG=$(\find . -name erl_child_setup.debug)
l=n stderr "Also installing Erlang/OTP $rel ($1) debug VM in $absdir..."
cp $BEAM_DEBUG_SMP $absdir/erts-*/bin/
cp $ERL_CHILD_SETUP_DEBUG $absdir/erts-*/bin/
cp bin/cerl $absdir/bin
fi

for r_type in $KERL_RELEASE_TARGET;
do
BEAM_DEBUG_SMP=$(\find . -name "beam.${r_type}.smp")
if [ "$BEAM_DEBUG_SMP" != "" ]; then
ERL_CHILD_SETUP_DEBUG=$(\find . -name "erl_child_setup.${r_type}")
l=n stderr "Also installing Erlang/OTP $rel ($1) ${r_type} VM in $absdir..."
cp $BEAM_DEBUG_SMP $absdir/erts-*/bin/
cp $ERL_CHILD_SETUP_DEBUG $absdir/erts-*/bin/
fi
done
[ -f bin/cerl ] && cp bin/cerl $absdir/bin
list_add installations "$1 $absdir";
cat <<ACTIVATE >"$absdir"/activate
#!/bin/sh
Expand Down

0 comments on commit 1c711e8

Please sign in to comment.