Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1pgnTu-0007ot-79 for mharc-grub-devel@gnu.org; Mon, 27 Mar 2023 10:05:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pgnTq-0007nZ-Nv for grub-devel@gnu.org; Mon, 27 Mar 2023 10:05:51 -0400 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pgnTm-0002rJ-Nx for grub-devel@gnu.org; Mon, 27 Mar 2023 10:05:50 -0400 Received: by mail-pj1-x102c.google.com with SMTP id p3-20020a17090a74c300b0023f69bc7a68so8937941pjl.4 for ; Mon, 27 Mar 2023 07:05:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axtens.net; s=google; t=1679925926; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=86/P5FpSWSTrzgVYyPCFwxPa4eVqdKmlbMaBOVsI448=; b=EeBf51tBRW0sEvviC4F6He6FxjLw56d3+Xym/j/4k5kNs3th0fUGzjB0jqwcM614el nF6sIQE1qKeCuTOXuuouVUYrGrMhy7x4C5Pu7HQfdM4J6gb6H5KjLIxWCpAa7PcULBnx 9yWE5MnAWyEJLAcDfx02rVJ+yDkPturGS6qUk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679925926; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=86/P5FpSWSTrzgVYyPCFwxPa4eVqdKmlbMaBOVsI448=; b=oAHT5Wgot514RwWfmbQH15DlzgBMmR2iJ9CJ0PME1Dd5hXxeSsozsmTEtzVpBPxp8L sJodAh6aV7jZaxNL04wb0JwtJ8F2NsXPYiIkOwhN4wepVkkpp94b9YlyqWZPLPGnouDo QrPGU6fYaHHzYekE21L3H6SBXZ/ibK1Yq9HKwwtwZoFQLnosITeo41QHcbjvZZmQ5d5Z Y8rDkF96gp7/55o9i+Jgdl+nrfmadsEY7YRov0Ka9pJ+mA1YXn/PcZirYescF/gM1PJH YpBZ0u5m/r27XhiVPWen70hxDX8o/ZSyvGgSr1QgLfHKVUdm8jnXE3FuT3JAFgT42yPt KY8w== X-Gm-Message-State: AAQBX9egYhywoHRJJn9gg5z5tXyCdRvR7CFX47jxrpl22yfa9G69tK8G WO/FoknZmktjExaV0ZoHhrXKortGYycPsJ+QCKA= X-Google-Smtp-Source: AKy350Y27UmLQE0BkzE7tRUyB5CL/cMEK1HqQAMIJysAtHt3ivc4Ji/nvkuqpzUVZ3Etdr4A2kvPCA== X-Received: by 2002:a17:902:ced0:b0:19e:7a2c:78a7 with SMTP id d16-20020a170902ced000b0019e7a2c78a7mr13606099plg.57.1679925925594; Mon, 27 Mar 2023 07:05:25 -0700 (PDT) Received: from linkitivity.lan (123-243-125-234.tpgi.com.au. [123.243.125.234]) by smtp.gmail.com with ESMTPSA id c11-20020a170902aa4b00b001a1fe42a141sm8493032plr.115.2023.03.27.07.05.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 07:05:24 -0700 (PDT) From: Daniel Axtens To: grub-devel@gnu.org Cc: Daniel Axtens Subject: [PATCH 1/6] configure.ac: detect if compiler supports -fsanitize=fuzzer Date: Tue, 28 Mar 2023 01:04:54 +1100 Message-Id: <20230327140459.601018-2-dja@axtens.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230327140459.601018-1-dja@axtens.net> References: <20230327140459.601018-1-dja@axtens.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=dja@axtens.net; helo=mail-pj1-x102c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Mar 2023 14:05:52 -0000 If detected, COND_ENABLE_FUZZERS is set, which can be used in Makefile templates. This allows us to build libfuzzer fuzzers for parts of grub. --- configure.ac | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/configure.ac b/configure.ac index ca42ff8f7318..f7f305482e59 100644 --- a/configure.ac +++ b/configure.ac @@ -1922,6 +1922,31 @@ fi AC_SUBST([LIBZFS]) AC_SUBST([LIBNVPAIR]) +AC_ARG_ENABLE([fuzzers], + [AS_HELP_STRING([--enable-fuzzers], + [enable fuzzers (default=guessed)])]) +if test x"$enable_fuzzers" = xno ; then + fuzzers_excuse="explicitly disabled" +fi + +if test x"$fuzzers_excuse" = x ; then + SAVED_CFLAGS="$CFLAGS" + SAVED_CC="$CC" + CC="$HOST_CC" + CFLAGS="$HOST_CFLAGS -fsanitize=fuzzer" + AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include +#include +int LLVMFuzzerTestOneInput(const uint8_t Data, size_t Size) {return 0;}]], [[]])], + [], + [fuzzers_excuse="-fsanitize=fuzzer not supported by host compiler"]) + CFLAGS="$SAVED_CFLAGS" + CC="$SAVED_CC" +fi + +if test x"$enable_fuzzers" = xyes && test x"$fuzzers_excuse" != x ; then + AC_MSG_ERROR([fuzzers were explicitly requested but requirements are not satisfied ($fuzzers_excuse)]) +fi + LIBS="" AC_SUBST([FONT_SOURCE]) @@ -2054,6 +2079,8 @@ AM_CONDITIONAL([COND_STARFIELD], [test "x$starfield_excuse" = x]) AM_CONDITIONAL([COND_HAVE_EXEC], [test "x$have_exec" = xy]) AM_CONDITIONAL([COND_HAVE_PCI], [test "x$have_pci" = xy]) +AM_CONDITIONAL([COND_ENABLE_FUZZERS], [test "x$fuzzers_excuse" = x]) + test "x$prefix" = xNONE && prefix="$ac_default_prefix" test "x$exec_prefix" = xNONE && exec_prefix="${prefix}" datarootdir="$(eval echo "$datarootdir")" @@ -2189,5 +2216,10 @@ echo "With stack smashing protector: Yes" else echo "With stack smashing protector: No" fi +if [ x"$fuzzers_excuse" = x ]; then +echo With fuzzers: Yes +else +echo With fuzzers: No "($fuzzers_excuse)" +fi echo "*******************************************************" ] -- 2.25.1