-
Notifications
You must be signed in to change notification settings - Fork 399
Create shared sources directory for ext/
#5088
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,26 @@ module LibdatadogExtconfHelpers | |
| # may see multiple libdatadog versions. See https://github.com/DataDog/dd-trace-rb/pull/2531 for the horror story. | ||
| LIBDATADOG_VERSION = '~> 24.0.1.1.0' | ||
|
|
||
| # Include sources in the `shared` directory. We intentionally: | ||
| # * Keep every entry in $srcs to the basename so mkmf/VPATH can resolve them correctly. | ||
| # * Add the shared directory to $VPATH using $(srcdir) so the generated Makefile works no matter where it's run from. | ||
| # * Extend $INCFLAGS with the same path so headers resolve without absolute paths that would break relocation. | ||
| def self.add_shared_sources!(extension_dir:, shared_relative_dir:) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor: Maybe hardcode |
||
| shared_absolute_dir = File.expand_path(shared_relative_dir, extension_dir) | ||
| shared_sources = Dir[File.join(shared_absolute_dir, '*.c')].map { |path| File.basename(path) } | ||
| extension_sources = Dir[File.join(extension_dir, '*.c')].map { |path| File.basename(path) } | ||
|
|
||
| $srcs = extension_sources + shared_sources | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So I added this to the bottom of the $stderr.puts("$srcs: #{$srcs.inspect}")
$stderr.puts("$VPATH: #{$objs.inspect}")
$stderr.puts("$INCFLAGS: #{$INCFLAGS.inspect}")and I got this on master:
...and this on this branch:
I usually avoid the vague "let's do X 'just in case'" approach to things, but given:
My suggestion would be to setup
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good!
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll add some extra documentation for this section, regarding the pattern of following the upstream pattern. |
||
| $VPATH ||= [] | ||
|
|
||
| shared_search_dir = File.join('$(srcdir)', shared_relative_dir) | ||
| $VPATH << shared_search_dir unless $VPATH.include?(shared_search_dir) | ||
|
|
||
| $INCFLAGS ||= '' | ||
| include_token = " -I#{shared_search_dir}" | ||
| $INCFLAGS << include_token unless $INCFLAGS.include?(include_token) | ||
| end | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I soft-suspected we may be missing something with the headers, since if we don't explicitly list all headers in the Makefile, make won't know to rebuild the code if the header changes (even though it can find the headers). I diff'd the -HDRS = $(srcdir)/clock_id.h $(srcdir)/collectors_discrete_dynamic_sampler.h $(srcdir)/collectors_dynamic_sampling_rate.h $(srcdir)/collectors_gc_profiling_helper.h $(srcdir)/collectors_idle_sampling_helper.h $(srcdir)/collectors_stack.h $(srcdir)/collectors_thread_context.h $(srcdir)/datadog_ruby_common.h $(srcdir)/encoded_profile.h $(srcdir)/gvl_profiling_helper.h $(srcdir)/heap_recorder.h $(srcdir)/helpers.h $(srcdir)/libdatadog_helpers.h $(srcdir)/private_vm_api_access.h $(srcdir)/ruby_helpers.h $(srcdir)/setup_signal_handler.h $(srcdir)/stack_recorder.h $(srcdir)/time_helpers.h $(srcdir)/unsafe_api_calls_check.h
+HDRS = $(srcdir)/clock_id.h $(srcdir)/collectors_discrete_dynamic_sampler.h $(srcdir)/collectors_dynamic_sampling_rate.h $(srcdir)/collectors_gc_profiling_helper.h $(srcdir)/collectors_idle_sampling_helper.h $(srcdir)/collectors_stack.h $(srcdir)/collectors_thread_context.h $(srcdir)/encoded_profile.h $(srcdir)/gvl_profiling_helper.h $(srcdir)/heap_recorder.h $(srcdir)/helpers.h $(srcdir)/libdatadog_helpers.h $(srcdir)/private_vm_api_access.h $(srcdir)/ruby_helpers.h $(srcdir)/setup_signal_handler.h $(srcdir)/stack_recorder.h $(srcdir)/time_helpers.h $(srcdir)/unsafe_api_calls_check.hTL;DR I believe |
||
|
|
||
| # Used as an workaround for a limitation with how dynamic linking works in environments where the datadog gem and | ||
| # libdatadog are moved after the extension gets compiled. | ||
| # | ||
|
|
||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw if you want to add any specs (hint hint lol haha), there's already a
libdatadog_extconf_helpers_spec.rbliving inside profiling that we can use ;)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the other comments, you brought up very good concerns that I didn't think of when writing this.
So I'll see if I can get as many of them as possible in tests, thank you so much for all the feedback!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good! TBH I think this is already in very good shape so feel free to split improvements into separate PRs vs waiting for a bigger PR with it all ;)