Skip to content

From CI, Tools/c-analyzer/check-c-globals.py failed #150948

Closed as not planned
Closed as not planned

Description

@YvesDup

Bug report

Bug description:

Working from this #130913 PR, I recently needed to add this line #include <sys/sysctl.h> // sysctlbyname in a header file.

From CI, the check-c-globals.py tools failed with this message:

..... ..... /home/runner/work/cpython/cpython/Modules/_multiprocessing/semaphore_macosx.h:5:10: fatal error: sys/sysctl.h: No such file or directory
    5 | #include <sys/sysctl.h>  // sysctlbyname
      |          ^~~~~~~~~~~~~~
compilation terminated.
# requested file: </home/runner/work/cpython/cpython/Modules/_multiprocessing/semaphore_macosx.h>

See https://github.com/python/cpython/actions/runs/26958247530/job/79541476456?pr=130913#step:11:39 for complete logs

cc @ericsnowcurrently (As suggested in the documentation:)

CPython versions tested on:

3.16

Operating systems tested on:

macOS

Linked PRs

Activity

  1. added
    type-bugAn unexpected behavior, bug, or error
    on Jun 5, 2026
  2. StanFromIreland commented on Jun 5, 2026

    @StanFromIreland
  3. added
    infraCI, GitHub Actions, buildbots, Dependabot, etc.
    on Jun 5, 2026
  4. YvesDup commented on Jun 5, 2026

    @YvesDup
    ContributorAuthor

    Occasionally the tool is unable to parse updated code.
    If this happens then add the file to the "EXCLUDED" list
    in Tools/c-analyzer/cpython/_parser.py and create a new
    issue for fixing the tool (and CC ericsnowcurrently
    on the issue).

    I guess if the PR is approved, this new file will be noted as excluded from the tool run.

  5. YvesDup commented on Jun 5, 2026

    @YvesDup
    ContributorAuthor

    I added in Tools/c-analyzer/cpython/_parser.py the file that raises the error.

    # XXX Handle these.
    EXCLUDED = format_conf_lines([
        # macOS
        'Modules/_scproxy.c',              # SystemConfiguration/SystemConfiguration.h
        'Modules/_multiprocessing/semaphore_macosx.h',              # <sys/sysctl.h>
    
        # Windows
    

    I created a new branch with the change into the Tools/c-analyzer/cpython/_parser.py file but the "Check for unsupported C global variables" test is disabled - see https://github.com/YvesDup/cpython/actions/runs/27023166717/job/79756266970

  6. zainnadeem786 commented on Jun 20, 2026

    @zainnadeem786
    Contributor

    Hi @StanFromIreland @YvesDup ,

    I'd like to work on this issue.

    I investigated the c-analyzer path and it appears that Modules/_multiprocessing/semaphore_macosx.h is being picked up by the analyzer through the generic Modules/**/*.h scan, but preprocessing fails on non-macOS CI because of the #include <sys/sysctl.h> dependency.

    From what I found, the existing approach for files that cannot be parsed cross-platform is to add them to the EXCLUDED list in Tools/c-analyzer/cpython/_parser.py. Similar platform-specific exclusions already exist for _scproxy.c, _winapi.c, and other OS-specific files.

    I plan to submit a small PR that adds Modules/_multiprocessing/semaphore_macosx.h to the macOS exclusion list, which appears to be consistent with the current c-analyzer guidance and existing exclusions.

    Please let me know if there is a preferred alternative approach.

  7. StanFromIreland commented on Jun 20, 2026

    @StanFromIreland
    Member

    I'm sorry but I closed your PR, it is not necessary. Such changes should be done in #130913 instead.

  8. zainnadeem786 commented on Jun 20, 2026

    @zainnadeem786
    Contributor

    @StanFromIreland Understood, thank you for the clarification. I'll follow up in #130913 instead.

  9. YvesDup commented on Jun 21, 2026

    @YvesDup
    Author
  10. StanFromIreland commented on Jun 21, 2026

    @StanFromIreland
    Member

    Sorry @YvesDup, I'm not familiar with macOS things and I don't have access to a machine to test.

  11. YvesDup commented on Jun 22, 2026

    @YvesDup
    Author
  12. YvesDup commented on Jun 22, 2026

    @YvesDup
    ContributorAuthor

    I confirm that this part of code is dedicated to macOS platform. The c-analyzer tool runs on linux where the <sys/sysctl.h> header has been deprecated for some time and no longer exists.
    So I think it makes sense to add semaphore_macosx.h into the file Tools/c-analyzer/cpython/_parser.py, as suggested below.
    I wish this is the right way to go about it.
    This modification will be add to the #130913 PR.

  13. YvesDup commented on Jun 22, 2026

    @YvesDup
    ContributorAuthor

    I will close this issue as completed. No objection ?

  14. StanFromIreland commented on Jun 22, 2026

    @StanFromIreland
    Member

    Since we don't need any action here, I agree we can close.

  15. YvesDup commented on Jun 22, 2026

    @YvesDup
    ContributorAuthor

    @StanFromIreland thank you for adding macOS team as #130913 reviewers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    infraCI, GitHub Actions, buildbots, Dependabot, etc.type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions