Project

General

Profile

Actions

Misc #19035

closed

Change of have_header behaviour between 3.0 and 3.1 causes problems for C++ extensions

Added by katafrakt (Paweł Świątkowski) over 1 year ago. Updated over 1 year ago.

Status:
Third Party's Issue
Assignee:
-
[ruby-core:<unknown>]

Description

In 4b6fd8329b46701414aba2eeca10013cf66ec513 the behaviour of have_header changed to actually compile instead of just preprocess (at least that's what I understand). This caused problems in at least one extension using C++ (bindings to RocksDB), which now does not build on MacOS on Ruby 3.1 (while still builds on 3.0.2).

A minimal reproducible code is:

require 'mkmf'
dir_config('rocksdb')
RbConfig::CONFIG["CPP"] = "#{RbConfig::CONFIG['CXX']} -E -std=gnu++17"
have_header('rocksdb/db.h')

This detects a header in 3.0.2, but not in 3.1. Looking at mkmf.log:

DYLD_FALLBACK_LIBRARY_PATH=.:/Users/pawel/.rbenv/versions/3.1.0/lib "clang -I/Users/pawel/.rbenv/versions/3.1.0/include/ruby-3.1.0/x86_64-darwin20 -I/Users/pawel/.rbenv/versions/3.1.0/include/ruby-3.1.0/ruby/backward -I/Users/pawel/.rbenv/versions/3.1.0/include/ruby-3.1.0 -I. -I/Users/pawel/.rbenv/versions/3.1.0/include  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -Wundef  -fno-common -pipe   -c conftest.c"
In file included from conftest.c:3:
/usr/local/include/rocksdb/db.h:14:10: fatal error: 'map' file not found
#include <map>
         ^~~~~
1 error generated.
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <rocksdb/db.h>
/* end */

It is because it tries to use clang (i.e. RbConfig::CONFIG['CC']) to compile it, not clang++. I can set RbConfig::CONFIG['CC'] and it works (just generates a bunch of warnings coming from Ruby itself). I'm posting this under Misc, because I don't know if it's a bug or just a hack that stopped working. If the latter, perhaps this change should be documented somewhere, as it is kind of breaking; and I haven't found any notion of it in the changelog of 3.1.

Actions

Also available in: Atom PDF

Like0
Like0