Skip to content

JIT compilation fails recently on Mac M1: 'assert.h' file not found #127480

Closed

Description

@smontanaro

Bug report

Bug description:

In the past few days, the JIT fragment compilation step began failing for me on my M1 MacBook Pro (running Sequoia 15.1.1). The complaint is that assert.h can't be found. I'm using clang 19 from homebrew. (Apple's /usr/bin/clang is still v16, which isn't new enough to compile the JIT stuff, as I understand it.):

% clang -v    
Homebrew clang version 19.1.4
Target: arm64-apple-darwin24.1.0
Thread model: posix
InstalledDir: /opt/homebrew/Cellar/llvm/19.1.4/bin
Configuration file: /opt/homebrew/etc/clang/arm64-apple-darwin24.cfg
System configuration file directory: /opt/homebrew/etc/clang
User configuration file directory: /Users/skip/.config/clang

and am told these are the default include file directories:

% echo | clang -xc -E -v -
...
#include "..." search starts here:
#include <...> search starts here:
 /opt/homebrew/Cellar/llvm/19.1.4/lib/clang/19/include
 /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include
 /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/System/Library/Frameworks (framework directory)
End of search list.

There is an assert.h in the llvm wrappers subdir that first directory:

/opt/homebrew/Cellar/llvm/19.1.4/lib/clang/19/include/llvm_libc_wrappers/assert.h

I assume that the LLVM folks know what they are doing and actually search that wrappers directory. ¯_(ツ)_/¯

I've attached a file with the output of the compilation.
errors.txt

In the end, I suspect it will turn out that I've done something wrong, but I post here just in case I'm correct.

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Activity

  1. Eclips4 commented on Dec 1, 2024

    @Eclips4
    Member

    This error looks pretty familiar to me. Sometime ago, we saw this error after upgrading LLVM from version 18 to version 19. The problem was not on our side, IIRC. Here's a fix for our CI #126494.

  2. Eclips4 commented on Dec 1, 2024

    @Eclips4
    Member

    So, I also have a MacBook with an M1 chip, and it has LLVM 19.1.2 installed. JIT compilation didn't fail with that version, but after upgrading to LLVM 19.1.4 (I also use homebrew), I started getting the same error during JIT compilation:

    /Users/admin/Projects/cpython/Include/Python.h/Users/admin/Projects/cpython/Include/Python.h::1919::1010::  fatal error: fatal error: 'assert.h' file not found'assert.h' file not found
    
       19 | #include <assert.h>                 19 | #include <asse rt./h/>  a s s e r t ( )
            |            ^~~~~~~~~~
    // assert()
          |          ^~~~~~~~~~
  3. smontanaro commented on Dec 1, 2024

    @smontanaro
    ContributorAuthor

    So, I also have a MacBook with an M1 chip, and it has LLVM 19.1.2 installed. JIT compilation didn't fail with that version, but after upgrading to LLVM 19.1.4 (I also use homebrew)

    I'm not much of a homebrew swiss army knife user. How would I back up to 19.1.2? brew search llvm only shows llvm@19. I saw nothing in the output of brew install --help which suggested I could pick specific minor and micro versions.

  4. Eclips4 commented on Dec 1, 2024

    @Eclips4
    Member

    I'm not much of a homebrew swiss army knife user. How would I back up to 19.1.2? brew search llvm only shows llvm@19. I saw nothing in the output of brew install --help which suggested I could pick specific minor and micro versions.

    Unfortunately, there's no easy way to install a specific version :(
    Perhaps we need to wait until 19.1.5 gets released.

  5. smontanaro commented on Dec 1, 2024

    @smontanaro
    ContributorAuthor

    Perhaps we need to wait until 19.1.5 gets released.

    That's certainly the easiest route for me. Thanks.

  6. smontanaro commented on Dec 2, 2024

    @smontanaro
    ContributorAuthor

    Not being content to leave well enough alone, I asked the Homebrew folks for help (not being sure where to ask, so I started there). The reply I got suggested this:

    mkdir -p ~/.config/clang
    echo "--sysroot=$(xcrun --show-sdk-path)" >> ~/.config/clang/aarch64-apple-darwin24.1.0.cfg
    

    which seems to have solved the issue for me. I'm closing this ticket.

  7. Eclips4 commented on Dec 2, 2024

    @Eclips4
    Member

    Not being content to leave well enough alone, I asked the Homebrew folks for help (not being sure where to ask, so I started there). The reply I got suggested this:

    mkdir -p ~/.config/clang
    echo "--sysroot=$(xcrun --show-sdk-path)" >> ~/.config/clang/aarch64-apple-darwin24.1.0.cfg
    

    which seems to have solved the issue for me. I'm closing this ticket.

    Thank you, Skip, for sharing this. I'll also apply it to fix the JIT build on my machine. 🙂

  8. changed the title [-]JIT compilation fails recently on Mac M1[/-] [+]JIT compilation fails recently on Mac M1: 'assert.h` file not found[/+] on Dec 4, 2024
  9. changed the title [-]JIT compilation fails recently on Mac M1: 'assert.h` file not found[/-] [+]JIT compilation fails recently on Mac M1: 'assert.h' file not found[/+] on Dec 4, 2024
  10. Eclips4 commented on Dec 4, 2024

    @Eclips4
    Member

    (Changing the title to make it easier to find for someone who might be fighting with the same thing)

  11. jpweytjens commented on Feb 10, 2026

    @jpweytjens

    Thanks for pointing in the right direction @smontanaro. I added the following platform independent line to my .bashrc

    export CPATH="$(xcrun --show-sdk-path)/usr/include"
    
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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions