From patchwork Sat Oct 12 09:59:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1996384 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=EBiksD9V; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XQfBB2Nc2z1xsc for ; Sat, 12 Oct 2024 21:00:16 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 63A01385703F for ; Sat, 12 Oct 2024 10:00:13 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 9B5623858C41 for ; Sat, 12 Oct 2024 09:59:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9B5623858C41 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 9B5623858C41 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=1728727195; cv=none; b=dlV2OZzp40t+j5T7BYWhwFiPcFM0zCw6qHXvQw5sAv1V6N12U3/meKxj1XgHb/0Xj0scKxpXUHS+F/il5nkSrT53eVfIy8xnqmJEX/QBX3K2klqW0RkvRk+KYxmAuFzqBkt5glv2ylaEGHZUDOJnL8NieKmDX1LOn4kz1CCjtBc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728727195; c=relaxed/simple; bh=2uURjhFYquajbmitkIBh07VBgrHqHH/0N9ZbFmZRq94=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=uPQFmRNLv32hw+VOYdsV11NPTcTZsJ2wLy4LE7h4PBjVTZDdt83fLNRiLnLXR0AgAuMFBdLuSomdfyyBOsKmZuvuKqcD7wF2rCv85wuL4Cb+V/WMGSxF6uEC0K4LDRxVdGKegRLb0+7itTnHaXhS2urk+9xLoNR3hSJKE+TnMeE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728727193; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=IgXS2Yl6zsLJnf1jlt1DWhlnJcS/l53o+ZwdD+X85Cc=; b=EBiksD9VTcdXh3V9eMh34mQhovCgi0/5bx3zOcIfrK0+qceJfNI4zn19LmyMlgeXDpoUHk 5EMx5A0/bj9RF3glQw0KcN5L6/4hPVdWuNb6Yus5KM5lGq5YnheLs3z9UG+BMU8UrR3n9t UeYpqoYOYCXaRX4pBkd+MifKQ/BLW/U= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-342-QGgSnR3PO429sa_tRPEqFA-1; Sat, 12 Oct 2024 05:59:48 -0400 X-MC-Unique: QGgSnR3PO429sa_tRPEqFA-1 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8602219560A5; Sat, 12 Oct 2024 09:59:47 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.45.224.61]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BDE4D19560AA; Sat, 12 Oct 2024 09:59:46 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 49C9xhDv1247632 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 12 Oct 2024 11:59:43 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 49C9xhWq1247631; Sat, 12 Oct 2024 11:59:43 +0200 Date: Sat, 12 Oct 2024 11:59:43 +0200 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] bootstrap: Fix genmatch build where system gcc defaults to -fPIE -pie Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Hi! Seems our buildbot is unhappy about my latest commit to link genmatch with libcommon.a in order to support gcc_diag diagnostics in libcpp. We have in gcc/configure.ac: if test x$enable_host_shared = xyes; then PICFLAG=-fPIC elif test x$enable_host_pie = xyes; then PICFLAG=-fPIE elif test x$gcc_cv_c_no_fpie = xyes; then PICFLAG=-fno-PIE else PICFLAG= fi if test x$enable_host_pie = xyes; then LD_PICFLAG=-pie elif test x$gcc_cv_no_pie = xyes; then LD_PICFLAG=-no-pie else LD_PICFLAG= fi if test x$enable_host_bind_now = xyes; then LD_PICFLAG="$LD_PICFLAG -Wl,-z,now" fi Now, for object files linked into cc1, cc1plus, xgcc etc. we carefully arrange for them to be compiled with $(PICFLAG) and do the link with $(LD_PICFLAG). For the generator programs, we don't do anything like that, we simply compile their objects without $(PICFLAG) and link without $(LD_PICFLAG). It isn't that big deal, the generator programs runs once or a couple of times during the build and that is it, we don't ship them and don't care much if they are PIE or not. Except that after my changes to link in libcommon.a into build/genmatch, we now link -fno-PIE compiled objects into a binary which is linked with default flags. Our distro compiler just links a normal executable and everything works fine (-fPIE/-pie is added through spec file snippet and just added in rpm default flags), but seems the buildbot system gcc defaults to -fPIE -pie instead and so building build/genmatch fails. The following patch is a minimal fix for that, just add -no-pie when linking build/genmatch, but don't add -pie. If we wanted to start building even the build/gen* tools with $(PICFLAG) and $(LD_PICFLAG), that would be much larger change. Ok for trunk to unbreak trunk? 2024-10-12 Jakub Jelinek * Makefile.in (LINKER_FOR_BUILD): Append -no-pie if it is in $(LD_PICFLAG) when building build/genmatch. Jakub --- gcc/Makefile.in.jj 2024-10-12 10:50:41.054854533 +0200 +++ gcc/Makefile.in 2024-10-12 11:47:03.126827883 +0200 @@ -3145,6 +3145,11 @@ build/genmatch$(build_exeext): BUILD_LIB build/genmatch$(build_exeext): BUILD_LIBS += $(LIBINTL) $(LIBICONV) endif +# genmatch links in libcommon.a, which could have been compiled with +# $(PICFLAG) set to -fno-PIE. Make sure to link genmatch with -no-pie +# in that case. +build/genmatch$(build_exeext): LINKER_FOR_BUILD += $(findstring -no-pie,$(LD_PICFLAG)) + build/genmatch$(build_exeext) : $(BUILD_CPPLIB) \ build/vec.o build/hash-table.o build/sort.o libcommon.a \ $(LIBBACKTRACE)