From 9234ed312206252f01d3b6e403c065744a38b96f Mon Sep 17 00:00:00 2001 From: Richard Brooksby Date: Sun, 23 Jul 2023 07:38:35 +0100 Subject: [PATCH 1/8] Adding GCC 12 to build matrix to provoke warnings. --- .github/workflows/build-and-test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 1ab63c1159..e78cd33798 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -35,10 +35,12 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest] - compiler: [clang, gcc] + compiler: [clang, gcc, gcc-12] exclude: - os: macos-latest compiler: gcc + - os: macos-latest + compiler: gcc-12 runs-on: ${{ matrix.os }} From a9407bec776034567a7227c2200b3f4c6d98e380 Mon Sep 17 00:00:00 2001 From: Richard Brooksby Date: Sun, 23 Jul 2023 08:04:21 +0100 Subject: [PATCH 2/8] Adding GCC version output to check and record which exact version of GCC is in use. The configure script does not display it. --- .github/workflows/build-and-test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index e78cd33798..ef66c76b96 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -47,6 +47,7 @@ jobs: # See design.mps.tests.ci.run.posix. steps: - uses: actions/checkout@v3 + - run: CC=${{ matrix.compiler }} $CC --version - run: CC=${{ matrix.compiler }} ./configure - run: make - run: make test From 90a4d23763175288ddfb00a5601b45b28bc52e97 Mon Sep 17 00:00:00 2001 From: Richard Brooksby Date: Sun, 23 Jul 2023 08:07:02 +0100 Subject: [PATCH 3/8] Second attempt at GCC version output. Variable expansion does not work as expected. --- .github/workflows/build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index ef66c76b96..7210146e88 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -47,7 +47,7 @@ jobs: # See design.mps.tests.ci.run.posix. steps: - uses: actions/checkout@v3 - - run: CC=${{ matrix.compiler }} $CC --version + - run: ${{ matrix.compiler }} --version - run: CC=${{ matrix.compiler }} ./configure - run: make - run: make test From 8e117ae69ea8a8017a0586569146b133786bf1ac Mon Sep 17 00:00:00 2001 From: Richard Brooksby Date: Sun, 23 Jul 2023 07:42:03 +0000 Subject: [PATCH 4/8] Suppress uninitialized warning from GCC 12.2. --- code/arenavm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/arenavm.c b/code/arenavm.c index 50708e9563..11aca9d1c9 100644 --- a/code/arenavm.c +++ b/code/arenavm.c @@ -600,7 +600,7 @@ static Res VMArenaCreate(Arena *arenaReturn, ArgList args) VM vm = &vmStruct; Chunk chunk; mps_arg_s arg; - char vmParams[VMParamSize]; + char vmParams[VMParamSize] = {0}; /* suppress uninitialized warning from GCC 12.2 */ AVER(arenaReturn != NULL); AVERT(ArgList, args); From af093511133de407f037df630575df176bbe116f Mon Sep 17 00:00:00 2001 From: Richard Brooksby Date: Tue, 25 Jul 2023 07:44:09 +0100 Subject: [PATCH 5/8] Suppress (legitimate) dangling pointer warning from GCC 13.1 to resolve GitHub issue #256 . --- code/ss.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/code/ss.c b/code/ss.c index ce088101f1..2d8bbb2fe5 100644 --- a/code/ss.c +++ b/code/ss.c @@ -1,7 +1,7 @@ /* ss.c: STACK SCANNING * * $Id$ - * Copyright (c) 2001-2020 Ravenbrook Limited. See end of file for license. + * Copyright (c) 2001-2023 Ravenbrook Limited. See end of file for license. * * This scans the mutator's stack and fixes the registers that may * contain roots. . @@ -30,12 +30,22 @@ SRCID(ss, "$Id$"); * stack by the caller below its other local data, so as long as * it does not use something like alloca, the address of the argument * is a hot stack pointer. . + * + * GCC 13.1 legitimately complains about us leaking a dangling pointer + * (-Wdangling-pointer) -- it's exactly what we are trying to do. + * Rather that suppressing this warning globally, we use Diagnostic + * Pragmas + * to + * suppress the warning only here. */ ATTRIBUTE_NOINLINE void StackHot(void **stackOut) { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdangling-pointer" *stackOut = &stackOut; +#pragma GCC diagnostic pop } @@ -71,7 +81,7 @@ Res StackScan(ScanState ss, void *stackCold, /* C. COPYRIGHT AND LICENSE * - * Copyright (C) 2001-2020 Ravenbrook Limited . + * Copyright (C) 2001-2023 Ravenbrook Limited . * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are From 086545aec2cc932ccb17f8c011334847c1bd770b Mon Sep 17 00:00:00 2001 From: Richard Brooksby Date: Tue, 25 Jul 2023 07:52:31 +0100 Subject: [PATCH 6/8] Suppress warning when GCC before 13.1 doesn't know about -Wdangling-pointer. --- code/ss.c | 1 + 1 file changed, 1 insertion(+) diff --git a/code/ss.c b/code/ss.c index 2d8bbb2fe5..6feeac1fc2 100644 --- a/code/ss.c +++ b/code/ss.c @@ -43,6 +43,7 @@ ATTRIBUTE_NOINLINE void StackHot(void **stackOut) { #pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunknown-warning-option" #pragma GCC diagnostic ignored "-Wdangling-pointer" *stackOut = &stackOut; #pragma GCC diagnostic pop From 795f4415132c06ec6cf14db1d6e748ad8fc8710d Mon Sep 17 00:00:00 2001 From: Richard Brooksby Date: Tue, 25 Jul 2023 08:03:35 +0100 Subject: [PATCH 7/8] Suppress warnings from GCC 11 and 12 about not knowing the warning to suppress unknown warnings. --- code/ss.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/code/ss.c b/code/ss.c index 6feeac1fc2..fe38296477 100644 --- a/code/ss.c +++ b/code/ss.c @@ -31,18 +31,21 @@ SRCID(ss, "$Id$"); * it does not use something like alloca, the address of the argument * is a hot stack pointer. . * - * GCC 13.1 legitimately complains about us leaking a dangling pointer - * (-Wdangling-pointer) -- it's exactly what we are trying to do. - * Rather that suppressing this warning globally, we use Diagnostic - * Pragmas - * to - * suppress the warning only here. */ ATTRIBUTE_NOINLINE void StackHot(void **stackOut) { + /* GCC 13.1 legitimately complains about us leaking a dangling + pointer (-Wdangling-pointer) -- it's exactly what we are trying to + do. Rather that suppressing this warning globally, we use + Diagnostic Pragmas + to + suppress the warning only here. */ #pragma GCC diagnostic push + /* Prevent GCC 11 and GCC 12 producing warnings that they don't know + about -Wdangling-pointer and -Wunknown-warning-option. */ +#pragma GCC diagnostic ignored "-Wpragmas" #pragma GCC diagnostic ignored "-Wunknown-warning-option" #pragma GCC diagnostic ignored "-Wdangling-pointer" *stackOut = &stackOut; From 6d4ac64f3e18739b3c9269f708b4170ce40c207d Mon Sep 17 00:00:00 2001 From: Richard Brooksby Date: Tue, 25 Jul 2023 08:09:52 +0100 Subject: [PATCH 8/8] Restricting GCC-specific pragmas to build.gc to avoid warnings on build.mv. --- code/ss.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/code/ss.c b/code/ss.c index fe38296477..2f421b88d4 100644 --- a/code/ss.c +++ b/code/ss.c @@ -42,14 +42,20 @@ void StackHot(void **stackOut) Diagnostic Pragmas to suppress the warning only here. */ -#pragma GCC diagnostic push +#if CONFIG_BUILD_GC +# pragma GCC diagnostic push /* Prevent GCC 11 and GCC 12 producing warnings that they don't know about -Wdangling-pointer and -Wunknown-warning-option. */ -#pragma GCC diagnostic ignored "-Wpragmas" -#pragma GCC diagnostic ignored "-Wunknown-warning-option" -#pragma GCC diagnostic ignored "-Wdangling-pointer" +# pragma GCC diagnostic ignored "-Wpragmas" +# pragma GCC diagnostic ignored "-Wunknown-warning-option" +# pragma GCC diagnostic ignored "-Wdangling-pointer" +#endif + *stackOut = &stackOut; -#pragma GCC diagnostic pop + +#if CONFIG_BUILD_GC +# pragma GCC diagnostic pop +#endif }