From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 22B293858C54 for ; Tue, 23 Jan 2024 12:28:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 22B293858C54 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 22B293858C54 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706012902; cv=none; b=pFA7Vh7TCKtpybuv7yFH8ROzyRsnGtpiIVCNWXgJRiMbeh2ZkHG7HXkXORagNRVJEWpSx9286xP7JqlN07ACEs1rxWIibTHZhktGkmSI+wcZupT9fS0V63RIdulsZvb9SBX505ivqowglW9KHOx5Pf0aqyFl8X12Dy86S2l9HYk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706012902; c=relaxed/simple; bh=NBK+K8lAyixszerQGriDTbU9dB2bd48KajmwOYww3/o=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=gdNUBbS7r8dzlPxAcEBKwFGs+EhLACVjd6FGyn8nMJAl1BPeorOpAd5Ktv1jFbvYqsMd4zdaYoz7hsdiKil80cAUzI5MdhBw89AUSviuES+mGbmqynH8Gb5rxa3CxD3gOtubOvXQ2Tp50ZuCf3xWcGRwqnSy/LA5U6lxec4+B4c= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706012900; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=PHQwzII7wwWINp+fGsE8cn6+Rn0beUD9le7DFSdNJm8=; b=Sgn0oLJ+T+J2puSrMF3y1rp/1RSbwNgNriwM3aFjhW9yvXfUV2B33gGcOU51MVGP0C5IRg MMPoHBTAZt4HwV3fOjawYLb7KY4h5CKVZ5Z/QYMQcuH2y2mxxOgvaIK8Rydxg42s6SE9vY 6HJ8bGjCuKd9wkUszHsJOJAgkLiq3zk= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-332-KJJpgKD7PV6hkL7LjrueCg-1; Tue, 23 Jan 2024 07:28:19 -0500 X-MC-Unique: KJJpgKD7PV6hkL7LjrueCg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2722210AF98A; Tue, 23 Jan 2024 12:28:19 +0000 (UTC) Received: from prancer.redhat.com (unknown [10.42.28.192]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A6BFBC15E61; Tue, 23 Jan 2024 12:28:18 +0000 (UTC) From: Nick Clifton To: binutils@sourceware.org Cc: serge.guelton@telecom-bretagne.eu Subject: RFC: Document unexpected behaviour of --fatal-warnings Date: Tue, 23 Jan 2024 12:28:17 +0000 Message-ID: <87fryomdy6.fsf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Guys, It was recently pointed out to me that the bfd linker's --fatal-warnings option can behave in an unexpected manner. For example: $ ld.bfd -z bad-option --fatal-warnings -e 0/dev/null ld.bfd: warning: -z bad-option ignored $ echo $? 0 ie the warning about the ignored option is not being treated as an error. This happens because the --fatal-warnings option only takes affect after it has been processed, and we process the options in a linear order. So the following works: $ ld.bfd --fatal-warnings -z bad-option -e 0 /dev/null ld.bfd: warning: -z bad-option ignored $ echo $? 1 This behaviour differs from gold and lld, both of which honour --fatal-warnings no matter where it occurs on the command line. So we could fix the linker, create a two pass argument scan and the problem would be solved. But a) I am lazy and b) we already have a precedent for options on the command line only affecting options that come after it. (I am thinking of the -L option here, although there are probably several others). So instead I am considering documenting the current behaviour as expected. (See the patch below). What do people think ? Cheers Nick diff --git a/ld/ld.texi b/ld/ld.texi index 4fda259a552..16ab08e03f2 100644 --- a/ld/ld.texi +++ b/ld/ld.texi @@ -1993,7 +1993,20 @@ in filename invoked by -R or --just-symbols @item --fatal-warnings @itemx --no-fatal-warnings Treat all warnings as errors. The default behaviour can be restored -with the option @option{--no-fatal-warnings}. +with the option @option{--no-fatal-warnings}. Note: this option does +not affects warnings generated by other command line options that are +placed before it on the command line. So for example: + +@smallexample +$ ld -z bad-option --fatal-warnings -e 0/dev/null +ld: warning: -z bad-option ignored +$ echo $? +0 +$ ld --fatal-warnings -z bad-option -e 0 /dev/null +ld: warning: -z bad-option ignored +$ echo $? +1 +@end smallexample @kindex -w @kindex --no-warnings