ivoanjo / gvl-tracing

Get a timeline view of Global VM Lock usage in your Ruby app
MIT License
114 stars 7 forks source link

Fails to install with latest MacOS clang #19

Closed kovyrin closed 5 months ago

kovyrin commented 5 months ago

When installing the gem on a MacOS machine (MacOS Sonoma 14.4.1 (23E224)) with the latest XCode, I see the following error:

❯ gem install gvl-tracing -v=1.5.1
Building native extensions. This could take a while...
ERROR:  Error installing gvl-tracing:
    ERROR: Failed to build gem native extension.

    current directory: /Users/kovyrin/.gem/ruby/3.3.0/gems/gvl-tracing-1.5.1/ext/gvl_tracing_native_extension
/opt/rubies/3.3.0/bin/ruby extconf.rb
checking for gettid() in unistd.h... no
checking for pthread.h... yes
checking for pthread_getname_np() in pthread.h... yes
checking for pthread_threadid_np() in pthread.h... yes
checking for rb_internal_thread_specific_get() in ruby/thread.h... yes
checking for whether -Werror-implicit-function-declaration is accepted as CFLAGS... yes
checking for whether -Wunused-parameter is accepted as CFLAGS... yes
checking for whether -Wold-style-definition is accepted as CFLAGS... yes
checking for whether -Wall is accepted as CFLAGS... yes
checking for whether -Wextra is accepted as CFLAGS... yes
creating extconf.h
creating Makefile

current directory: /Users/kovyrin/.gem/ruby/3.3.0/gems/gvl-tracing-1.5.1/ext/gvl_tracing_native_extension
make DESTDIR\= sitearchdir\=./.gem.20240403-90534-9pike1 sitelibdir\=./.gem.20240403-90534-9pike1 clean

current directory: /Users/kovyrin/.gem/ruby/3.3.0/gems/gvl-tracing-1.5.1/ext/gvl_tracing_native_extension
make DESTDIR\= sitearchdir\=./.gem.20240403-90534-9pike1 sitelibdir\=./.gem.20240403-90534-9pike1
compiling gvl_tracing.c
gvl_tracing.c:34:10: fatal error: 'threads.h' file not found
#include <threads.h>
         ^~~~~~~~~~~
1 error generated.
make: *** [gvl_tracing.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/kovyrin/.gem/ruby/3.3.0/gems/gvl-tracing-1.5.1 for inspection.
Results logged to /Users/kovyrin/.gem/ruby/3.3.0/extensions/arm64-darwin-23/3.3.0/gvl-tracing-1.5.1/gem_make.out

It seems to work as expected for my coworkers with older versions of XCode.

My gcc:

❯ gcc --version
Apple clang version 15.0.0 (clang-1500.0.40.1)
Target: arm64-apple-darwin23.4.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
kovyrin commented 5 months ago

Just confirmed it was introduced in https://github.com/ivoanjo/gvl-tracing/commit/cafbeb7ff6383f6892947e7213542c09a8f155cc. The previous revision compiles without any issues.

ivoanjo commented 5 months ago

Hey! Thanks for the report.

That failure is a bit... weird. threads.h is from C11 and I'm assuming a modern macOS/Clang would support it. I wonder if it's because it needs some extra flags to allow access to those features.

Let me try a few things and see if I can understand why clang is unhappy...

ivoanjo commented 5 months ago

So it turns out that for some bizarre reason macOS/Clang don't support all of C11, and in particular they decided they didn't like threads.h.

And it also turns out that in my excitement to put out the release, I completely missed that the CI runs we have for the gem had already failed due to the missing threads.h.

Thanks for catching and reporting this! I've pushed gvl-tracing 1.5.2 with a fix for the issue :)

kovyrin commented 5 months ago

Thank you for the fix. Just tested 1.5.2 installs correctly on my machine.