Skip to content

Commit

Permalink
Add configure option to enable slave emulator
Browse files Browse the repository at this point in the history
It takes as argument the target of the slave emulator (epiphany-elf by
default).
  • Loading branch information
margnus1 committed Apr 6, 2015
1 parent 4e6684e commit fb8a6ad
Show file tree
Hide file tree
Showing 8 changed files with 247 additions and 44 deletions.
125 changes: 125 additions & 0 deletions erts/configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -4904,6 +4904,131 @@ CFLAGS="$CFLAGS $sanitizers"
LDFLAGS="$LDFLAGS $sanitizers"
])

dnl ----------------------------------------------------------------------
dnl Configure slave emulator
dnl ----------------------------------------------------------------------

AC_ARG_ENABLE(slave-emulator,
AS_HELP_STRING([--enable-slave-emulator],
[run erlang processes on general-purpose co-processors like the Adapteva Epiphany]),
enable_slave_emulator="$enableval",
enable_slave_emulator=auto)

dnl We call AC_CONFIG_SUBDIRS, even though the generated shell code is never
dnl executed, because we want the side effects, i.e. that --help=recursive will
dnl include options for the slave emulator.
if false; then
AC_CONFIG_SUBDIRS([emulator/slave])
fi

if test X$enable_slave_emulator != Xno; then
AC_PROG_SED
AC_PROG_GREP
AC_PROG_EGREP

if test -n $EPIPHANY_HOME; then
CFLAGS="$CFLAGS -I $EPIPHANY_HOME/tools/host/include"
LDFLAGS="$LDFLAGS -L $EPIPHANY_HOME/tools/host/lib"
fi

AC_SEARCH_LIBS([e_init], [e-hal])
if test "X$ac_cv_search_e_init" = Xno; then
if test X$enable_slave_emulator != Xauto; then
AC_MSG_ERROR([could not find the Epiphany Hardware Abstraction Layer (eHAL)])
else
AC_MSG_WARN([slave emulator disabled because the Epiphany Hardware Abstraction Layer (eHAL) could not be found])
enable_slave_emulator=no
fi
fi
fi

if test X$enable_slave_emulator != Xno; then
AC_SEARCH_LIBS([e_load], [e-loader])
if test "X$ac_cv_search_e_load" = Xno; then
if test X$enable_slave_emulator != Xauto; then
AC_MSG_ERROR([could not find the Epiphany Hardware Abstraction Layer (eHAL) loader])
else
AC_MSG_WARN([slave emulator disabled because the Epiphany Hardware Abstraction Layer (eHAL) loader could not be found])
enable_slave_emulator=no
fi
fi
fi

if test X$enable_slave_emulator != Xno; then
if test X$enable_slave_emulator = Xyes -o X$enable_slave_emulator = Xauto; then
slave_host=epiphany-elf
else
slave_host=$enable_slave_emulator
fi

# Recurse into the emulator/slave directory
dnl We do this manually (most of the code below is borrowed from
dnl _AC_OUTPUT_SUBDIRS) so that we can override the --host argument.
if test "$no_recursion" != yes; then
ac_sub_configure_args="--prefix=$prefix $ac_configure_args --host=$slave_host"

# Always prepend --prefix to ensure using the same prefix
# in subdir configurations.
ac_arg="--prefix=$prefix"
case $ac_arg in
*\'*) ac_arg=`AS_ECHO(["$ac_arg"]) | sed "s/'/'\\\\\\\\''/g"` ;;
esac
ac_sub_configure_args="'$ac_arg' $ac_sub_configure_args"

# Pass --silent
if test "$silent" = yes; then
ac_sub_configure_args="--silent $ac_sub_configure_args"
fi

# Always prepend --disable-option-checking to silence warnings, since
# different subdirs can have different --enable and --with options.
ac_sub_configure_args="--disable-option-checking $ac_sub_configure_args"

ac_popdir=`pwd`
ac_dir=emulator/slave

ac_msg="=== configuring in $ac_dir (`pwd`/$ac_dir)"
_AS_ECHO_LOG([$ac_msg])
_AS_ECHO([$ac_msg])
AS_MKDIR_P(["$ac_dir"])
_AC_SRCDIRS(["$ac_dir"])

cd "$ac_dir"
ac_sub_configure=$ac_srcdir/configure

