Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

locale.c: New build-time warnings when built with clang14 #21288

Closed
jkeenan opened this issue Jul 25, 2023 · 8 comments
Closed

locale.c: New build-time warnings when built with clang14 #21288

jkeenan opened this issue Jul 25, 2023 · 8 comments
Labels
build-time-warnings Replaces [META] Build-time warnings RT #133556

Comments

@jkeenan
Copy link
Contributor

jkeenan commented Jul 25, 2023

Tonight for the first time in several months I configured and built a perl on FreeBSD-12 for the purpose of detecting build-time warnings. I build with a commit from recent days (post-5.37.1) and compiled with clang14.

$ clang14 --version
clang version 14.0.6
Target: x86_64-portbld-freebsd12.3
Thread model: posix
InstalledDir: /usr/local/llvm14/bin

$ sh ./Configure -des -Dusedevel -Duseithreads -Dcc=clang14 && \
make test_prep

$ parse-build-warnings d9203338cf.freebsd.threaded.clang14.maketp.output.txt.gz
File:  d9203338cf.freebsd.threaded.clang14.maketp.output.txt.gz

[
  {
    char   => 48,
    group  => "Wunused-parameter",
    line   => 408,
    source => "locale.c",
    text   => "unused parameter 'caller_line'",
  },
  {
    char   => 21,
    group  => "Wunused-const-variable",
    line   => 313,
    source => "locale.c",
    text   => "unused variable 'category_name_lengths'",
  },
  ...
]

(There were also 4 previously observed build-time warnings from cpan/*Compress* modules.)

In the output of make test_prep I saw:

clang14 -c -DPERL_CORE -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -std=c99 -O2 -Wall -Werror=pointer-arith -Werror=vla -Wextra -Wno-long-long -Wno-declaration-after-statement -Wc++-compat -Wwrite-strings locale.c
locale.c:408:48: warning: unused parameter 'caller_line' [-Wunused-parameter]
                                  const line_t caller_line)
                                               ^
locale.c:313:21: warning: unused variable 'category_name_lengths' [-Wunused-const-variable]
STATIC const Size_t category_name_lengths[] = {
                    ^
2 warnings generated.

For line 313 in locale.c:

commit a63ba983ed3db8a22e590abc43751d991c27d7a4
Author:     Karl Williamson <khw@cpan.org>
AuthorDate: Thu Jul 20 20:35:00 2023 -0600
Commit:     Karl Williamson <khw@cpan.org>
CommitDate: Mon Jul 24 04:10:34 2023 -0600

    locale.c: Avoid runtime strlen() calls

For line 408 in locale.c:

commit a2d04a5251e8e0c441a5c12ede6c00b49c7403b4
Author:     Karl Williamson <khw@cpan.org>
AuthorDate: Thu Apr 20 15:19:50 2023 -0600
Commit:     Karl Williamson <khw@cpan.org>
CommitDate: Mon Jul 24 04:10:34 2023 -0600

    locale.c: Refactor S_get_category_index()

@khwilliamson, can you take a look?

Thank you very much.
Jim Keenan

@jkeenan jkeenan added Needs Triage build-time-warnings Replaces [META] Build-time warnings RT #133556 labels Jul 25, 2023
@khwilliamson
Copy link
Contributor

khwilliamson commented Jul 25, 2023 via email

@jkeenan
Copy link
Contributor Author

jkeenan commented Aug 4, 2023

Future commits in the pipeline will remove these.

They appear to have been removed, but now we have an -Wunused-function warning:

clang14 -c -DPERL_CORE -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -std=c99 -O2 -Wall -Werror=pointer-arith -Werror=vla -Wextra -Wno-long-long -Wno-declaration-after-statement -Wc++-compat -Wwrite-strings locale.c
locale.c:1938:1: warning: unused function 'S_calculate_LC_ALL_string' [-Wunused-function]
S_calculate_LC_ALL_string(pTHX_ const char ** category_locales_list)
^
1 warning generated.

... which probably comes from:

a19e3599018 (Karl Williamson          2023-03-26 10:19:25 -0600 1938) S_calculate_LC_ALL_string(pTHX_ const char ** category_locales_list)

I'll proceed on the assumption that we'll soon be actually using S_calculate_LC_ALL_string.

@pmqs
Copy link
Contributor

pmqs commented Aug 18, 2023

...

(There were also 4 previously observed build-time warnings from cpan/*Compress* modules.)

I stumbled across the clang warnings issue myself when I was debugging a FreeBSD GitHub action for Compress-Raw-Zlib and noticed a stack of compiler warnings. A search for clang issues brought me here.

Issue appears to be use of an old ppport.h that looks like it can be dealt with by refreshing with a newer copy. I've created pmqs/Compress-Raw-Zlib#26 and pmqs/Compress-Raw-Bzip2#12 to track the issue with the Compress modules.

@jkeenan
Copy link
Contributor Author

jkeenan commented Aug 18, 2023

...
(There were also 4 previously observed build-time warnings from cpan/*Compress* modules.)

I stumbled across the clang warnings issue myself when I was debugging a FreeBSD GitHub action for Compress-Raw-Zlib and noticed a stack of compiler warnings. A search for clang issues brought me here.

Issue appears to be use of an old ppport.h that looks like it can be dealt with by refreshing with a newer copy. I've created pmqs/Compress-Raw-Zlib#26 and pmqs/Compress-Raw-Bzip2#12 to track the issue with the Compress modules.

Paul, thanks for keeping an eye out for this!
jimk

@jkeenan
Copy link
Contributor Author

jkeenan commented Aug 19, 2023

a19e359

The -Wunused_function warning is no longer being emitted, probably as a result of this commit:

commit 9b4482c8527453ef4973adb2eec2955a9a0f792d
Author:     Karl Williamson <khw@cpan.org>
AuthorDate: Thu Mar 30 06:40:52 2023 -0600
Commit:     Karl Williamson <khw@cpan.org>
CommitDate: Mon Aug 7 20:29:33 2023 -0600

    locale.c: Calculate native LC_ALL strings

So the only clang-specific build-time warnings still being tracked in this ticket are those mentioned in the discussion with @pmqs above.

@pmqs
Copy link
Contributor

pmqs commented Aug 19, 2023

So the only clang-specific build-time warnings still being tracked in this ticket are those mentioned in the discussion with @pmqs above.

I'm on it now. The version of ppport.h is the root-cause for the Compress::Raw::* modules clang warnings.

Problem is upgrading ppport.h breaks the tests for Compress::Raw::* when run with Perl 5.6. Reported to Devel-PPPort in Dual-Life/Devel-PPPort#231

Will temporarily disable failing tests in 5.6 for now to get this checked in.

I just love a rabbit-hole!

@pmqs
Copy link
Contributor

pmqs commented Aug 20, 2023

The clang warnings are also an issue with DB_File - created pmqs/DB_File#13 to fix.

@jkeenan
Copy link
Contributor Author

jkeenan commented Oct 4, 2023

This GH issue was originally focused on warnings being emitted during compilation of locale.c. Those have been resolved. I have opened a separate ticket for 3 other build-time warnings reported by @pmqs in this ticket. So we can now close this ticket.

@jkeenan jkeenan closed this as completed Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build-time-warnings Replaces [META] Build-time warnings RT #133556
Projects
None yet
Development

No branches or pull requests

3 participants