From unknown Fri Jun 20 07:27:21 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#53240 <53240@debbugs.gnu.org> To: bug#53240 <53240@debbugs.gnu.org> Subject: Status: Compiler stderr messages cause -fPIC detection to fail Reply-To: bug#53240 <53240@debbugs.gnu.org> Date: Fri, 20 Jun 2025 14:27:21 +0000 retitle 53240 Compiler stderr messages cause -fPIC detection to fail reassign 53240 libtool submitter 53240 Rodrigo Arias severity 53240 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Thu Jan 13 16:19:09 2022 Received: (at submit) by debbugs.gnu.org; 13 Jan 2022 21:19:09 +0000 Received: from localhost ([127.0.0.1]:34755 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n87Uy-0003BH-Or for submit@debbugs.gnu.org; Thu, 13 Jan 2022 16:19:09 -0500 Received: from lists.gnu.org ([209.51.188.17]:34080) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n87FX-0002ja-WE for submit@debbugs.gnu.org; Thu, 13 Jan 2022 16:03:13 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54094) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n87FX-0004Cy-Qo for bug-libtool@gnu.org; Thu, 13 Jan 2022 16:03:11 -0500 Received: from mao.bsc.es ([84.88.52.34]:56429 helo=mail.bsc.es) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n87FT-00021Y-Jc for bug-libtool@gnu.org; Thu, 13 Jan 2022 16:03:11 -0500 Received: from hop.localdomain (unknown [10.100.0.11]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.bsc.es (Postfix) with ESMTPSA id CAE7F41D88AF for ; Thu, 13 Jan 2022 22:02:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsc.es; s=20191012; t=1642107779; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=fxfmmSV8LeWKJW4AnY/Nf2AAEd9Hdn/FjfFgyWH7A/4=; b=CFci7oIN98YD5lwaIkDMWkm2jmkgPFio4oEH1CmXgZ+rMG0kLmngQXn2tEdEYHMwhj/MhW 7c/mTttSJ9TEkNxHTc6o7yjmzMP3d8O9LTi5VPoZ7uJYLTK6NVN5qcevXSdc2cw5ZGJ4Es TPL5TgNXhR0VSKrBz6kkAqG15ONyHQaigyIpPRRFUvmsGHt46PY4G8nBlpcw7InGOlLJZB +HlfdQVYefmyJspbBGhNqafcBCAuqODLUXQ7tfZhlh+M9A35pH1NGI4R5Mjtl8o16CR9wV AbD2Ds0hL2RhiqgyMiRmQdOavumpkKk9hy4zH5/ULNKUq3tFwoz9qLY1DqO9nA== Date: Thu, 13 Jan 2022 22:02:59 +0100 From: Rodrigo Arias To: bug-libtool@gnu.org Subject: Compiler stderr messages cause -fPIC detection to fail Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline X-Copyrighted-Material: Please visit http://www.bsc.es/disclaimer Received-SPF: pass client-ip=84.88.52.34; envelope-from=rodrigo.arias@bsc.es; helo=mail.bsc.es X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Thu, 13 Jan 2022 16:19:07 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) Hi, When using a compiler that produces dynamic messages via stderr when invoked, the configure code of libtool assumes the -fPIC is not working. This originally happened to me when using a gcc wrapper in nix with verbose messages enabled, which prints the arguments, but it can be reproduced more easily with gcc and `CFLAGS=-v` in the configure. Related: https://lists.gnu.org/archive/html/bug-autoconf/2012-07/msg00046.html $ ./configure CFLAGS=-v ... checking if gcc supports -fno-rtti -fno-exceptions... no checking for gcc option to produce PIC... -fPIC -DPIC checking if gcc PIC flag -fPIC -DPIC works... no <-- see here checking if gcc static flag -static works... no checking if gcc supports -c -o file.o... no checking if gcc supports -c -o file.o... (cached) no Here is the part of the config.log: ... configure:9683: checking for gcc option to produce PIC configure:9691: result: -fPIC -DPIC configure:9699: checking if gcc PIC flag -fPIC -DPIC works configure:9718: gcc -c -std=c11 -v -fPIC -DPIC -DPIC conftest.c >&5 Using built-in specs. COLLECT_GCC=/nix/store/h6d0c7lnxx65i925xmnxgwdfdvc7hc2p-gcc-10.3.0/bin/gcc Target: x86_64-unknown-linux-gnu Configured with: Thread model: posix Supported LTO compression algorithms: zlib gcc version 10.3.0 (GCC) [ more lines removed ] configure:9722: $? = 0 configure:9735: result: no <--- here it assumes it doesn't work configure:9764: checking if gcc static flag -static works configure:9793: result: no Here is the offending code in the configure: lt_cv_prog_compiler_pic_works=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$lt_prog_compiler_pic -DPIC" ## exclude from sc_useless_quotes_in_assignment # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_pic_works=yes fi fi $RM conftest* It looks like the diff command fails because the gcc output has multiple lines which have now changed to include the -fPIC option, causing it to return 1. The same problem would happen with other checks that use _LT_COMPILER_OPTION, but I only see the -fno-rtti check using it. However, this problem will likely happen to any other detection checks that rely on the diff over the output being the same. I don't know if there is a good solution to this problem, but at least I believe it can be tested if the output is a reliable source to look for errors by using two flags without side effects and testing that the log stays the same, say gcc -E vs gcc -E -E. If that causes the output to differ, then diffing the output alone is not a reliable way to test if -fPIC has caused an error. Example: % echo | gcc -E - 2>&1 | md5sum 23f8c0306cc1ad862a3a5a6cb2a6747b - % echo | gcc -E -E - 2>&1 | md5sum 23f8c0306cc1ad862a3a5a6cb2a6747b - Output seems reliable. % echo | gcc -v -E - 2>&1 | md5sum be68c813b36efa7b72a69a31c6ddfc06 - % echo | gcc -v -E -E - 2>&1 | md5sum a814600ad051ee786c38498d6298a1bb - Output changes with the args and is not reliable. Best, Rodrigo.