# The recursion is here.
# Make the cache file name correct relative to the subdirectory.
case $cache_file in
[[\\/]]* | ?:[[\\/]]* ) ac_sub_cache_file=$cache_file ;;
*) # Relative name.
ac_sub_cache_file=$ac_top_build_prefix$cache_file ;;
esac

AC_MSG_NOTICE([running $SHELL $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir])
# The eval makes quoting arguments work.
eval "\$SHELL \"\$ac_sub_configure\" $ac_sub_configure_args \
--cache-file=\"\$ac_sub_cache_file\" --srcdir=\"\$ac_srcdir\"" ||
if test X$enable_slave_emulator != Xauto; then
AC_MSG_ERROR([$ac_sub_configure failed for $ac_dir])
else
AC_MSG_WARN([disabling slave emulator because of configuration failure])
enable_slave_emulator=no
fi

cd "$ac_popdir"
ac_msg="=== proceeding to configure $srcdir"
_AS_ECHO_LOG([$ac_msg])
_AS_ECHO([$ac_msg])
fi
fi

ERTS_BUILD_SLAVE_EMU=no
if test X$enable_slave_emulator != Xno; then
ERTS_BUILD_SLAVE_EMU=yes
AC_DEFINE(ERTS_SLAVE_EMU_ENABLED, 1, [Define if the slave emulator is available])
fi
AC_SUBST(ERTS_BUILD_SLAVE_EMU)

dnl ----------------------------------------------------------------------
dnl Output the result.
dnl ----------------------------------------------------------------------
Expand Down
26 changes: 26 additions & 0 deletions erts/emulator/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,11 @@ endif

ERTS_ENABLE_KERNEL_POLL=@ERTS_ENABLE_KERNEL_POLL@

# This script requires $(TF_MARKER), so we include it down here
ifeq (@ERTS_BUILD_SLAVE_EMU@, yes)
include slave/info.mk
endif

#
#
#
Expand Down Expand Up @@ -243,6 +248,9 @@ endif
PERL = @PERL@
RM = @RM@
MKDIR = @MKDIR@
SED = @SED@
GREP = @GREP@
EGREP = @EGREP@

USING_MINGW=@MIXED_CYGWIN_MINGW@
MIXED_MSYS=@MIXED_MSYS@
Expand Down Expand Up @@ -1020,6 +1028,24 @@ $(OBJDIR)/hipe_arm.o: hipe/hipe_arm.c
# end of HiPE section
########################################

ifeq (@ERTS_BUILD_SLAVE_EMU@, yes)
$(BINDIR)/$(EMULATOR_EXECUTABLE): $(SLAVE_EXECUTABLE)
$(SLAVE_EXECUTABLE): FORCE
$(V_at)( cd slave && $(MAKE) FLAVOR=$(FLAVOR) )

$(TTF_DIR)/slave_syms.h: $(SLAVE_EXECUTABLE)
$(gen_verbose)$(SLAVE_OBJDUMP) -t $< \
| $(GREP) -e .bss\t -e .data\t -e .text\t \
| $(EGREP) ' [^ .]+$' \
| $(SED) 's/^\([^ ]*\)[^_]* \([^ ]*\)$/#define SLAVE_SYM\2 0x\1/g' \
> $@

# FORCE is an empty phony target used to unconditionally execute certain rules
.PHONY: FORCE
FORCE:

endif

# ----------------------------------------------------------------------
# The emulator itself
#
Expand Down
2 changes: 1 addition & 1 deletion erts/emulator/master/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pump: $(PUMP_OBJS)
%.o: %.c slave_syms.h
$(CC) $(CFLAGS) -c -o $@ $<

slave_syms.h: ~/otp/bin/epiphany-unknown-elf/beam
slave_syms.h: ~/otp/bin/epiphany-unknown-elf/slave
~/otp/erts/emulator/utils/make_slave_syms

clean:
Expand Down
1 change: 1 addition & 0 deletions erts/emulator/slave/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
/config.log
/config.status
/config.h.in
/info.mk
89 changes: 48 additions & 41 deletions erts/emulator/slave/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -251,13 +251,12 @@ CREATE_DIRS += $(TTF_DIR)
# create obj dir for emulator

OBJDIR = obj/$(TTF_DIR)

CREATE_DIRS += $(OBJDIR)

BINDIR = $(ERL_TOP)/bin/$(TARGET)
CREATE_DIRS += $(BINDIR)

ERLANG_OSTYPE = @ERLANG_OSTYPE@

ENABLE_ALLOC_TYPE_VARS += @ERLANG_OSTYPE@

