From cac97c41c20c9866baecefbdc53976af1475f0a1 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Mon, 14 Mar 2022 15:38:04 -0700 Subject: [PATCH] gprofng: Skip jsynprog with a broken javac On CET enabled Linux/x86-64 machines, one can get $ javac simple.java Error: dl failure on line 894 Error: failed /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-6.fc35.x86_64/jre/lib/amd64/server/libjvm.so, because /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-6.fc35.x86_64/jre/lib/amd64/server/libjvm.so: rebuild shared object with SHSTK support enabled Set GPROFNG_BROKEN_JAVAC to "yes" only with a broken javac and skip the jsynprog test with a broken javac. PR gprofng/28965 * Makefile.am (GPROFNG_BROKEN_JAVAC): New. (check-DEJAGNU): Pass GPROFNG_BROKEN_JAVAC to runtest. * configure.ac (GPROFNG_BROKEN_JAVAC): New AC_SUBST. Set to yes with a broken javac. * Makefile.in: Regenerate. * configure: Likewise. * testsuite/gprofng.display/display.exp: Skip jsynprog with a broken javac. --- gprofng/Makefile.am | 2 ++ gprofng/Makefile.in | 2 ++ gprofng/configure | 27 +++++++++++++++++-- gprofng/configure.ac | 17 ++++++++++++ gprofng/testsuite/gprofng.display/display.exp | 8 +++++- 5 files changed, 53 insertions(+), 3 deletions(-) diff --git a/gprofng/Makefile.am b/gprofng/Makefile.am index 3bf707412ca..e06769cbf90 100644 --- a/gprofng/Makefile.am +++ b/gprofng/Makefile.am @@ -41,6 +41,7 @@ LD_NO_AS_NEEDED = @LD_NO_AS_NEEDED@ GPROFNG_CFLAGS = @GPROFNG_CFLAGS@ GPROFNG_CPPFLAGS = @GPROFNG_CPPFLAGS@ GPROFNG_LIBDIR = @GPROFNG_LIBDIR@ +GPROFNG_BROKEN_JAVAC = @GPROFNG_BROKEN_JAVAC@ AM_MAKEFLAGS = \ jdk_inc="$(jdk_inc)" \ @@ -59,6 +60,7 @@ check-DEJAGNU: site.exp development.exp runtest=$(RUNTEST); \ if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \ $$runtest --tool $(DEJATOOL) --srcdir $${srcroot}/testsuite \ + GPROFNG_BROKEN_JAVAC="$(GPROFNG_BROKEN_JAVAC)" \ MAKE="$(MAKE)" CC="$(CC)" CFLAGS="$(CFLAGS) $(PTHREAD_CFLAGS)" \ LDFLAGS="$(LDFLAGS)" LIBS="$(PTHREAD_LIBS) $(LIBS)" \ BUILDDIR="$(abs_top_builddir)" $(RUNTESTFLAGS); \ diff --git a/gprofng/Makefile.in b/gprofng/Makefile.in index 599fce5e879..27889c0f359 100644 --- a/gprofng/Makefile.in +++ b/gprofng/Makefile.in @@ -262,6 +262,7 @@ EXEEXT = @EXEEXT@ # Setup the testing framework, if you have one EXPECT = expect FGREP = @FGREP@ +GPROFNG_BROKEN_JAVAC = @GPROFNG_BROKEN_JAVAC@ GPROFNG_CFLAGS = @GPROFNG_CFLAGS@ GPROFNG_CPPFLAGS = @GPROFNG_CPPFLAGS@ GPROFNG_LIBADD = @GPROFNG_LIBADD@ @@ -934,6 +935,7 @@ uninstall-am: @TCL_TRY_TRUE@ runtest=$(RUNTEST); \ @TCL_TRY_TRUE@ if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \ @TCL_TRY_TRUE@ $$runtest --tool $(DEJATOOL) --srcdir $${srcroot}/testsuite \ +@TCL_TRY_TRUE@ GPROFNG_BROKEN_JAVAC="$(GPROFNG_BROKEN_JAVAC)" \ @TCL_TRY_TRUE@ MAKE="$(MAKE)" CC="$(CC)" CFLAGS="$(CFLAGS) $(PTHREAD_CFLAGS)" \ @TCL_TRY_TRUE@ LDFLAGS="$(LDFLAGS)" LIBS="$(PTHREAD_LIBS) $(LIBS)" \ @TCL_TRY_TRUE@ BUILDDIR="$(abs_top_builddir)" $(RUNTESTFLAGS); \ diff --git a/gprofng/configure b/gprofng/configure index 23a5dd8ef8e..983150f4f76 100755 --- a/gprofng/configure +++ b/gprofng/configure @@ -645,6 +645,7 @@ TCL_TRY_FALSE TCL_TRY_TRUE EXPECT jdk_inc +GPROFNG_BROKEN_JAVAC JAVA JAVAC PTHREAD_CFLAGS @@ -12135,7 +12136,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12138 "configure" +#line 12139 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -12241,7 +12242,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12244 "configure" +#line 12245 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -16528,6 +16529,7 @@ fi fi +GPROFNG_BROKEN_JAVAC=no if test "x$enable_gprofng_jp" = x; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Cannot find the JDK include directory. gprofng will be build without support for profiling Java applications. @@ -16539,9 +16541,30 @@ else $as_echo "#define GPROFNG_JAVA_PROFILING 1" >>confdefs.h + if test "x$JAVAC" != x; then + cat > configtest.java << EOF +class Simple{ + public static void main(String args){ + System.out.println("Hello Java"); + } +} +EOF + if { ac_try='$JAVAC conftest.java &5 2>&1' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 + (eval $ac_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then + GPROFNG_BROKEN_JAVAC=no + else + GPROFNG_BROKEN_JAVAC=yes + fi + rm -f configtest.* + fi fi + DEBUG= # Check whether --enable-gprofng-debug was given. if test "${enable_gprofng_debug+set}" = set; then : diff --git a/gprofng/configure.ac b/gprofng/configure.ac index c05e98192f3..7fcf6c3b1db 100644 --- a/gprofng/configure.ac +++ b/gprofng/configure.ac @@ -128,13 +128,30 @@ fi if test "x$enable_gprofng_jp" = x; then AC_CHECK_HEADER([jni.h], [ enable_gprofng_jp=yes ], [], [] ) fi +GPROFNG_BROKEN_JAVAC=no if test "x$enable_gprofng_jp" = x; then AC_MSG_WARN([ Cannot find the JDK include directory. gprofng will be build without support for profiling Java applications. Use --with-jdk=PATH to specify directory for the installed JDK]) else AC_DEFINE(GPROFNG_JAVA_PROFILING, 1, [Enable java profiling]) + if test "x$JAVAC" != x; then + cat > configtest.java << EOF +class Simple{ + public static void main(String args[]){ + System.out.println("Hello Java"); + } +} +EOF + if AC_TRY_COMMAND($JAVAC conftest.java &AS_MESSAGE_LOG_FD 2>&1); then + GPROFNG_BROKEN_JAVAC=no + else + GPROFNG_BROKEN_JAVAC=yes + fi + rm -f configtest.* + fi fi +AC_SUBST(GPROFNG_BROKEN_JAVAC) AC_SUBST(jdk_inc) DEBUG= diff --git a/gprofng/testsuite/gprofng.display/display.exp b/gprofng/testsuite/gprofng.display/display.exp index 108144c069a..dfb383e9fc6 100644 --- a/gprofng/testsuite/gprofng.display/display.exp +++ b/gprofng/testsuite/gprofng.display/display.exp @@ -68,6 +68,8 @@ switch $pltf { } } +global GPROFNG_BROKEN_JAVAC + foreach line $table { set dir [lindex $line 0] set cflags [lindex $line 1] @@ -75,7 +77,11 @@ foreach line $table { verbose [file rootname $line] verbose running display test $line - run_display_test $dir $cflags $gprofflags + if { $GPROFNG_BROKEN_JAVAC == "yes" && $dir == "jsynprog" } { + unsupported $dir + } else { + run_display_test $dir $cflags $gprofflags + } } -- 2.30.2