diff --git a/.rubocop.yml b/.rubocop.yml index b07f1bd1ac..b4c3395fbd 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -375,3 +375,6 @@ Style/TrailingCommaInHashLiteral: Style/GlobalVars: Exclude: - 'ext/ddtrace_profiling_native_extension/extconf.rb' + +Naming/VariableNumber: + Enabled: false diff --git a/ext/ddtrace_profiling_native_extension/clock_id_from_pthread.c b/ext/ddtrace_profiling_native_extension/clock_id_from_pthread.c index 9c87ea4a20..b4e37f436c 100644 --- a/ext/ddtrace_profiling_native_extension/clock_id_from_pthread.c +++ b/ext/ddtrace_profiling_native_extension/clock_id_from_pthread.c @@ -9,7 +9,12 @@ #include #include + +#ifdef RUBY_2_1_WORKAROUND +#include +#else #include +#endif #include "private_vm_api_access.h" diff --git a/ext/ddtrace_profiling_native_extension/extconf.rb b/ext/ddtrace_profiling_native_extension/extconf.rb index e9f43b9ee2..95ee8f8845 100644 --- a/ext/ddtrace_profiling_native_extension/extconf.rb +++ b/ext/ddtrace_profiling_native_extension/extconf.rb @@ -116,10 +116,18 @@ def add_compiler_flag(flag) # This gem ships source code copies of these VM headers for the different Ruby VM versions; # see https://github.com/ruby-debug/debase-ruby_core_source for details + thread_native_for_ruby_2_1 = proc { true } + if RUBY_VERSION < '2.2' + # This header became public in Ruby 2.2, but we need to pull it from the private headers folder for 2.1 + thread_native_for_ruby_2_1 = proc { have_header('thread_native.h') } + $defs << '-DRUBY_2_1_WORKAROUND' + end + create_header require 'debase/ruby_core_source' dir_config('ruby') # allow user to pass in non-standard core include directory - Debase::RubyCoreSource.create_makefile_with_core(proc { have_header('vm_core.h') }, EXTENSION_NAME) + Debase::RubyCoreSource + .create_makefile_with_core(proc { have_header('vm_core.h') && thread_native_for_ruby_2_1.call }, EXTENSION_NAME) end diff --git a/spec/ddtrace/contrib/rails/rack_spec.rb b/spec/ddtrace/contrib/rails/rack_spec.rb index fa1e7a4806..71523b9034 100644 --- a/spec/ddtrace/contrib/rails/rack_spec.rb +++ b/spec/ddtrace/contrib/rails/rack_spec.rb @@ -24,7 +24,7 @@ } end - let(:rails_older_than_3_2) do # rubocop:disable Naming/VariableNumber + let(:rails_older_than_3_2) do Gem::Version.new(Rails::VERSION::STRING) < Gem::Version.new('3.2') end