EMULATOR_EXECUTABLE = slave$(TF_MARKER)
Expand Down Expand Up @@ -487,18 +486,26 @@ $(OBJS): $(TTF_DIR)/GENERATED
$(BINDIR)/$(EMULATOR_EXECUTABLE): $(INIT_OBJS) $(OBJS) $(DEPLIBS)
$(ld_verbose)$(PURIFY) $(LD) -o $(BINDIR)/$(EMULATOR_EXECUTABLE) \
$(HIPEBEAMLDFLAGS) $(LDFLAGS) $(INIT_OBJS) $(OBJS) $(LIBS) \
-Wl,-O2 -T sys/p16_legacy_hack2.ldf
-T sys/p16_legacy_hack2.ldf

$(BINDIR)/$(EMULATOR_EXECUTABLE).srec: $(BINDIR)/$(EMULATOR_EXECUTABLE)
$(V_OBJCOPY) --srec-forceS3 --output-target srec \
$(BINDIR)/$(EMULATOR_EXECUTABLE) $(BINDIR)/$(EMULATOR_EXECUTABLE).srec
$(V_OBJCOPY) --srec-forceS3 --output-target srec $< $@

# ----------------------------------------------------------------------
# Dependencies
#
Makefile: Makefile.in
Makefile: Makefile.in config.status
$(gen_verbose) ./config.status

include/config.h: config.h.in
$(gen_verbose) ./config.status

include/erl_int_sizes_config.h: ../../include/erl_int_sizes_config.h.in
$(gen_verbose) ./config.status

config.status configure: configure.in
@echo
@echo "Makefile.in has been updated, please re-run configure!"
@echo "configure.in has been updated, please re-run autoreconf and configure"
@echo
@exit 1

Expand Down Expand Up @@ -534,37 +541,37 @@ DEP_CC=$(CC)
DEP_FLAGS=-MM -MG $(CFLAGS) $(INCLUDES)
SYS_SRC=$(ALL_SYS_SRC)

# .PHONY: $(TARGET)/gen_git_version.mk
# $(TARGET)/gen_git_version.mk:
# # We touch beam/erl_bif.info.c if we regenerated the git version to force a
# # rebuild.
# $(gen_verbose)
# $(V_at)if ../utils/gen_git_version $@; then touch beam/erl_bif_info.c; fi

# .PHONY: depend
# ifdef VOID_EMULATOR
# depend:
# @echo $(VOID_EMULATOR)' - omitted target depend'
# else
# depend: $(TTF_DIR)/depend.mk
# $(TTF_DIR)/depend.mk: $(TTF_DIR)/GENERATED $(PRELOAD_SRC) $(CP_BEAM_SRC)
# $(gen_verbose)
# $(V_at)$(DEP_CC) $(DEP_FLAGS) $(BEAM_SRC) \
# | $(SED_DEPEND) > $(TTF_DIR)/depend.mk
# $(V_at)$(DEP_CC) $(DEP_FLAGS) $(CP_BEAM_SRC) \
# | $(SED_DEPEND) > $(TTF_DIR)/depend.mk
# $(V_at)$(DEP_CC) $(DEP_FLAGS) $(SYS_SRC) \
# | $(SED_DEPEND) >> $(TTF_DIR)/depend.mk
# $(V_at)$(DEP_CC) $(DEP_FLAGS) $(TARGET_SRC) \
# | $(SED_DEPEND) >> $(TTF_DIR)/depend.mk
# $(V_at)$(DEP_CC) $(DEP_FLAGS) $(ERTS_LIB_SRC) \
# | $(SED_DEPEND) >> $(TTF_DIR)/depend.mk
# endif

# ifneq ($(MAKECMDGOALS),clean)
# ifneq ($(MAKECMDGOALS),generate)
# ifndef VOID_EMULATOR
# -include $(TTF_DIR)/depend.mk
# endif
# endif
# endif
.PHONY: $(TARGET)/gen_git_version.mk
$(TARGET)/gen_git_version.mk:
# We touch beam/erl_bif.info.c if we regenerated the git version to force a
# rebuild.
$(gen_verbose)
$(V_at)if ../utils/gen_git_version $@; then touch beam/erl_bif_info.c; fi

