public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gprofng: 30894 bison should be no hard dependency
@ 2023-10-05  1:42 vladimir.mezentsev
  2023-10-05  8:57 ` Sam James
  0 siblings, 1 reply; 3+ messages in thread
From: vladimir.mezentsev @ 2023-10-05  1:42 UTC (permalink / raw)
  To: binutils; +Cc: Vladimir Mezentsev

From: Vladimir Mezentsev <vladimir.mezentsev@oracle.com>

When running from a distribution tarball, bison should not be necessary.
The generated files (QLParser.tab.cc, QLParser.tab.hh) should be distributed.
configure.ac should not abort if bison is missing.
configure.ac should remove temporary files (dummy.c, Simple.class).
bison must be run once to create QLParser.tab.cc and QLParser.tab.hh.

gprofng/ChangeLog
2023-10-03  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

	PR gprofng/30894
	* configure.ac: Don't abort if bison is missing. Remove temporary files.
	* src/Makefile.am: Distribute QLParser.tab.cc and QLParser.tab.hh.
	* Run bison once to create QLParser.tab.cc and QLParser.tab.hh.
	* configure: Rebuild.
	* src/Makefile.in: Rebuild.
---
 gprofng/configure       | 15 ++++++---------
 gprofng/configure.ac    | 11 ++++-------
 gprofng/src/Makefile.am | 19 ++++++++++++++++---
 gprofng/src/Makefile.in | 22 +++++++++++++++++-----
 4 files changed, 43 insertions(+), 24 deletions(-)

diff --git a/gprofng/configure b/gprofng/configure
index 005f9cbaf7d..90f869829f6 100755
--- a/gprofng/configure
+++ b/gprofng/configure
@@ -6113,9 +6113,6 @@ $as_echo "$ac_prog_version" >&6; }
   fi
 
 
-if test x$BISON = "x:"; then
-  as_fn_error $? "Building gprofng requires bison 3.0.4 or later." "$LINENO" 5
-fi
 
 # Check whether --enable-shared was given.
 if test "${enable_shared+set}" = set; then :
@@ -12252,7 +12249,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12255 "configure"
+#line 12252 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12358,7 +12355,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12361 "configure"
+#line 12358 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -16609,14 +16606,14 @@ else
 $as_echo "#define GPROFNG_JAVA_PROFILING 1" >>confdefs.h
 
     if test "x$JAVAC" != x; then
-      cat > configtest.java << EOF
+      cat > Simple.java << EOF
 class Simple{
   public static void main(String args){
     System.out.println("Hello Java");
   }
 }
 EOF
-      if { ac_try='$JAVAC configtest.java >&5 2>&5'
+      if { ac_try='$JAVAC Simple.java >&5 2>&5'
   { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
   (eval $ac_try) 2>&5
   ac_status=$?
@@ -16626,7 +16623,7 @@ EOF
       else
 	GPROFNG_BROKEN_JAVAC=yes
       fi
-      rm -f configtest.*
+      rm -f Simple.*
     fi
 fi
 
@@ -16677,7 +16674,7 @@ if test "$LIBC" = musl; then
 $as_echo "#define __MUSL_LIBC 1" >>confdefs.h
 
 fi
-
+rm -f dummy.c
 
 # Check if linker supports --as-needed and --no-as-needed options.
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking linker --as-needed support" >&5
diff --git a/gprofng/configure.ac b/gprofng/configure.ac
index cfca82e3651..7938d7b2cb0 100644
--- a/gprofng/configure.ac
+++ b/gprofng/configure.ac
@@ -30,9 +30,6 @@ AC_PROG_INSTALL
 AC_PROG_RANLIB
 AM_PROG_AR
 gl_PROG_BISON([BISON],[3.0.4])
-if test x$BISON = "x:"; then
-  AC_MSG_ERROR([Building gprofng requires bison 3.0.4 or later.])
-fi
 
 AC_DISABLE_SHARED
 LT_INIT
@@ -130,19 +127,19 @@ if test "x$enable_gprofng_jp" = x; then
 else
     AC_DEFINE(GPROFNG_JAVA_PROFILING, 1, [Enable java profiling])
     if test "x$JAVAC" != x; then
-      cat > configtest.java << EOF
+      cat > Simple.java << EOF
 class Simple{
   public static void main(String args[]){
     System.out.println("Hello Java");
   }
 }
 EOF
-      if AC_TRY_COMMAND($JAVAC configtest.java >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD); then
+      if AC_TRY_COMMAND($JAVAC Simple.java >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD); then
 	GPROFNG_BROKEN_JAVAC=no
       else
 	GPROFNG_BROKEN_JAVAC=yes
       fi
-      rm -f configtest.*
+      rm -f Simple.*
     fi
 fi
 AC_SUBST(GPROFNG_BROKEN_JAVAC)
@@ -177,7 +174,7 @@ eval "$cc_set_libc"
 if test "$LIBC" = musl; then
   AC_DEFINE(__MUSL_LIBC, 1, [Build with musl-libc.])
 fi
-
+rm -f dummy.c
 
 # Check if linker supports --as-needed and --no-as-needed options.
 AC_CACHE_CHECK(linker --as-needed support, bfd_cv_ld_as_needed,
diff --git a/gprofng/src/Makefile.am b/gprofng/src/Makefile.am
index 219367fb9ce..adc3c581df3 100644
--- a/gprofng/src/Makefile.am
+++ b/gprofng/src/Makefile.am
@@ -117,12 +117,25 @@ AM_CFLAGS = $(GPROFNG_CFLAGS) $(PTHREAD_CFLAGS) \
 	$(GPROFNG_NO_SWITCH_CFLAGS)
 AM_CXXFLAGS = $(AM_CFLAGS)
 
-QLParser.tab.cc QLParser.tab.hh: QLParser.yy
+# bison generates two files QLParser.tab.cc, QLParser.tab.hh.
+# we don't know which file will be newer.
+# Make QLParser.tab.cc always newer than QLParser.tab.hh.
+QLParser.tab.hh: QLParser.yy
+	if test "$(BISON)" == ":"; then \
+	  echo "fatal: Building gprofng requires bison 3.0.4 or later."; \
+	  exit 1; \
+	fi; \
 	$(BISON) $^
 
-BUILT_SOURCES = QLParser.tab.hh
-EXTRA_DIST = QLParser.yy
+QLParser.tab.cc: QLParser.tab.hh
+	touch $@
 
+BUILT_SOURCES = QLParser.tab.cc QLParser.tab.hh
+EXTRA_DIST = QLParser.tab.cc QLParser.tab.hh QLParser.yy
+
+# info and diststuff are needed for src-release.sh:
+info: $(BUILT_SOURCES)
+diststuff: info
 
 lib_LTLIBRARIES = $(LIBGPROFNG)
 libgprofng_la_SOURCES = $(CCSOURCES) $(CSOURCES)
diff --git a/gprofng/src/Makefile.in b/gprofng/src/Makefile.in
index b881268b0d9..76a0c950079 100644
--- a/gprofng/src/Makefile.in
+++ b/gprofng/src/Makefile.in
@@ -543,8 +543,8 @@ AM_CFLAGS = $(GPROFNG_CFLAGS) $(PTHREAD_CFLAGS) \
 	$(GPROFNG_NO_SWITCH_CFLAGS)
 
 AM_CXXFLAGS = $(AM_CFLAGS)
-BUILT_SOURCES = QLParser.tab.hh
-EXTRA_DIST = QLParser.yy
+BUILT_SOURCES = QLParser.tab.cc QLParser.tab.hh
+EXTRA_DIST = QLParser.tab.cc QLParser.tab.hh QLParser.yy
 lib_LTLIBRARIES = $(LIBGPROFNG)
 libgprofng_la_SOURCES = $(CCSOURCES) $(CSOURCES)
 libgprofng_la_LDFLAGS = -version-info 0:0:0
@@ -1021,8 +1021,6 @@ html: html-am
 
 html-am:
 
-info: info-am
-
 info-am:
 
 install-data-am: install-dbeDATA
@@ -1096,9 +1094,23 @@ uninstall-am: uninstall-binPROGRAMS uninstall-dbeDATA \
 .PRECIOUS: Makefile
 
 
-QLParser.tab.cc QLParser.tab.hh: QLParser.yy
+# bison generates two files QLParser.tab.cc, QLParser.tab.hh.
+# we don't know which file will be newer.
+# Make QLParser.tab.cc always newer than QLParser.tab.hh.
+QLParser.tab.hh: QLParser.yy
+	if test "$(BISON)" == ":"; then \
+	  echo "fatal: Building gprofng requires bison 3.0.4 or later."; \
+	  exit 1; \
+	fi; \
 	$(BISON) $^
 
+QLParser.tab.cc: QLParser.tab.hh
+	touch $@
+
+# info and diststuff are needed for src-release.sh:
+info: $(BUILT_SOURCES)
+diststuff: info
+
 # Distribution involves building the binaries to generate the manpage,
 # so ensure that the necessary libraries are built at dist time.
 dist-hook: $(LIBGPROFNG)
-- 
2.31.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gprofng: 30894 bison should be no hard dependency
  2023-10-05  1:42 [PATCH] gprofng: 30894 bison should be no hard dependency vladimir.mezentsev
@ 2023-10-05  8:57 ` Sam James
  2023-10-05 14:57   ` Vladimir Mezentsev
  0 siblings, 1 reply; 3+ messages in thread
From: Sam James @ 2023-10-05  8:57 UTC (permalink / raw)
  To: vladimir.mezentsev; +Cc: binutils


Vladimir Mezentsev via Binutils <binutils@sourceware.org> writes:

> From: Vladimir Mezentsev <vladimir.mezentsev@oracle.com>
>
> When running from a distribution tarball, bison should not be necessary.
> The generated files (QLParser.tab.cc, QLParser.tab.hh) should be distributed.
> configure.ac should not abort if bison is missing.
> configure.ac should remove temporary files (dummy.c, Simple.class).
> bison must be run once to create QLParser.tab.cc and QLParser.tab.hh.
>
> gprofng/ChangeLog
> 2023-10-03  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>
>
> 	PR gprofng/30894
> 	* configure.ac: Don't abort if bison is missing. Remove temporary files.
> 	* src/Makefile.am: Distribute QLParser.tab.cc and QLParser.tab.hh.
> 	* Run bison once to create QLParser.tab.cc and QLParser.tab.hh.
> 	* configure: Rebuild.
> 	* src/Makefile.in: Rebuild.
> ---
>  gprofng/configure       | 15 ++++++---------
>  gprofng/configure.ac    | 11 ++++-------
>  gprofng/src/Makefile.am | 19 ++++++++++++++++---
>  gprofng/src/Makefile.in | 22 +++++++++++++++++-----
>  4 files changed, 43 insertions(+), 24 deletions(-)
>
> diff --git a/gprofng/configure b/gprofng/configure
> index 005f9cbaf7d..90f869829f6 100755
> --- a/gprofng/configure
> +++ b/gprofng/configure
> @@ -6113,9 +6113,6 @@ $as_echo "$ac_prog_version" >&6; }
>    fi
>  
>  
> -if test x$BISON = "x:"; then
> -  as_fn_error $? "Building gprofng requires bison 3.0.4 or later." "$LINENO" 5
> -fi
>  
>  # Check whether --enable-shared was given.
>  if test "${enable_shared+set}" = set; then :
> @@ -12252,7 +12249,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 12255 "configure"
> +#line 12252 "configure"
>  #include "confdefs.h"
>  
>  #if HAVE_DLFCN_H
> @@ -12358,7 +12355,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 12361 "configure"
> +#line 12358 "configure"
>  #include "confdefs.h"
>  
>  #if HAVE_DLFCN_H
> @@ -16609,14 +16606,14 @@ else
>  $as_echo "#define GPROFNG_JAVA_PROFILING 1" >>confdefs.h
>  
>      if test "x$JAVAC" != x; then
> -      cat > configtest.java << EOF
> +      cat > Simple.java << EOF
>  class Simple{
>    public static void main(String args){
>      System.out.println("Hello Java");
>    }
>  }
>  EOF
> -      if { ac_try='$JAVAC configtest.java >&5 2>&5'
> +      if { ac_try='$JAVAC Simple.java >&5 2>&5'
>    { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
>    (eval $ac_try) 2>&5
>    ac_status=$?
> @@ -16626,7 +16623,7 @@ EOF
>        else
>  	GPROFNG_BROKEN_JAVAC=yes
>        fi
> -      rm -f configtest.*
> +      rm -f Simple.*
>      fi
>  fi
>  
> @@ -16677,7 +16674,7 @@ if test "$LIBC" = musl; then
>  $as_echo "#define __MUSL_LIBC 1" >>confdefs.h
>  
>  fi
> -
> +rm -f dummy.c
>  
>  # Check if linker supports --as-needed and --no-as-needed options.
>  { $as_echo "$as_me:${as_lineno-$LINENO}: checking linker --as-needed support" >&5
> diff --git a/gprofng/configure.ac b/gprofng/configure.ac
> index cfca82e3651..7938d7b2cb0 100644
> --- a/gprofng/configure.ac
> +++ b/gprofng/configure.ac
> @@ -30,9 +30,6 @@ AC_PROG_INSTALL
>  AC_PROG_RANLIB
>  AM_PROG_AR
>  gl_PROG_BISON([BISON],[3.0.4])
> -if test x$BISON = "x:"; then
> -  AC_MSG_ERROR([Building gprofng requires bison 3.0.4 or later.])
> -fi
>  
>  AC_DISABLE_SHARED
>  LT_INIT
> @@ -130,19 +127,19 @@ if test "x$enable_gprofng_jp" = x; then
>  else
>      AC_DEFINE(GPROFNG_JAVA_PROFILING, 1, [Enable java profiling])
>      if test "x$JAVAC" != x; then
> -      cat > configtest.java << EOF
> +      cat > Simple.java << EOF
>  class Simple{
>    public static void main(String args[]){
>      System.out.println("Hello Java");
>    }
>  }
>  EOF
> -      if AC_TRY_COMMAND($JAVAC configtest.java >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD); then
> +      if AC_TRY_COMMAND($JAVAC Simple.java >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD); then
>  	GPROFNG_BROKEN_JAVAC=no
>        else
>  	GPROFNG_BROKEN_JAVAC=yes
>        fi
> -      rm -f configtest.*
> +      rm -f Simple.*
>      fi
>  fi
>  AC_SUBST(GPROFNG_BROKEN_JAVAC)
> @@ -177,7 +174,7 @@ eval "$cc_set_libc"
>  if test "$LIBC" = musl; then
>    AC_DEFINE(__MUSL_LIBC, 1, [Build with musl-libc.])
>  fi
> -
> +rm -f dummy.c
>  
>  # Check if linker supports --as-needed and --no-as-needed options.
>  AC_CACHE_CHECK(linker --as-needed support, bfd_cv_ld_as_needed,
> diff --git a/gprofng/src/Makefile.am b/gprofng/src/Makefile.am
> index 219367fb9ce..adc3c581df3 100644
> --- a/gprofng/src/Makefile.am
> +++ b/gprofng/src/Makefile.am
> @@ -117,12 +117,25 @@ AM_CFLAGS = $(GPROFNG_CFLAGS) $(PTHREAD_CFLAGS) \
>  	$(GPROFNG_NO_SWITCH_CFLAGS)
>  AM_CXXFLAGS = $(AM_CFLAGS)
>  
> -QLParser.tab.cc QLParser.tab.hh: QLParser.yy
> +# bison generates two files QLParser.tab.cc, QLParser.tab.hh.
> +# we don't know which file will be newer.
> +# Make QLParser.tab.cc always newer than QLParser.tab.hh.
> +QLParser.tab.hh: QLParser.yy
> +	if test "$(BISON)" == ":"; then \
> +	  echo "fatal: Building gprofng requires bison 3.0.4 or later."; \
> +	  exit 1; \
> +	fi; \
>  	$(BISON) $^
>  
> -BUILT_SOURCES = QLParser.tab.hh
> -EXTRA_DIST = QLParser.yy
> +QLParser.tab.cc: QLParser.tab.hh
> +	touch $@
>  
> +BUILT_SOURCES = QLParser.tab.cc QLParser.tab.hh
> +EXTRA_DIST = QLParser.tab.cc QLParser.tab.hh QLParser.yy
> +
> +# info and diststuff are needed for src-release.sh:
> +info: $(BUILT_SOURCES)
> +diststuff: info
>  
>  lib_LTLIBRARIES = $(LIBGPROFNG)
>  libgprofng_la_SOURCES = $(CCSOURCES) $(CSOURCES)
> diff --git a/gprofng/src/Makefile.in b/gprofng/src/Makefile.in
> index b881268b0d9..76a0c950079 100644
> --- a/gprofng/src/Makefile.in
> +++ b/gprofng/src/Makefile.in
> @@ -543,8 +543,8 @@ AM_CFLAGS = $(GPROFNG_CFLAGS) $(PTHREAD_CFLAGS) \
>  	$(GPROFNG_NO_SWITCH_CFLAGS)
>  
>  AM_CXXFLAGS = $(AM_CFLAGS)
> -BUILT_SOURCES = QLParser.tab.hh
> -EXTRA_DIST = QLParser.yy
> +BUILT_SOURCES = QLParser.tab.cc QLParser.tab.hh
> +EXTRA_DIST = QLParser.tab.cc QLParser.tab.hh QLParser.yy
>  lib_LTLIBRARIES = $(LIBGPROFNG)
>  libgprofng_la_SOURCES = $(CCSOURCES) $(CSOURCES)
>  libgprofng_la_LDFLAGS = -version-info 0:0:0
> @@ -1021,8 +1021,6 @@ html: html-am
>  
>  html-am:
>  
> -info: info-am
> -
>  info-am:
>  
>  install-data-am: install-dbeDATA
> @@ -1096,9 +1094,23 @@ uninstall-am: uninstall-binPROGRAMS uninstall-dbeDATA \
>  .PRECIOUS: Makefile
>  
>  
> -QLParser.tab.cc QLParser.tab.hh: QLParser.yy
> +# bison generates two files QLParser.tab.cc, QLParser.tab.hh.
> +# we don't know which file will be newer.
> +# Make QLParser.tab.cc always newer than QLParser.tab.hh.
> +QLParser.tab.hh: QLParser.yy
> +	if test "$(BISON)" == ":"; then \

Please use =, not ==, as == is a Bashism and configure scripts (etc)
must work with POSIX shell.

> +	  echo "fatal: Building gprofng requires bison 3.0.4 or later."; \
> +	  exit 1; \
> +	fi; \
>  	$(BISON) $^
>  
> +QLParser.tab.cc: QLParser.tab.hh
> +	touch $@
> +
> +# info and diststuff are needed for src-release.sh:
> +info: $(BUILT_SOURCES)
> +diststuff: info
> +
>  # Distribution involves building the binaries to generate the manpage,
>  # so ensure that the necessary libraries are built at dist time.
>  dist-hook: $(LIBGPROFNG)


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gprofng: 30894 bison should be no hard dependency
  2023-10-05  8:57 ` Sam James
@ 2023-10-05 14:57   ` Vladimir Mezentsev
  0 siblings, 0 replies; 3+ messages in thread
From: Vladimir Mezentsev @ 2023-10-05 14:57 UTC (permalink / raw)
  To: Sam James; +Cc: binutils

[-- Attachment #1: Type: text/plain, Size: 485 bytes --]



On 10/5/23 01:57, Sam James wrote:
>> -QLParser.tab.cc QLParser.tab.hh: QLParser.yy
>> +# bison generates two files QLParser.tab.cc, QLParser.tab.hh.
>> +# we don't know which file will be newer.
>> +# Make QLParser.tab.cc always newer than QLParser.tab.hh.
>> +QLParser.tab.hh: QLParser.yy
>> +	if test "$(BISON)" == ":"; then \
> Please use =, not ==, as == is a Bashism and configure scripts (etc)
> must work with POSIX shell.
>

I will fix this.
Thank you for review.
-Vladimir

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-10-05 14:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-05  1:42 [PATCH] gprofng: 30894 bison should be no hard dependency vladimir.mezentsev
2023-10-05  8:57 ` Sam James
2023-10-05 14:57   ` Vladimir Mezentsev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).