ruby-prof / ruby-prof

A ruby profiler. See https://ruby-prof.github.io for more information.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Gem fails to compile on Apple clang version 12.0.0

bboe opened this issue · comments

While Xcode 12 is not out of beta yet, it seems like our employees who have the latest Macbook are failing to build this library due to related updates. Here's the build error:

"make \"DESTDIR=\""
compiling rp_call_info.c
compiling rp_measure.c
compiling rp_measure_allocations.c
compiling rp_measure_cpu_time.c
compiling rp_measure_gc_runs.c
compiling rp_measure_gc_time.c
compiling rp_measure_memory.c
compiling rp_measure_process_time.c
compiling rp_measure_wall_time.c
rp_measure_wall_time.c:13:5: error: implicit declaration of function 'gettimeofday' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    gettimeofday(&tv, NULL);
    ^
1 error generated.
make: *** [rp_measure_wall_time.o] Error 1
ERROR:  Error installing ruby-prof:
        ERROR: Failed to build gem native extension.

Here's the gcc version that results in the failing build:

$ gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/c++/4.2.1
Apple clang version 12.0.0 (clang-1200.0.26.2)
Target: x86_64-apple-darwin19.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

I believe Apple clang version 12 to be the issue because in their beta release notes it reads:

Clang now reports an error when you use a function without an explicit declaration when building C or Objective-C code for macOS (-Werror=implicit-function-declaration flag is on). This additional error detection unifies Clang’s behavior for iOS/tvOS and macOS 64-bit targets for this diagnostic. (49917738)

Source: https://developer.apple.com/documentation/xcode-release-notes/xcode-12-beta-release-notes

That error message doesn't match the actual code:

static VALUE cMeasureWallTime;

Notice there is nothing at line 13.

Also note that gettimeofday is protected by a macro and should only compile under Linux.

So I'm confused...what exactly are you building?

It looks like our bundle had it locked to version 0.13.0. 🤦 I would guess this problem doesn't occur on the latest, though I cannot confirm right now.

Ok, so I'd definitely recommend upgrading. Lots of work went into getting 1.x series released.