From patchwork Tue Jan 17 23:18:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Khem Raj X-Patchwork-Id: 18266 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 11964C00A5A for ; Tue, 17 Jan 2023 23:19:00 +0000 (UTC) Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) by mx.groups.io with SMTP id smtpd.web11.2329.1673997536201441152 for ; Tue, 17 Jan 2023 15:18:56 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=TRpzk9mw; spf=pass (domain: gmail.com, ip: 209.85.215.178, mailfrom: raj.khem@gmail.com) Received: by mail-pg1-f178.google.com with SMTP id v3so23213890pgh.4 for ; Tue, 17 Jan 2023 15:18:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=52afRuTBFIeZi9VjyqaZIFifJU0ajOBYsOLlBGSzMAw=; b=TRpzk9mw6Wh0lb/zaXNPFpeLNoefgkw1Uqn+pVNVpmjlsdR43dHfcLtFKk+ux2RwM4 Nbgm2oKRk+1zk/qbjA8exrgEnnmrVgzqrKYCEG7wUm3fXgME3+Cmed0fQzbLTPKqPTC1 n099ZfH1Sc5drdyVUkxCF7NcgSEdcQ0Gig/NwheAszY2WvMGzYe+CDoHjPSm1KdEGLk0 WCSbqtb7PM41LiDBP4359/m3eZFHDMMuVvUsbaagVeo0dU7iKZosTsHqtQzFdcSgv39l ss9J3Z46ROsjeLQe0bgZlcrHlAIJQ4G6EQC8rOY3gSkUE5KLReyZZTOnV/DIfLXt0ObH 7tQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=52afRuTBFIeZi9VjyqaZIFifJU0ajOBYsOLlBGSzMAw=; b=2I8uXco7xULcmIM9Hn5o28XW1tZJgXZhzHyiaSDH20Xj8838lS/SOMep7L0u2zwDet MVggJdh1LVtL+m2uZxdMlYBF0OaWcqgnXdIZnjeO5YglRLNmEVilUpF3MC56yPQYcDh1 Iab3lVGpkIjuvT89IpPBFuhRjkblk7PuxPvHWJModFjp8zo9ITE7F8hua6aBFvGWAZlm sJAvv6sY8p5iqlJ/LRzbVgwvYg4lZckbavrNly2XcdW1HPtbdfx7qLWecuQ9EXMFJwQE RIZkPrgIbeZQjnq9FJnJZ4lfw8I9zwDzpyvseVZ5/8q05Dtu4eT3LsoGDqIQi3v0OyHd xqJg== X-Gm-Message-State: AFqh2kp4ntFGWgeCThCJmoole37wc3hPJ2sW1fcxodRmvwC+XknLHAeh mDUOrvRYk1xtXOF05rNRngAAHof2f6osWw== X-Google-Smtp-Source: AMrXdXsE3IYnsz27ebYRCu73NBiQeIfglyQORgaGFG+CA8qovYSet25yqTnGj25R1R6SgAT9MFMoPw== X-Received: by 2002:aa7:92d4:0:b0:58d:bb59:7112 with SMTP id k20-20020aa792d4000000b0058dbb597112mr3801899pfa.22.1673997535195; Tue, 17 Jan 2023 15:18:55 -0800 (PST) Received: from apollo.hsd1.ca.comcast.net ([2601:646:9181:1cf0::b940]) by smtp.gmail.com with ESMTPSA id y15-20020aa7942f000000b0058d92d6e4ddsm5445717pfo.5.2023.01.17.15.18.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 15:18:54 -0800 (PST) From: Khem Raj To: openembedded-core@lists.openembedded.org Cc: Khem Raj Subject: [PATCH 1/4] mdadm: Define alignof using _Alignof when using C11 or newer Date: Tue, 17 Jan 2023 15:18:50 -0800 Message-Id: <20230117231853.1511529-1-raj.khem@gmail.com> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Tue, 17 Jan 2023 23:19:00 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/176066 Signed-off-by: Khem Raj --- ...sing-_Alignof-when-using-C11-or-newe.patch | 52 +++++++++++++++++++ meta/recipes-extended/mdadm/mdadm_4.2.bb | 1 + 2 files changed, 53 insertions(+) create mode 100644 meta/recipes-extended/mdadm/files/0001-Define-alignof-using-_Alignof-when-using-C11-or-newe.patch diff --git a/meta/recipes-extended/mdadm/files/0001-Define-alignof-using-_Alignof-when-using-C11-or-newe.patch b/meta/recipes-extended/mdadm/files/0001-Define-alignof-using-_Alignof-when-using-C11-or-newe.patch new file mode 100644 index 0000000000..1c472886b3 --- /dev/null +++ b/meta/recipes-extended/mdadm/files/0001-Define-alignof-using-_Alignof-when-using-C11-or-newe.patch @@ -0,0 +1,52 @@ +From 82c893bb9e01f914a6bdef1bef943af746cfc3e1 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Sun, 15 Jan 2023 12:42:18 -0800 +Subject: [PATCH] Define alignof using _Alignof when using C11 or newer + +WG14 N2350 made very clear that it is an UB having type definitions +within "offsetof" [1]. This patch enhances the implementation of macro +alignof_slot to use builtin "_Alignof" to avoid undefined behavior on +when using std=c11 or newer + +clang 16+ has started to flag this [2] + +Fixes build when using -std >= gnu11 and using clang16+ + +Older compilers gcc < 4.9 or clang < 8 has buggy _Alignof even though it +may support C11, exclude those compilers too + +[1] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2350.htm +[2] https://reviews.llvm.org/D133574 + +Upstream-Status: Pending +Signed-off-by: Khem Raj +--- + sha1.c | 12 +++++++++++- + 1 file changed, 11 insertions(+), 1 deletion(-) + +diff --git a/sha1.c b/sha1.c +index 89b32f4..1e4ad5d 100644 +--- a/sha1.c ++++ b/sha1.c +@@ -229,7 +229,17 @@ sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx) + if (len >= 64) + { + #if !_STRING_ARCH_unaligned +-# define alignof(type) offsetof (struct { char c; type x; }, x) ++/* GCC releases before GCC 4.9 had a bug in _Alignof. See GCC bug 52023 ++ . ++ clang versions < 8.0.0 have the same bug. */ ++# if (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 \ ++ || (defined __GNUC__ && __GNUC__ < 4 + (__GNUC_MINOR__ < 9) \ ++ && !defined __clang__) \ ++ || (defined __clang__ && __clang_major__ < 8)) ++# define alignof(type) offsetof (struct { char c; type x; }, x) ++# else ++# define alignof(type) _Alignof(type) ++# endif + # define UNALIGNED_P(p) (((size_t) p) % alignof (sha1_uint32) != 0) + if (UNALIGNED_P (buffer)) + while (len > 64) +-- +2.39.0 + diff --git a/meta/recipes-extended/mdadm/mdadm_4.2.bb b/meta/recipes-extended/mdadm/mdadm_4.2.bb index 7298860241..1c4397509b 100644 --- a/meta/recipes-extended/mdadm/mdadm_4.2.bb +++ b/meta/recipes-extended/mdadm/mdadm_4.2.bb @@ -25,6 +25,7 @@ SRC_URI = "${KERNELORG_MIRROR}/linux/utils/raid/mdadm/${BPN}-${PV}.tar.xz \ file://0001-Fix-parsing-of-r-in-monitor-manager-mode.patch \ file://0001-Makefile-install-mdcheck.patch \ file://0001-restripe.c-Use-_FILE_OFFSET_BITS-to-enable-largefile.patch \ + file://0001-Define-alignof-using-_Alignof-when-using-C11-or-newe.patch \ " SRC_URI[sha256sum] = "461c215670864bb74a4d1a3620684aa2b2f8296dffa06743f26dda5557acf01d"