bugXlog - Bugs: bug #60003, xlog adds gcc-specific warning...

 
 

bug #60003: xlog adds gcc-specific warning flags when building under clang

Submitter:  Greg Troxel <gdt>
Submitted:  Thu 04 Feb 2021 07:33:45 PM UTC
   
 
Category:  General Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  andystewart
Open/Closed:  Closed Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Sun 28 Nov 2021 06:07:45 PM UTC, comment #9: 

Hi,

In case this helps others building on Debian-based systems, AX_CHECK_COMPILE_FLAG is defined in the autoconf-archive package.  If this package isn't installed in the build environment, the build of xlog will fail with:


...
checking for strchr... yes
checking for index... yes
./configure: line 4985: syntax error near unexpected token `-Werror,'
./configure: line 4985: `AX_CHECK_COMPILE_FLAG(-Werror, CFLAGS="$CFLAGS -Werror", , )'


Regards,
tony (on behalf of the Debian Hamradio Maintainers Team)
KG7IEL

tony mancill <tmancill>
Thu 18 Feb 2021 01:36:57 PM UTC, comment #8: 

Thanks, Greg, for testing these modifications.  I'm glad it is working for you!  73 de Andy KB1OIQ

Andy Stewart <andystewart>
Group administrator
Thu 18 Feb 2021 01:27:48 AM UTC, comment #7: 

Seems to work well; got clean compiles on macOS 10.13 (clang) and NetBSD 9 (gcc).  This bug is ready to close from my viewpoint - thanks for the fix.

Greg Troxel <gdt>
Wed 17 Feb 2021 08:01:04 PM UTC, comment #6: 

Hi Greg,

Please try xlog-2.0.21beta3.  It has this modification.

73,

Andy

Andy Stewart <andystewart>
Group administrator
Wed 17 Feb 2021 03:27:59 PM UTC, comment #5: 

The new test is almost working, but runs afoul of an unknown warning option being a warning.

configure:4550: checking whether C compiler accepts -Wno-stringop-truncation
configure:4569: clang -c -pipe -I/opt/pkg/include -I/usr/include -I/opt/pkg/include/glib-2.0 -I/opt/pkg/include/gio-unix-2.0 -I/opt/pkg/lib/glib-2.0/include -I/opt/pkg/include/freetype2 -I/opt/pkg\
/include/harfbuzz -Wno-deprecated-declarations -Wall  -Wno-stringop-truncation -I/opt/pkg/include -I/usr/include -I/opt/pkg/include/glib-2.0 -I/opt/pkg/include/gio-unix-2.0 -I/opt/pkg/lib/glib-2.0\
/include -I/opt/pkg/include/freetype2 -I/opt/pkg/include/harfbuzz conftest.c >&5
warning: unknown warning option '-Wno-stringop-truncation'; did you mean '-Wno-string-conversion'? [-Wunknown-warning-option]
1 warning generated.
configure:4569: $? = 0
configure:4577: result: yes

so the configure test wrongly concludes that -Wno-stringop-truncation is ok.   I manually moved the -Werror test up (in configure, as configure.ac was unusable earlier) so that it is done before all the rest of the tests.  Then I got:

checking whether C compiler accepts -Werror... yes
checking whether C compiler accepts -Wno-deprecated-declarations... yes
checking whether C compiler accepts -Wall... yes
checking whether C compiler accepts -Wno-stringop-truncation... no
checking whether C compiler accepts -Wno-unused-but-set-variable... no

instead of a yes for the two that are no as shown, and I get a no-warnings compile under macOS 10.13 with clang 10+applestuff.

So I think if you just move the configure.ac chunk for Werror to before the others, the checks will check the right thing (unless you run into a compiler that doesn't support -Werror, which would surprise me).

Greg Troxel <gdt>
Wed 17 Feb 2021 01:53:56 AM UTC, comment #4: 

These changes were released with xlog-2.0.21beta2.  Greg: if you can test this, that would be most helpful.  Thanks!

Andy Stewart <andystewart>
Group administrator
Mon 15 Feb 2021 11:19:13 PM UTC, comment #3: 

Hi Greg,

In configure.ac, I see the following:

if test "${ac_cv_c_compiler_gnu}" = "yes"; then
  CFLAGS="${CFLAGS} -Wno-deprecated-declarations -Wall -Wno-stringop-truncation -Wno-unused-but-set-variable -Werror"
fi

I've read online that clang and gcc are not easily distinguishable in this regard, and that code isn't doing the right thing in your case.

So......I've commented out the above and added the following:

AX_CHECK_COMPILE_FLAG([-Wno-deprecated-declarations], [CFLAGS="$CFLAGS -Wno-deprecated-declarations"], [], [])
AX_CHECK_COMPILE_FLAG([-Wall], [CFLAGS="$CFLAGS -Wall"], [], [])
AX_CHECK_COMPILE_FLAG([-Wno-stringop-truncation], [CFLAGS="$CFLAGS -Wno-stringop-truncation"], [], [])
AX_CHECK_COMPILE_FLAG([-Wno-unused-but-set-variable], [CFLAGS="$CFLAGS -Wno-unused-but-set-variable"], [], [])
AX_CHECK_COMPILE_FLAG([-Werror], [CFLAGS="$CFLAGS -Werror"], [], [])

It works for me using gcc.  Can you test it with clang?

Thanks, and 73,

Andy
KB1OIQ

Andy Stewart <andystewart>
Group administrator
Thu 04 Feb 2021 09:48:13 PM UTC, comment #2: 

Sorry, -Wno-stringop-truncation is apparently ok on clang.  But it is said not to be ok on earlier gcc.  As a random example of another project adding it only for gcc 9:

https://github.com/PX4/PX4-Autopilot/commit/e3e7cb415822a93b09ddcf077af015001c51f1b9

It seems to be ok on gcc 7, and notes in pkgsrc say it was not ok in gcc 5.

Greg Troxel <gdt>
Thu 04 Feb 2021 07:44:08 PM UTC, comment #1: 

Sorry, this is 2.0.20 as well.

Greg Troxel <gdt>
Thu 04 Feb 2021 07:33:45 PM UTC, original submission:  

In pkgsrc, we have essentially a patch (run time compiler line transform) to remove warning options when building under clang.  Otherwise, the compilations all fail with an unknown command-line argument.

BUILDLINK_TRANSFORM+=   rm:-Wno-unused-but-set-variable
BUILDLINK_TRANSFORM+=   rm:-Wno-stringop-truncation

The bug I'm reporting is that these gcc-specific warning flags are being added by xlog's build system even if the compiler is clang and not gcc.




Greg Troxel <gdt>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by tmancill (Posted a comment)
  • -email is unavailable- added by andystewart (Posted a comment)
  • -email is unavailable- added by gdt (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-02-18 andystewart StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2021-02-17 andystewart StatusNeed Info Ready For Test
    2021-02-17 andystewart StatusIn Progress Need Info
    2021-02-15 andystewart StatusNone In Progress
        Assigned toNone andystewart

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code