X-Loop: help-debbugs@HIDDEN Subject: bug#68832: Testing: POSIX yacc and C++ linkage Resent-From: Marcel Telka <marcel@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-automake@HIDDEN Resent-Date: Tue, 30 Jan 2024 23:59:02 +0000 Resent-Message-ID: <handler.68832.B.17066591006487 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: report 68832 X-GNU-PR-Package: automake X-GNU-PR-Keywords: To: 68832 <at> debbugs.gnu.org X-Debbugs-Original-To: bug-automake@HIDDEN Received: via spool by submit <at> debbugs.gnu.org id=B.17066591006487 (code B ref -1); Tue, 30 Jan 2024 23:59:02 +0000 Received: (at submit) by debbugs.gnu.org; 30 Jan 2024 23:58:20 +0000 Received: from localhost ([127.0.0.1]:37135 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1rUxzd-0001gT-4S for submit <at> debbugs.gnu.org; Tue, 30 Jan 2024 18:58:20 -0500 Received: from lists.gnu.org ([2001:470:142::17]:50492) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <marcel@HIDDEN>) id 1rUuq3-0004uJ-TZ for submit <at> debbugs.gnu.org; Tue, 30 Jan 2024 15:36:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <marcel@HIDDEN>) id 1rUupo-00011w-Sn for bug-automake@HIDDEN; Tue, 30 Jan 2024 15:35:57 -0500 Received: from tortuga.telka.sk ([185.14.234.118]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <marcel@HIDDEN>) id 1rUupm-0000xX-Ge for bug-automake@HIDDEN; Tue, 30 Jan 2024 15:35:56 -0500 Received: (qmail 15413 invoked from network); 30 Jan 2024 20:35:42 -0000 Received: from telcontar.in.telka.sk (HELO telcontar) (marcel@HIDDEN) by tortuga.telka.sk with ESMTPSA (DHE-RSA-AES256-GCM-SHA384 encrypted); 30 Jan 2024 20:35:42 -0000 Date: Tue, 30 Jan 2024 21:35:41 +0100 From: Marcel Telka <marcel@HIDDEN> Message-ID: <ZbldnY-_UKmOctnv@telcontar> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="Yf0zFUp9B7SJlIQ6" Content-Disposition: inline Received-SPF: pass client-ip=185.14.234.118; envelope-from=marcel@HIDDEN; helo=tortuga.telka.sk X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-Mailman-Approved-At: Tue, 30 Jan 2024 18:58:16 -0500 X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -0.1 (/) --Yf0zFUp9B7SJlIQ6 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, I ran tests for automake 1.16.5 on OpenIndiana and following 4 tests failed: FAIL: t/yacc-cxx.sh FAIL: t/yacc-clean-cxx.sh FAIL: t/yacc-d-cxx.sh FAIL: t/yacc-mix-c-cxx.sh The cause for the failure is this: parse1.yy:30:7: error: conflicting declaration of 'void yyerror(const char*)' with 'C' linkage parse1.yy:7:6: note: previous declaration with 'C++' linkage 7 | void yyerror (const char *s) {} | ^~~~~~~ parse1.yy:34:6: error: conflicting declaration of 'int yylex()' with 'C' linkage parse1.yy:6:5: note: previous declaration with 'C++' linkage 6 | int yylex (void) { return std::getchar (); } | ^~~~~ For testing there is the default system yacc used. It is the illumos yacc as inherited from Solaris with some changes[1]. The generated code that causes the failure is this: 24 #if defined(__cplusplus) || defined(__STDC__) 25 26 #if defined(__cplusplus) 27 extern "C" { 28 #endif 29 #ifndef yyerror 30 #if defined(__cplusplus) 31 void yyerror(YYCONST char *); 32 #endif 33 #endif 34 #ifndef yylex 35 int yylex(void); 36 #endif 37 int yyparse(void); 38 #if defined(__cplusplus) 39 } 40 #endif 41 42 #endif The issue is apparent. The yacc generated code create both yyerror() and yylex() with the C linkage, but testing expects C++ linkage. This is exactly what the compiler error says. All of this is obvious. So where is the bug and what should be fixed? There are few possible views: 1. yacc is buggy and should not force C linkage for C++ source. This is grey area because POSIX says nothing about linkage or C++[2]. 2. The tests' expectations about yacc behavior re C++ are too strong. This seems to be true for illumos yacc. Other yacc implementations, for example GNU bison, does better job and do not force C linkage for affected functions. My proposal to solve the issue is to change affected tests to require bison instead of yacc. Please see attachment. Thank you. [1] for example this: https://www.illumos.org/issues/16136 [2] https://pubs.opengroup.org/onlinepubs/9699919799/utilities/yacc.html -- +-------------------------------------------+ | Marcel Telka e-mail: marcel@HIDDEN | | homepage: http://telka.sk/ | +-------------------------------------------+ --Yf0zFUp9B7SJlIQ6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="automake-1.16.5-test-yacc-cxx-bison.patch" --- automake-1.16.5/t/yacc-cxx.sh.orig +++ automake-1.16.5/t/yacc-cxx.sh @@ -18,7 +18,7 @@ # headers are not involved). # Keep in sync with sister test 'yacc-basic.sh'. -required='c++ yacc' +required='c++ bison' . test-init.sh cat >> configure.ac << 'END' --- automake-1.16.5/t/yacc-clean-cxx.sh.orig +++ automake-1.16.5/t/yacc-clean-cxx.sh @@ -20,7 +20,7 @@ # "make maintainer-clean". # See also sister test 'yacc-clean.sh'. -required='c++ yacc' +required='c++ bison' . test-init.sh cat >> configure.ac << 'END' --- automake-1.16.5/t/yacc-d-cxx.sh.orig +++ automake-1.16.5/t/yacc-d-cxx.sh @@ -18,7 +18,7 @@ # (i.e., '-d' in *YFLAGS). # Keep in sync with sister test 'yacc-d-basic.sh'. -required='c++ yacc' +required='c++ bison' . test-init.sh write_parse () --- automake-1.16.5/t/yacc-mix-c-cxx.sh.orig +++ automake-1.16.5/t/yacc-mix-c-cxx.sh @@ -17,7 +17,7 @@ # Check that many different Yacc parsers (both C and C++) can co-exists # in the same directory. -required='cc c++ yacc' +required='cc c++ bison' . test-init.sh cat >> configure.ac << 'END' --Yf0zFUp9B7SJlIQ6--
Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) Content-Type: text/plain; charset=utf-8 X-Loop: help-debbugs@HIDDEN From: help-debbugs@HIDDEN (GNU bug Tracking System) To: Marcel Telka <marcel@HIDDEN> Subject: bug#68832: Acknowledgement (Testing: POSIX yacc and C++ linkage) Message-ID: <handler.68832.B.17066591006487.ack <at> debbugs.gnu.org> References: <ZbldnY-_UKmOctnv@telcontar> X-Gnu-PR-Message: ack 68832 X-Gnu-PR-Package: automake Reply-To: 68832 <at> debbugs.gnu.org Date: Tue, 30 Jan 2024 23:59:02 +0000 Thank you for filing a new bug report with debbugs.gnu.org. This is an automatically generated reply to let you know your message has been received. Your message is being forwarded to the package maintainers and other interested parties for their attention; they will reply in due course. Your message has been sent to the package maintainer(s): bug-automake@HIDDEN If you wish to submit further information on this problem, please send it to 68832 <at> debbugs.gnu.org. Please do not send mail to help-debbugs@HIDDEN unless you wish to report a problem with the Bug-tracking system. --=20 68832: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D68832 GNU Bug Tracking System Contact help-debbugs@HIDDEN with problems
X-Loop: help-debbugs@HIDDEN Subject: bug#68832: Testing: POSIX yacc and C++ linkage References: <ZbldnY-_UKmOctnv@telcontar> Resent-From: Karl Berry <karl@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-automake@HIDDEN Resent-Date: Wed, 31 Jan 2024 22:48:03 +0000 Resent-Message-ID: <handler.68832.B68832.170674124226414 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 68832 X-GNU-PR-Package: automake X-GNU-PR-Keywords: To: marcel@HIDDEN Cc: 68832 <at> debbugs.gnu.org Received: via spool by 68832-submit <at> debbugs.gnu.org id=B68832.170674124226414 (code B ref 68832); Wed, 31 Jan 2024 22:48:03 +0000 Received: (at 68832) by debbugs.gnu.org; 31 Jan 2024 22:47:22 +0000 Received: from localhost ([127.0.0.1]:39221 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1rVJMY-0006rs-9z for submit <at> debbugs.gnu.org; Wed, 31 Jan 2024 17:47:22 -0500 Received: from frenzy.freefriends.org ([198.99.81.75]:54590 helo=freefriends.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <karl@HIDDEN>) id 1rVJMV-0006qu-Kg for 68832 <at> debbugs.gnu.org; Wed, 31 Jan 2024 17:47:20 -0500 X-Envelope-From: karl@HIDDEN Received: from freefriends.org (localhost [127.0.0.1]) by freefriends.org (8.14.7/8.14.7) with ESMTP id 40VMl9LT001289 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jan 2024 15:47:09 -0700 Received: (from apache@localhost) by freefriends.org (8.14.7/8.14.7/Submit) id 40VMl92F001288; Wed, 31 Jan 2024 15:47:09 -0700 Date: Wed, 31 Jan 2024 15:47:09 -0700 Message-Id: <202401312247.40VMl92F001288@HIDDEN> From: Karl Berry <karl@HIDDEN> In-Reply-To: <ZbldnY-_UKmOctnv@telcontar> X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) parse1.yy:30:7: error: conflicting declaration of 'void yyerror(const char*)' with 'C' linkage parse1.yy:7:6: note: previous declaration with 'C++' linkage Thanks much for the careful and complete report. I think this is another manifestation of what Bogdan fixed in other cases in https://debbugs.gnu.org/cgi/bugreport.cgi?bug=62886. His idea there was to essentially add an extern "C" only on Solaris, via sufficient #ifdef's. In these new cases, I guess braces would be required, so the test code would end up looking like: #if (defined __cplusplus) && ((!defined __sun) || (defined __EXTERN_C__)) extern "C" { #endif int yylex (void) { return std::getchar (); } void yyerror (const char *s) {} #if (defined __cplusplus) && ((!defined __sun) || (defined __EXTERN_C__)) } #endif Although I could try to do this, I can't easily test the result, and I'd probably mess up the editing. I'm also far from sure that this will actually solve the problem without introducing new ones. So maybe you could edit one of the test *.sh files and rerun the test and see what happens? In case you don't know, you can run a single test with, e.g., make check TESTS='t/yacc-cxx.sh' keep_testdirs=yes (the keep_testdirs keeps the <testdir>.dir/ around so it can be inspected afterward.) My proposal to solve the issue is to change affected tests to require bison instead of yacc. A lot of work has gone into making the tests work with Solaris tools (despite the current failures), so I'm reluctant to throw that possibility away. Also, there have been similar bug reports with older versions of bison. There is no panacea :( ... --thanks, karl.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.