From patchwork Mon Jul 1 08:54:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rainer Orth X-Patchwork-Id: 93125 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DC52C389909A for ; Mon, 1 Jul 2024 08:55:55 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp.CeBiTec.Uni-Bielefeld.DE (smtp.CeBiTec.Uni-Bielefeld.DE [129.70.160.84]) by sourceware.org (Postfix) with ESMTPS id A84EC389908F for ; Mon, 1 Jul 2024 08:54:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A84EC389908F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=CeBiTec.Uni-Bielefeld.DE Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=cebitec.uni-bielefeld.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A84EC389908F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=129.70.160.84 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719824108; cv=none; b=uOjccn088eOngbeZzruVhqUmw1Rc9E0axTCUkTceRe5QzBFJJBHvXwgv/sl/PYDV5kLr8E8p/T8n5UHqCZUgfpstDliVfSV4S7uDGWoU6AEpqIz2a6G011BRQqOVts4xBmyLcFvFlAkAUNuw/68UFV6j1ebqAFZBr4H7pJNqTZk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719824108; c=relaxed/simple; bh=BseltRvF5tDQkcqiJ6qSOPIjIM3Kj30qxJtWl039myE=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Oj4U37LNwMGfByIkT6YENLFRtlg51Q+yUCW/5ly9icp9IW1T3qcku4QFVEgJCurvrV05Dor/Kl/LQjQSypmuG7MwnIfs8gTcd7aY1qrozZXjAxRkT8Nu56WENYdfrpDUcBR2wBmzru/IkF2nhtE7e8ZWlXYLGJ7g2xTSXvjelCE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from localhost (localhost [127.0.0.1]) by smtp.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTP id 94E04C5AD7; Mon, 1 Jul 2024 10:54:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= cebitec.uni-bielefeld.de; h=content-type:content-type :mime-version:user-agent:message-id:date:date:subject:subject :from:from:received:received; s=20200306; t=1719824095; bh=Bselt RvF5tDQkcqiJ6qSOPIjIM3Kj30qxJtWl039myE=; b=LXEE3GsdLcunerCDkdspt fDxaBImlNH5GRcp23lVF02RA9IhQnnmUbodYtlZH2SdfJ7O5PbyaKCXlE1hdUili qazR9BDYAbXh9lTN+Xe//Djie4k4ifgmj2m1JakGUitDcINkaqqUJjmLg3VXVvBm qB+5yZx0AcSCLo1NV4zqN5d5kLzUwAlaZHPHnxMs2qQBP9AbEsx0vRX2EpNg+H01 qPECW1Ee6N0q88XeU2S+GaeGxbDshHIbbnXBiXpZILhx5tShBnGCBpmETB4VpCPT uFKn4A/5qbgDeLjNt4XYlVFQg3qWiDinsJb5FcKoohKw9KV6EdErK6/jZKFxhBW3 A== X-Virus-Scanned: amavisd-new at cebitec.uni-bielefeld.de Received: from smtp.CeBiTec.Uni-Bielefeld.DE ([127.0.0.1]) by localhost (smtp.cebitec.uni-bielefeld.de [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id gYBia3vTXuYo; Mon, 1 Jul 2024 10:54:55 +0200 (CEST) Received: from manam.CeBiTec.Uni-Bielefeld.DE (p4fddb173.dip0.t-ipconnect.de [79.221.177.115]) (Authenticated sender: ro) by smtp.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTPSA id 006EEC57FF; Mon, 1 Jul 2024 10:54:54 +0200 (CEST) From: Rainer Orth To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [PATCH] libffi: Fix 32-bit SPARC structure passing [PR115681] Date: Mon, 01 Jul 2024 10:54:54 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (usg-unix-v) MIME-Version: 1.0 X-Spam-Status: No, score=-3788.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, SPF_HELO_NONE, SPF_PASS, 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: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org The libffi.closures/single_entry_structs2.c test FAILs on 32-bit SPARC: FAIL: libffi.closures/single_entry_structs2.c -W -Wall -Wno-psabi -O0 execution test The issue has been reported, analyzed and fixed upstream: Several tests FAIL on 32-bit Solaris/SPARC https://github.com/libffi/libffi/issues/841 Therefore this patch imports the fix into the GCC tree. Tested on sparc-sun-solaris2.11. Ok for trunk? Rainer # HG changeset patch # Parent 31401e58fa469c62c2278e38d35817fab3407e97 libffi: Fix 32-bit SPARC structure passing diff --git a/libffi/src/sparc/ffi.c b/libffi/src/sparc/ffi.c --- a/libffi/src/sparc/ffi.c +++ b/libffi/src/sparc/ffi.c @@ -286,6 +286,8 @@ ffi_call_int (ffi_cif *cif, void (*fn)(v void **avalue, void *closure) { size_t bytes = cif->bytes; + size_t i, nargs = cif->nargs; + ffi_type **arg_types = cif->arg_types; FFI_ASSERT (cif->abi == FFI_V8); @@ -295,6 +297,20 @@ ffi_call_int (ffi_cif *cif, void (*fn)(v && (cif->flags & SPARC_FLAG_RET_MASK) == SPARC_RET_STRUCT) bytes += FFI_ALIGN (cif->rtype->size, 8); + /* If we have any structure arguments, make a copy so we are passing + by value. */ + for (i = 0; i < nargs; i++) + { + ffi_type *at = arg_types[i]; + int size = at->size; + if (at->type == FFI_TYPE_STRUCT) + { + char *argcopy = alloca (size); + memcpy (argcopy, avalue[i], size); + avalue[i] = argcopy; + } + } + ffi_call_v8(cif, fn, rvalue, avalue, -bytes, closure); }