From patchwork Wed Jun 3 11:14:56 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: gerris.rs@gmail.com X-Patchwork-Id: 136376 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CF1AA4BA2E15 for ; Wed, 3 Jun 2026 11:15:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CF1AA4BA2E15 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=i3V9tUxg X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-qk1-x72a.google.com (mail-qk1-x72a.google.com [IPv6:2607:f8b0:4864:20::72a]) by sourceware.org (Postfix) with ESMTPS id C2A1F4BA2E0C for ; Wed, 3 Jun 2026 11:14:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C2A1F4BA2E0C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C2A1F4BA2E0C Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::72a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1780485298; cv=none; b=saE4Nsv4wQDxrVUFScOeg1QxJpIbFIs7prYUmy2ze+1zjOJcZpwsMufSPuSHDScUynC1cG5iAwJtQRabAYh92ZNxCl5jSqoIj2C582Cv/0yL2M0x+uojHjqVULG0GP9iOU8tJKlOX/d6YK00UySynxso9lLE3LeYUxHKHCU6e3g= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1780485298; c=relaxed/simple; bh=fACZNxIexWsqw4ork5DrhDobctrlbb7K7CUJU8QpD6A=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=DEO8RW3shReYfoREHXmTcRHyqgqwMPdAE7s8aqDhZ1ZGEhCQq00IZI18rpOOzgS5JIl71qSMPR1ElHHqFRt2cp+FtT8tWcYRrL9GzFdcUdpa0oHwCMTCenXiieqsIUNmeJUnxj5ddmqO1U7xj7UApVHkCBnwUL8W9B5sS6CIzFM= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=i3V9tUxg DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C2A1F4BA2E0C Received: by mail-qk1-x72a.google.com with SMTP id af79cd13be357-91588056619so83350485a.2 for ; Wed, 03 Jun 2026 04:14:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780485298; x=1781090098; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=KHBdhXSlv6e8pjqjHt0wWenpVJLIKgq5qo+CHZHgcX4=; b=i3V9tUxgROlbuuWTA9+MMdpv66PFgupxkBj3mSitvF59vRe5aHu4+KprMFpcJtlCEQ KDXHOVNJFP+gmMImW6f/XiOBqvpokK7ra9gg0KAt9Ixm6b4yziEcuN/t35rCk0XzuCGr GiJuYAo4hJLHUs9he+45zpne51tYunhJgGrRydfeQbuoss6Zmm4Dy77jTa2O7nR7rLPp ktlB2mFXKAJJDIFq4+qO5Cp68zTjNHNT1aI3arGDOvSo5WCh97baPmqCoKgZuWZDMWVk DkwrZy7oQt56TCCL57baebCbsfQ/WnzttXM6UBEcj6qpvec6jQzMfJ6FRU/F3Yj93vEg MKMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780485298; x=1781090098; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=KHBdhXSlv6e8pjqjHt0wWenpVJLIKgq5qo+CHZHgcX4=; b=XivX0x+Lo87D8EYNVYxQDpfQc/pYBh+OMCBo8L02UaQ2WcXb9bi+n6ypV1xVuQKEsk bqKOlcKb3Vpcr06Fed2XbyX5YyUpQId2QoABpAurW/QF/9Yf7ex/O5mlTMNkBvOmWvPr EuJ0MFHff5mux+GACeMFOlbCVYng30d5aF8uX3ebN2TGMfeTAHrSpqAhDWA9xgZL3DHL 5LurEsLh6vO8hDbKV5e74Wt50WfpVpCnqF6z+2pdpW6nlIkDcWY7/V5RlDEsvLBQWO0D hC/Yndh4nAFhOtpNUy7CdTZVJ8YnfBQPBvwQYfPxvPUNspesdhyAi0G0I7kGF1RXWJ91 zEAg== X-Gm-Message-State: AOJu0YwLADSM8GkP5w4ZO7a6OKI0jl6Cl7FXNs9ckbGQsRq3LBw/E6Go GWX8y1Quhh3VC2zbmLcqRbhxz8jlim7yP25tjTtclsQQeaLwDCcnzW3i9Nmo+g== X-Gm-Gg: Acq92OF1XWnvSxDldJP/r4HptJ0oHqZ/LFz0JvIJ4SMcMqSbFg5ZjI0fHrp2sWGMaZ3 wmWKENNkCKOU6t90AfWYQTZPSmZhutW8FQ3k9+4q2AzKC9sHmAAuGdnOrpGGWVlu2NEaMDt61WB /mBq0lOV2s8B5EK+jFy4ApivVi32eeAsgjQtHp9QTSeSTQo9nA6td5M9YVY87pM/dSn81umoiVe 117s3wthUwZA1pGPh+kkVZzk4xMQ0NZZaDR3VDkEg6gwijc4YPYchuCBTck13aSjHWPA7L6iqGk KaFtuqYAN2eZ/fXVY3ZIW+HDomYFnhlNGTMxow3gc+eZfRCk9QLhxGU8JcxaSBHnDEpH7dIBQ5m 0Esnq294Y0U6Bqxv8XSjCq5JoESet+zjM6oZP1xLlp6A3RZ6gGBUkiySwrC3Xfev1HrAFMI7sfi /D05oVG2vK/xLI4fW9MbcRekN1VWFABqKECOt21Vyyk6eYg0SrtNJrgtlhOz6/ziblGmHEtukO4 /mRBS2ag7MT2REvwP6Y7a4z6AWaJes= X-Received: by 2002:a05:620a:404c:b0:915:89d4:df22 with SMTP id af79cd13be357-9158a858a36mr455179385a.50.1780485298104; Wed, 03 Jun 2026 04:14:58 -0700 (PDT) Received: from runnervm3jyl0.ozoxzkprtlmulfxbfzsbc1pbsh.cx.internal.cloudapp.net ([9.234.151.23]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8ceccda0904sm17679526d6.7.2026.06.03.04.14.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 04:14:57 -0700 (PDT) From: gerris.rs@gmail.com To: gcc-patches@gcc.gnu.org, gcc-rust@gcc.gnu.org Cc: pierre-emmanuel.patry@embecosm.com, arthur.cohen@embecosm.com, dkm+gccrs@kataplop.net, Enes Cevik Subject: [gccrs COMMIT] lang: Add lang item exchange_malloc Date: Wed, 3 Jun 2026 11:14:56 +0000 Message-ID: <20260603111456.3097-1-gerris.rs@gmail.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLOCKED shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on 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 From: Enes Cevik This patch introduces the `exchange_malloc` lang item to compiler. This lang item is a strict prerequisite for the `owned_box` lang item and box expressions. gcc/rust/ChangeLog: * util/rust-lang-item.cc (Rust::LangItem::lang_items): Register exchange_malloc to BiMap. * util/rust-lang-item.h (LangItem::Kind): Add EXCHANGE_MALLOC. gcc/testsuite/ChangeLog: * rust/compile/exchange_malloc.rs: New test. Signed-off-by: Enes Cevik --- This change was merged into the gccrs repository and is posted here for upstream visibility and potential drive-by review, as requested by GCC release managers. Each commit email contains a link to its details on github from where you can find the Pull-Request and associated discussions. Commit on github: https://github.com/Rust-GCC/gccrs/commit/16a37ba94b143f0f1e9987d0380fca1ae309406f The commit has NOT been mentioned in any issue. The commit has been mentioned in the following pull-request(s): - https://github.com/Rust-GCC/gccrs/pull/4557 gcc/rust/util/rust-lang-item.cc | 2 ++ gcc/rust/util/rust-lang-item.h | 2 ++ gcc/testsuite/rust/compile/exchange_malloc.rs | 7 +++++++ 3 files changed, 11 insertions(+) create mode 100644 gcc/testsuite/rust/compile/exchange_malloc.rs base-commit: cd9103fd3fe8d3726d5b4c30d30c7da265f53da3 diff --git a/gcc/rust/util/rust-lang-item.cc b/gcc/rust/util/rust-lang-item.cc index 37bd85b6b..21e2c81e9 100644 --- a/gcc/rust/util/rust-lang-item.cc +++ b/gcc/rust/util/rust-lang-item.cc @@ -120,6 +120,8 @@ const BiMap Rust::LangItem::lang_items = {{ {"discriminant_kind", Kind::DISCRIMINANT_KIND}, {"discriminant_type", Kind::DISCRIMINANT_TYPE}, {"manually_drop", Kind::MANUALLY_DROP}, + + {"exchange_malloc", Kind::EXCHANGE_MALLOC}, }}; tl::optional diff --git a/gcc/rust/util/rust-lang-item.h b/gcc/rust/util/rust-lang-item.h index 90d53a499..5a765282b 100644 --- a/gcc/rust/util/rust-lang-item.h +++ b/gcc/rust/util/rust-lang-item.h @@ -156,6 +156,8 @@ public: DISCRIMINANT_KIND, MANUALLY_DROP, + + EXCHANGE_MALLOC }; static const BiMap lang_items; diff --git a/gcc/testsuite/rust/compile/exchange_malloc.rs b/gcc/testsuite/rust/compile/exchange_malloc.rs new file mode 100644 index 000000000..abfaabfb6 --- /dev/null +++ b/gcc/testsuite/rust/compile/exchange_malloc.rs @@ -0,0 +1,7 @@ +#![feature(no_core,lang_items)] +#![no_core] + +#[lang = "exchange_malloc"] +unsafe fn _allocate(_size: usize, _align: usize) -> *mut u8 { + 0 as *mut u8 +}