.PHONY: depend
ifdef VOID_EMULATOR
depend:
@echo $(VOID_EMULATOR)' - omitted target depend'
else
depend: $(TTF_DIR)/depend.mk
$(TTF_DIR)/depend.mk: $(TTF_DIR)/GENERATED $(PRELOAD_SRC)
$(gen_verbose)
$(V_at)$(DEP_CC) $(DEP_FLAGS) $(BEAM_SRC) \
| $(SED_DEPEND) > $(TTF_DIR)/depend.mk
$(V_at)$(DEP_CC) $(DEP_FLAGS) $(CP_BEAM_SRC) \
| $(SED_DEPEND) > $(TTF_DIR)/depend.mk
$(V_at)$(DEP_CC) $(DEP_FLAGS) $(SYS_SRC) \
| $(SED_DEPEND) >> $(TTF_DIR)/depend.mk
$(V_at)$(DEP_CC) $(DEP_FLAGS) $(TARGET_SRC) \
| $(SED_DEPEND) >> $(TTF_DIR)/depend.mk
$(V_at)$(DEP_CC) $(DEP_FLAGS) $(ERTS_LIB_SRC) \
| $(SED_DEPEND) >> $(TTF_DIR)/depend.mk
endif

ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),generate)
ifndef VOID_EMULATOR
-include $(TTF_DIR)/depend.mk
endif
endif
endif
21 changes: 20 additions & 1 deletion erts/emulator/slave/configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ if test "x$no_recursion" != "xyes" -a "x$OVERRIDE_CONFIG_CACHE" = "x"; then
cache_file=/dev/null
fi

## Now, make sure that ERL_TOP is set and is the same as srcdir
##
if test -z "$ERL_TOP" || test ! -d $ERL_TOP ; then
AC_MSG_ERROR(You need to set the environment variable ERL_TOP!)
fi
if test ! "${ERL_TOP}/erts/emulator/slave" -ef "$srcdir"; then
AC_MSG_ERROR([You need to run configure with argument --srcdir=${ERL_TOP}/erts/emulator/slave])
fi
erl_top=${ERL_TOP}

# echo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
# echo X
# echo "X srcdir = $srcdir"
Expand Down Expand Up @@ -176,10 +186,18 @@ AC_CHECK_PROGS([OBJCOPY],
["$ac_tool_prefix"objcopy epiphany-unknown-elf-objcopy \
epiphany-elf-objcopy e-objcopy objcopy],
[none])
if test "x$OBJDUMP" = xnone; then
if test "X$OBJCOPY" = Xnone; then
AC_MSG_ERROR([objcopy not found])
fi

AC_CHECK_PROGS([OBJDUMP],
["$ac_tool_prefix"objdump epiphany-unknown-elf-objdump \
epiphany-elf-objdump e-objdump objdump],
[none])
if test "X$OBJDUMP" = Xnone; then
AC_MSG_ERROR([objdump not found])
fi

AC_PROG_SED
AC_PROG_EGREP

Expand Down Expand Up @@ -1712,4 +1730,5 @@ dnl Note that the output files are relative to $srcdir

AC_OUTPUT(
Makefile
info.mk
)
25 changes: 25 additions & 0 deletions erts/emulator/slave/info.mk.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#
# %CopyrightBegin%
#
# Copyright Ericsson AB 1996-2015. All Rights Reserved.
#
# The contents of this file are subject to the Erlang Public License,
# Version 1.1, (the "License"); you may not use this file except in
# compliance with the License. You should have received a copy of the
# Erlang Public License along with this software. If not, it can be
# retrieved online at http://www.erlang.org/.
#
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
# the License for the specific language governing rights and limitations
# under the License.
#
# %CopyrightEnd%
#

# This file is intended to be included by higher-level Makefiles that need to
# cooperate with the slave emulator build process.

SLAVE_TARGET=@TARGET@
SLAVE_EXECUTABLE=$(ERL_TOP)/bin/$(SLAVE_TARGET)/slave$(TF_MARKER)
SLAVE_OBJDUMP=@OBJDUMP@
2 changes: 1 addition & 1 deletion otp_build
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ EXPECTED_AUTOCONF_VERSION=2.59
if [ -z "$ONLY_ERTS" ]; then
AUTOCONF_SUBDIRS="lib lib/* lib/test_server/src"
fi
AUTOCONF_SUBDIRS="$AUTOCONF_SUBDIRS erts ."
AUTOCONF_SUBDIRS="$AUTOCONF_SUBDIRS erts/emulator/slave erts ."

# `bootstrap_apps' should include application that are built, or
# partly built in one of the bootstrap phases. Applications that
Expand Down

0 comments on commit fb8a6ad

Please sign in to comment.