tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

databases/sqlite on powerpc



Hi,

it seems I've come across a compiler bug on NetBSD/powerpc
-current; the normal build log for databases/sqlite ends in my
case with

gcc -O2 -DUINT32_TYPE=u_int32_t -DUINT16_TYPE=u_int16_t -DUINT8_TYPE=u_int8_t -DINTPTR_TYPE=long -D_FORTIFY_SOURCE=2 -I/usr/include/readline -I/usr/include -o lemon ./tool/lemon.c
./tool/lemon.c: In function 'tplt_open':
./tool/lemon.c:2821:7: warning: implicit declaration of function 'access' [-Wimplicit-function-declaration]
 2821 |   if( access(buf,004)==0 ){
      |       ^~~~~~
./tool/lemon.c:2713:14: note: previous declaration of 'access' was here
 2713 |   extern int access();
      |              ^~~~~~
cp ./tool/lempar.c .
cp ./src/parse.y .
./lemon parse.y
gmake: *** [Makefile:262: parse.c] Segmentation fault (core dumped)
gmake: *** Deleting file 'parse.c'

Building the tool "lemon" with debugging reveals inside
print_stack_union() around line 3071:

    hash = (hash & 0x7fffffff)%arraysize;
    while( types[hash] ){

According to gdb, arraysize is 440, but the hash variable ends up
as -409 on the second line, which according to my understanding
Should Not Happen, and we get a SEGV.

Building the lemon tool without optimization makes the build
complete, so I conclude this is a compiler bug.

This is the in-tree gcc in NetBSD-current a week or two old:

gcc (nb1 20210411) 10.3.0

Suggested diff attached, which drops optimization from the tool
build of the "lemon" tool.  Optimization doesn't seem to be
important for this tool.

Looks OK to commit, even though this is done for all archs?
As near as I can tell, this is only a tool used during the
build.

Regards,

- Havard
Index: distinfo
===================================================================
RCS file: /cvsroot/pkgsrc/databases/sqlite/distinfo,v
retrieving revision 1.27
diff -u -p -r1.27 distinfo
--- distinfo	26 Oct 2021 10:10:05 -0000	1.27
+++ distinfo	22 Jun 2022 16:46:21 -0000
@@ -3,6 +3,6 @@ $NetBSD: distinfo,v 1.27 2021/10/26 10:1
 BLAKE2s (sqlite-2.8.17.tar.gz) = 2750dd8a0682b2047139de66b6a184b08e7674cb92846c629561604fc130fe37
 SHA512 (sqlite-2.8.17.tar.gz) = 966e0b7f7ebbaaa9e1899864475040946fd7b66363be778d29fadd5184623b1e62644f3c8d4c4ecd001b88044befa7c34d9de9f68590329a1a8301d854b73e3f
 Size (sqlite-2.8.17.tar.gz) = 969805 bytes
-SHA1 (patch-Makefile.in) = a7e6d0c15b6bd4c8c0f3a7123e82a145b3848703
+SHA1 (patch-Makefile.in) = a6e62db45de5bc6faebbb675004ed6dca9240e47
 SHA1 (patch-aa) = 4df2eff8c92b3e2bff86c710ef1a803d54201559
 SHA1 (patch-ab) = 00b7de05589fb62d511e26d0d864a8b5545967c8
Index: patches/patch-Makefile.in
===================================================================
RCS file: /cvsroot/pkgsrc/databases/sqlite/patches/patch-Makefile.in,v
retrieving revision 1.2
diff -u -p -r1.2 patch-Makefile.in
--- patches/patch-Makefile.in	16 Apr 2017 20:27:09 -0000	1.2
+++ patches/patch-Makefile.in	22 Jun 2022 16:46:21 -0000
@@ -2,10 +2,19 @@ $NetBSD: patch-Makefile.in,v 1.2 2017/04
 
 * Honour LDFLAGS for bl3.
 * Avoid a warning while generating config.h.
+* Build lemon without optimization to avoid compiler bug on NetBSD/powerpc
 
 --- Makefile.in.orig	2005-04-23 22:43:23.000000000 +0000
 +++ Makefile.in
-@@ -38,7 +38,7 @@ RELEASE = @ALLOWRELEASE@
+@@ -21,6 +21,7 @@ TOP = @srcdir@
+ # will run on the platform that is doing the build.
+ #
+ BCC = @BUILD_CC@ @BUILD_CFLAGS@
++BCC_NOOPT!= echo $(BCC) | sed -e 's/-O[01234]//'
+ 
+ # C Compile and options for use in building executables that 
+ # will run on the target platform.  (BCC and TCC are usually the
+@@ -38,7 +39,7 @@ RELEASE = @ALLOWRELEASE@
  
  # libtool compile/link/install
  LTCOMPILE = $(LIBTOOL) --mode=compile $(TCC)
@@ -14,7 +23,16 @@ $NetBSD: patch-Makefile.in,v 1.2 2017/04
  LTINSTALL = $(LIBTOOL) --mode=install $(INSTALL)
  
  # Compiler options needed for programs that use the TCL library.
-@@ -268,7 +268,8 @@ parse.c:	$(TOP)/src/parse.y lemon@BUILD_
+@@ -215,7 +216,7 @@ target_source:	$(SRC) $(VDBEHDR) 
+ # Rules to build the LEMON compiler generator
+ #
+ lemon@BUILD_EXEEXT@:	$(TOP)/tool/lemon.c $(TOP)/tool/lempar.c
+-	$(BCC) -o lemon $(TOP)/tool/lemon.c
++	$(BCC_NOOPT) -o lemon $(TOP)/tool/lemon.c
+ 	cp $(TOP)/tool/lempar.c .
+ 
+ btree.lo:	$(TOP)/src/btree.c $(HDR) $(TOP)/src/pager.h
+@@ -268,7 +269,8 @@ parse.c:	$(TOP)/src/parse.y lemon@BUILD_
  # configure the config.h file.
  #
  config.h:	


Home | Main Index | Thread Index | Old Index