From patchwork Tue Jun 28 21:05:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Trofimovich X-Patchwork-Id: 55512 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 5B539385AE51 for ; Tue, 28 Jun 2022 21:06:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5B539385AE51 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1656450383; bh=J3xpUVh+u5YpXhEQsfy3xaVNPy4xfY4osvWwN9QmE0k=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=d/YhWYmM0455Y7FLDId9gC+UYSOGBSnmUTn2t0rSf3amIPeFfAzvJGtsoDJxu5JWZ 6h0crQKHyuRQ/cX9Cn0bKMWfZSxd+tPHu5o2xVIr4LOJvjg8G9w9HrO5BGEXLSwIbo 6yLcp7rh9VhR8/33WCyv5lRudXSvxsCadZtFpUuE= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by sourceware.org (Postfix) with ESMTPS id 9225F385828E; Tue, 28 Jun 2022 21:05:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9225F385828E Received: by mail-wr1-x42b.google.com with SMTP id v9so3840215wrp.7; Tue, 28 Jun 2022 14:05:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=J3xpUVh+u5YpXhEQsfy3xaVNPy4xfY4osvWwN9QmE0k=; b=FYhmQIyioRPa7lca54CRCy5VWXxOUdQg5bwhv1gki3o6u/FPoPl0XLmOpvgyW7KSGn kHnN5kRN08ig1lir9ogiJD+d75JlVGTuqPLdzAPPjoeh3z7ZSTOpJDqpV0txxR63N5XO LX4h6CLoBv1y0GKmY+1L1882LezE7WsLZ9tRERQvWft5xwJYAnpJa9WnnNHDnC2P6YH7 VeFMhLBIFfXzVjGd+YakKnB69hNnq33EsJQRyh1u4vVxiJrULw3FIb2O4HH+NwmWg7FF sWeEDh5GGQCyuMP+5+oetGuQnTsuzCmCRuMVduGA4DYCThTyhhS3N0QTgVQu+su9fJHA qLCg== X-Gm-Message-State: AJIora95OFrfhPA6imHFHe6fsKYg1mLdGtrrfkqqce2pbjM24rlLt429 xpGKjkKqOIRqC5R844g3caw1pmF2kFY= X-Google-Smtp-Source: AGRyM1uvOio0rpcODvha9EFrtm3URktbR6DmwYhkwIapcb3/gIXvMZuMsETHdD7oatcacAIbizmhbw== X-Received: by 2002:a05:6000:1d84:b0:20e:5fae:6e71 with SMTP id bk4-20020a0560001d8400b0020e5fae6e71mr19705158wrb.224.1656450351202; Tue, 28 Jun 2022 14:05:51 -0700 (PDT) Received: from nz.home (host81-147-8-3.range81-147.btcentralplus.com. [81.147.8.3]) by smtp.gmail.com with ESMTPSA id k12-20020a7bc30c000000b0039c673952bfsm823599wmj.6.2022.06.28.14.05.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jun 2022 14:05:50 -0700 (PDT) Received: by nz.home (Postfix, from userid 1000) id CB9FC5783ED92; Tue, 28 Jun 2022 22:05:49 +0100 (BST) To: gcc-patches@gcc.gnu.org Subject: [PATCH v2] jit: avoid calloc() poisoning on musl [PR106102] Date: Tue, 28 Jun 2022 22:05:29 +0100 Message-Id: <20220628210529.2013070-1-slyich@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Sergei Trofimovich via Gcc-patches From: Sergei Trofimovich Reply-To: Sergei Trofimovich Cc: Sergei Trofimovich , rguenth@gcc.gnu.org Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" From: Sergei Trofimovich On musl uses calloc() (via ). jit/ includes it directly and exposes use of poisoned calloc(): /build/build/./prev-gcc/xg++ ... ../../gcc-13-20220626/gcc/jit/jit-playback.cc make[3]: *** [Makefile:1143: jit/libgccjit.o] Error 1 make[3]: *** Waiting for unfinished jobs.... In file included from /<>/musl-1.2.3-dev/include/pthread.h:30, from ../../gcc-13-20220626/gcc/jit/jit-playback.cc:44: /<>/musl-1.2.3-dev/include/sched.h:84:7: error: attempt to use poisoned "calloc" 84 | void *calloc(size_t, size_t); | ^ /<>/musl-1.2.3-dev/include/sched.h:124:36: error: attempt to use poisoned "calloc" 124 | #define CPU_ALLOC(n) ((cpu_set_t *)calloc(1,CPU_ALLOC_SIZE(n))) | ^ The change moves inclusion to "system.h" under new INCLUDE_PTHREAD_H guard and uses this mechanism in libgccjit. gcc/ PR c++/106102 * system.h: Introduce INCLUDE_PTHREAD_H macros to include . gcc/jit/ PR c++/106102 * jit-playback.cc: Include via "system.h" to avoid calloc() poisoning. * jit-recording.cc: Ditto. * libgccjit.cc: Ditto. --- gcc/jit/jit-playback.cc | 3 +-- gcc/jit/jit-recording.cc | 2 +- gcc/jit/libgccjit.cc | 2 +- gcc/system.h | 4 ++++ 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/gcc/jit/jit-playback.cc b/gcc/jit/jit-playback.cc index 6be6bdf8dea..79714132b91 100644 --- a/gcc/jit/jit-playback.cc +++ b/gcc/jit/jit-playback.cc @@ -19,6 +19,7 @@ along with GCC; see the file COPYING3. If not see . */ #include "config.h" +#define INCLUDE_PTHREAD_H #include "system.h" #include "coretypes.h" #include "target.h" @@ -41,8 +42,6 @@ along with GCC; see the file COPYING3. If not see #include "diagnostic.h" #include "stmt.h" -#include - #include "jit-playback.h" #include "jit-result.h" #include "jit-builtins.h" diff --git a/gcc/jit/jit-recording.cc b/gcc/jit/jit-recording.cc index 697dee66e73..f78daed2d71 100644 --- a/gcc/jit/jit-recording.cc +++ b/gcc/jit/jit-recording.cc @@ -19,13 +19,13 @@ along with GCC; see the file COPYING3. If not see . */ #include "config.h" +#define INCLUDE_PTHREAD_H #include "system.h" #include "coretypes.h" #include "tm.h" #include "pretty-print.h" #include "toplev.h" -#include #include "jit-builtins.h" #include "jit-recording.h" diff --git a/gcc/jit/libgccjit.cc b/gcc/jit/libgccjit.cc index 0e76097b4ba..ca862662777 100644 --- a/gcc/jit/libgccjit.cc +++ b/gcc/jit/libgccjit.cc @@ -19,12 +19,12 @@ along with GCC; see the file COPYING3. If not see . */ #include "config.h" +#define INCLUDE_PTHREAD_H #include "system.h" #include "coretypes.h" #include "timevar.h" #include "typed-splay-tree.h" #include "cppbuiltin.h" -#include #include "libgccjit.h" #include "jit-recording.h" diff --git a/gcc/system.h b/gcc/system.h index 67158b70c78..f8d42ff6815 100644 --- a/gcc/system.h +++ b/gcc/system.h @@ -753,6 +753,10 @@ extern int vsnprintf (char *, size_t, const char *, va_list); #endif #endif +#ifdef INCLUDE_PTHREAD_H +#include +#endif + #ifdef INCLUDE_ISL #ifdef HAVE_isl #include