CompilerWarnings task does not catch C++ warnings

Started by Peter Eisentrautover 1 year ago4 messages
#1Peter Eisentraut
peter@eisentraut.org
1 attachment(s)

The CompilerWarnings task on Cirrus CI does not catch warnings in C++
code. It tries to make warnings fatal by passing COPT='-Werror', but
that does not apply to C++ compilations.

I suggest that we just add COPT to CXXFLAGS as well. I think passing
-Werror is just about the only reasonable use of COPT nowadays, so
making that more robust seems useful. I don't think there is a need for
a separate make variable for C++ here.

Attachments:

0001-Apply-COPT-to-CXXFLAGS-as-well.patchtext/plain; charset=UTF-8; name=0001-Apply-COPT-to-CXXFLAGS-as-well.patchDownload
From dbd1f09836e59fe163f72c4170d628f302bf5587 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Mon, 17 Jun 2024 10:33:19 +0200
Subject: [PATCH] Apply COPT to CXXFLAGS as well

The main use of that make variable is to pass in -Werror.  It makes
sense to apply this to C++ as well.
---
 src/Makefile.global.in | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index 0a0ba0719f5..42f50b49761 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -742,6 +742,7 @@ endif
 #
 ifdef COPT
    CFLAGS += $(COPT)
+   CXXFLAGS += $(COPT)
    LDFLAGS += $(COPT)
 endif
 
-- 
2.45.2

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Peter Eisentraut (#1)
Re: CompilerWarnings task does not catch C++ warnings

Peter Eisentraut <peter@eisentraut.org> writes:

The CompilerWarnings task on Cirrus CI does not catch warnings in C++
code. It tries to make warnings fatal by passing COPT='-Werror', but
that does not apply to C++ compilations.
I suggest that we just add COPT to CXXFLAGS as well. I think passing
-Werror is just about the only reasonable use of COPT nowadays, so
making that more robust seems useful. I don't think there is a need for
a separate make variable for C++ here.

+1, but what about the meson side of things?

regards, tom lane

#3Peter Eisentraut
peter@eisentraut.org
In reply to: Tom Lane (#2)
Re: CompilerWarnings task does not catch C++ warnings

On 18.06.24 16:08, Tom Lane wrote:

Peter Eisentraut <peter@eisentraut.org> writes:

The CompilerWarnings task on Cirrus CI does not catch warnings in C++
code. It tries to make warnings fatal by passing COPT='-Werror', but
that does not apply to C++ compilations.
I suggest that we just add COPT to CXXFLAGS as well. I think passing
-Werror is just about the only reasonable use of COPT nowadays, so
making that more robust seems useful. I don't think there is a need for
a separate make variable for C++ here.

+1, but what about the meson side of things?

If you use meson {setup|configure} --werror, that would affect both C
and C++ compilers.

#4Andres Freund
andres@anarazel.de
In reply to: Peter Eisentraut (#1)
Re: CompilerWarnings task does not catch C++ warnings

Hi,

On 2024-06-18 09:27:02 +0200, Peter Eisentraut wrote:

The CompilerWarnings task on Cirrus CI does not catch warnings in C++ code.
It tries to make warnings fatal by passing COPT='-Werror', but that does not
apply to C++ compilations.

I suggest that we just add COPT to CXXFLAGS as well. I think passing
-Werror is just about the only reasonable use of COPT nowadays, so making
that more robust seems useful. I don't think there is a need for a separate
make variable for C++ here.

+1

Greetings,

Andres Freund