From b51886421e721bb9539f9f8c91ac879c170a70f9 Mon Sep 17 00:00:00 2001 From: Masamichi Takagi Date: Wed, 5 Sep 2018 13:14:36 +0900 Subject: [PATCH] uti: Don't compile syscall_intercept related stuff when not specified with configure option Change-Id: I9be8cb9b3fcae78d33a33b057c43caee23a81fc1 --- config.h.in | 3 ++ configure | 89 +++++++++++++++++++++++++++++++++++++++ configure.ac | 28 ++++++++++++ executer/user/Makefile.in | 9 +++- executer/user/mcexec.c | 7 +++ ihk | 2 +- 6 files changed, 136 insertions(+), 2 deletions(-) diff --git a/config.h.in b/config.h.in index bb296a8b..0ff560da 100644 --- a/config.h.in +++ b/config.h.in @@ -86,3 +86,6 @@ /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS + +/* whether or not syscall_intercept library is linked */ +#undef WITH_SYSCALL_INTERCEPT diff --git a/configure b/configure index 93fcc281..16fa20dd 100755 --- a/configure +++ b/configure @@ -628,6 +628,7 @@ IHK_RELEASE_DATE DCFA_VERSION MCKERNEL_VERSION IHK_VERSION +WITH_SYSCALL_INTERCEPT ENABLE_QLMPI ENABLE_RUSAGE ENABLE_MCOVERLAYFS @@ -3529,6 +3530,7 @@ fi + # Check whether --with-syscall_intercept was given. if test "${with_syscall_intercept+set}" = set; then : withval=$with_syscall_intercept; case "$withval" in #( @@ -3640,6 +3642,81 @@ fi fi + if test -n "${with_syscall_intercept}" || test -n "${with_syscall_intercept_include}" || test -n "${with_syscall_intercept_lib}"; then : + WITH_SYSCALL_INTERCEPT=yes +else + WITH_SYSCALL_INTERCEPT=no +fi + + +if test "x$WITH_SYSCALL_INTERCEPT" == "xno" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for syscall_no_intercept in -lsyscall_intercept" >&5 +$as_echo_n "checking for syscall_no_intercept in -lsyscall_intercept... " >&6; } +if ${ac_cv_lib_syscall_intercept_syscall_no_intercept+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsyscall_intercept -lcapstone -ldl $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char syscall_no_intercept (); +int +main () +{ +return syscall_no_intercept (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_syscall_intercept_syscall_no_intercept=yes +else + ac_cv_lib_syscall_intercept_syscall_no_intercept=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_syscall_intercept_syscall_no_intercept" >&5 +$as_echo "$ac_cv_lib_syscall_intercept_syscall_no_intercept" >&6; } +if test "x$ac_cv_lib_syscall_intercept_syscall_no_intercept" = xyes; then : + syscall_intercept_lib_found=yes +else + syscall_intercept_lib_found=no +fi + + if test "x$syscall_intercept_lib_found" != "xyes"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: libsyscall_intercept.so not found" >&5 +$as_echo "$as_me: libsyscall_intercept.so not found" >&6;} +fi + + ac_fn_c_check_header_mongrel "$LINENO" "libsyscall_intercept_hook_point.h" "ac_cv_header_libsyscall_intercept_hook_point_h" "$ac_includes_default" +if test "x$ac_cv_header_libsyscall_intercept_hook_point_h" = xyes; then : + syscall_intercept_header_found=yes +else + syscall_intercept_header_found=no +fi + + + if test "x$syscall_intercept_header_found" != "xyes"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: libsyscall_intercept_hook_point.h not found" >&5 +$as_echo "$as_me: libsyscall_intercept_hook_point.h not found" >&6;} +fi + + if test "x$syscall_intercept_lib_found" == "xyes" && test "x$syscall_intercept_header_found" == "xyes"; then : + WITH_SYSCALL_INTERCEPT=yes +else + WITH_SYSCALL_INTERCEPT=no +fi +fi + # Check whether --with-kernelsrc was given. @@ -4722,6 +4799,17 @@ else $as_echo "$as_me: perf is disabled" >&6;} fi +if test "x$WITH_SYSCALL_INTERCEPT" = "xyes" ; then + +$as_echo "#define WITH_SYSCALL_INTERCEPT 1" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: syscall_intercept library is linked" >&5 +$as_echo "$as_me: syscall_intercept library is linked" >&6;} +else + { $as_echo "$as_me:${as_lineno-$LINENO}: syscall_intercept library isn't linked" >&5 +$as_echo "$as_me: syscall_intercept library isn't linked" >&6;} +fi + if test "x$MCKERNEL_INCDIR" != "x" ; then cat >>confdefs.h <<_ACEOF @@ -4792,6 +4880,7 @@ fi + ac_config_headers="$ac_config_headers config.h" diff --git a/configure.ac b/configure.ac index ee122385..e8a0caca 100644 --- a/configure.ac +++ b/configure.ac @@ -123,6 +123,10 @@ AC_DEFUN([PAC_SET_HEADER_LIB_PATH_SYSCALL_INTERCEPT],[ [PAC_APPEND_FLAG([-L${with_$1}/lib64 -Wl,-rpath,${with_$1}/lib64],[LDFLAGS_SYSCALL_INTERCEPT])]) ]) ]) + + AS_IF([test -n "${with_$1}" || test -n "${with_$1_include}" || test -n "${with_$1_lib}"], + [WITH_SYSCALL_INTERCEPT=yes], + [WITH_SYSCALL_INTERCEPT=no]) ]) IHK_VERSION=IHK_VERSION_m4 @@ -142,8 +146,24 @@ AS_IF([test "x$numa_lib_found" != "xyes"], [AC_MSG_ERROR([Unable to find NUMA library, missing numactl-devel?])]) PAC_SET_HEADER_LIB_PATH([mpi]) + PAC_SET_HEADER_LIB_PATH_SYSCALL_INTERCEPT([syscall_intercept]) +if test "x$WITH_SYSCALL_INTERCEPT" == "xno" ; then + AC_CHECK_LIB([syscall_intercept],[syscall_no_intercept],[syscall_intercept_lib_found=yes],[syscall_intercept_lib_found=no],[-lcapstone -ldl]) + AS_IF([test "x$syscall_intercept_lib_found" != "xyes"], + [AC_MSG_NOTICE([libsyscall_intercept.so not found])]) + + AC_CHECK_HEADER([libsyscall_intercept_hook_point.h],[syscall_intercept_header_found=yes],[syscall_intercept_header_found=no]) + AS_IF([test "x$syscall_intercept_header_found" != "xyes"], + [AC_MSG_NOTICE([libsyscall_intercept_hook_point.h not found])]) + + AS_IF([test "x$syscall_intercept_lib_found" == "xyes" && test "x$syscall_intercept_header_found" == "xyes"], + [WITH_SYSCALL_INTERCEPT=yes], + [WITH_SYSCALL_INTERCEPT=no]) +fi + + AC_ARG_WITH([kernelsrc], AC_HELP_STRING( [--with-kernelsrc=path],[Path to 'kernel src', default is /lib/modules/uname_r/build]), @@ -466,6 +486,13 @@ else AC_MSG_NOTICE([perf is disabled]) fi +if test "x$WITH_SYSCALL_INTERCEPT" = "xyes" ; then + AC_DEFINE([WITH_SYSCALL_INTERCEPT],[1],[whether or not syscall_intercept library is linked]) + AC_MSG_NOTICE([syscall_intercept library is linked]) +else + AC_MSG_NOTICE([syscall_intercept library isn't linked]) +fi + if test "x$MCKERNEL_INCDIR" != "x" ; then AC_DEFINE_UNQUOTED(MCKERNEL_INCDIR,"$MCKERNEL_INCDIR",[McKernel specific headers]) fi @@ -508,6 +535,7 @@ AC_SUBST(LDFLAGS_SYSCALL_INTERCEPT) AC_SUBST(ENABLE_MCOVERLAYFS) AC_SUBST(ENABLE_RUSAGE) AC_SUBST(ENABLE_QLMPI) +AC_SUBST(WITH_SYSCALL_INTERCEPT) AC_SUBST(IHK_VERSION) AC_SUBST(MCKERNEL_VERSION) diff --git a/executer/user/Makefile.in b/executer/user/Makefile.in index 835349ab..494c51db 100644 --- a/executer/user/Makefile.in +++ b/executer/user/Makefile.in @@ -17,18 +17,23 @@ CPPFLAGS_SYSCALL_INTERCEPT=@CPPFLAGS_SYSCALL_INTERCEPT@ LDFLAGS_SYSCALL_INTERCEPT=@LDFLAGS_SYSCALL_INTERCEPT@ RPATH=$(shell echo $(LDFLAGS)|awk '{for(i=1;i<=NF;i++){if($$i~/^-L/){w=$$i;sub(/^-L/,"-Wl,-rpath,",w);print w}}}') VPATH=@abs_srcdir@ -TARGET=mcexec libsched_yield ldump2mcdump.so syscall_intercept.so +TARGET=mcexec libsched_yield ldump2mcdump.so @uncomment_if_ENABLE_MEMDUMP@TARGET+=eclair LIBS=@LIBS@ IHKDIR ?= $(VPATH)/../../../ihk/linux/include/ MCEXEC_LIBS=-lmcexec -lrt -lnuma -pthread -L@abs_builddir@/../../../ihk/linux/user -lihk -Wl,-rpath,$(MCKERNEL_LIBDIR) ENABLE_QLMPI=@ENABLE_QLMPI@ +WITH_SYSCALL_INTERCEPT=@WITH_SYSCALL_INTERCEPT@ ifeq ($(ENABLE_QLMPI),yes) MCEXEC_LIBS += -lmpi TARGET+= libqlmpi.so ql_server ql_mpiexec_start ql_mpiexec_finalize ql_talker libqlfort.so endif +ifeq ($(WITH_SYSCALL_INTERCEPT),yes) + TARGET += syscall_intercept.so +endif + ifeq ($(ARCH), arm64) CFLAGS += $(foreach i, $(shell seq 1 100), $(addprefix -DPOSTK_DEBUG_ARCH_DEP_, $(i))) CFLAGS += $(foreach i, $(shell seq 1 100), $(addprefix -DPOSTK_DEBUG_TEMP_FIX_, $(i))) @@ -108,7 +113,9 @@ ifeq ($(ENABLE_QLMPI),yes) install -m 755 ql_mpiexec_finalize $(BINDIR) install -m 755 ql_talker $(SBINDIR) endif +ifeq ($(WITH_SYSCALL_INTERCEPT),yes) install -m 755 syscall_intercept.so $(MCKERNEL_LIBDIR) +endif @uncomment_if_ENABLE_MEMDUMP@install -m 755 eclair $(BINDIR) @uncomment_if_ENABLE_MEMDUMP@install -m 755 vmcore2mckdump $(BINDIR) diff --git a/executer/user/mcexec.c b/executer/user/mcexec.c index 270b5da3..0fc7892a 100644 --- a/executer/user/mcexec.c +++ b/executer/user/mcexec.c @@ -2178,6 +2178,13 @@ int main(int argc, char **argv) if (opendev() == -1) exit(EXIT_FAILURE); +#ifndef WITH_SYSCALL_INTERCEPT + if (enable_uti) { + __eprintf("ERROR: uti is not available when not configured with --with-syscall_intercept=\n"); + exit(EXIT_FAILURE); + } +#endif + ld_preload_init(); #ifdef ADD_ENVS_OPTION diff --git a/ihk b/ihk index e88b7d01..00634a82 160000 --- a/ihk +++ b/ihk @@ -1 +1 @@ -Subproject commit e88b7d011eb73b86d9b9fdcd2ef3b1691f36c684 +Subproject commit 00634a823ff0d3debfa381da5f1ac2f994fae388