Skip to content

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

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

Closed
smontanaro opened this issue Dec 1, 2024 · 8 comments
Closed

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

smontanaro opened this issue Dec 1, 2024 · 8 comments
Labels
OS-mac topic-JIT type-bug An unexpected behavior, bug, or error

Comments

@smontanaro
Copy link
Contributor

smontanaro commented Dec 1, 2024

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

@smontanaro smontanaro added the type-bug An unexpected behavior, bug, or error label Dec 1, 2024
@Eclips4
Copy link
Member

Eclips4 commented Dec 1, 2024

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.

@Eclips4
Copy link
Member

Eclips4 commented Dec 1, 2024

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()
      |          ^~~~~~~~~~

@smontanaro
Copy link
Contributor Author

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.

@Eclips4
Copy link
Member

Eclips4 commented Dec 1, 2024

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.

@smontanaro
Copy link
Contributor Author

Perhaps we need to wait until 19.1.5 gets released.

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

@smontanaro
Copy link
Contributor Author

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.

@Eclips4
Copy link
Member

Eclips4 commented Dec 2, 2024

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. 🙂

@Eclips4 Eclips4 changed the title JIT compilation fails recently on Mac M1 JIT compilation fails recently on Mac M1: 'assert.h` file not found Dec 4, 2024
@Eclips4 Eclips4 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 Dec 4, 2024
@Eclips4
Copy link
Member

Eclips4 commented Dec 4, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OS-mac topic-JIT type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants