tracing: include tracepoints in GUIX builds #23297

issue 0xB10C openend this issue on October 17, 2021
  1. 0xB10C commented at 2:42 pm on October 17, 2021: member

    There has been light conceptual agreement on including the USDT based tracepoints in Bitcoin Core release builds. This, for example, enables user to hook into production deployments, if they need to. Binaries don’t have to be switched out. This is possible because we don’t do expensive computations only for the tracepoints and the tracepoints are NOPs when not used.

    There is a slight chance that the GUIX build on the current master already includes the tracepoints. I have not done an GUIX build on a branch with the tracepoints merged yet. This can be tested on a bitcoind binary using one of the methods mentioned in the tracing documentation section “Listing avaliable tracepoints”.

    If not present, making the systemtap headers (sys/sdt.h) available during the GUIX build should build bitcoind with the tracepoints.

  2. 0xB10C added the label Feature on Oct 17, 2021
  3. sipa deleted a comment on Oct 17, 2021
  4. MarcoFalke added the label Build system on Oct 18, 2021
  5. 0xB10C commented at 10:46 am on November 26, 2021: member

    There is a slight chance that the GUIX build on the current master already includes the tracepoints. I have not done an GUIX build on a branch with the tracepoints merged yet. This can be tested on a bitcoind binary using one of the methods mentioned in the tracing documentation section “Listing avaliable tracepoints”.

    A GUIX build on 76392b042e98 didn’t include the tracepoints. The systemtap headers need to be added.

  6. 0xB10C commented at 9:04 am on December 3, 2021: member

    I’ve been exploring this a bit more. Currently two approaches, non of them really great.

    • a) Package the systemtap sys/sdt.h header as GUIX package in manifest.scm and make it available as include during configure and build.
      • See GUIX package definition below.
      • While the package is available during configure and build, the header includes not are picked up automatically. Likely, an additional include needs to be set.
    • b) Include systemtap as package in depends
      • We don’t need systemtap. We only need the sys/sdt.h header file.
      • depends are usually compiled, we don’t want and need to compile systemtap here.

    Carl Dong noted that this belongs into the depends and shouldn’t be a GUIX package.

     0diff --git a/contrib/guix/manifest.scm b/contrib/guix/manifest.scm
     1index 580500605..3f4814ba3 100644
     2--- a/contrib/guix/manifest.scm
     3+++ b/contrib/guix/manifest.scm
     4@@ -30,6 +30,7 @@
     5              (gnu packages shells)
     6              (gnu packages tls)
     7              (gnu packages version-control)
     8+             (guix build-system copy)
     9              (guix build-system font)
    10              (guix build-system gnu)
    11              (guix build-system python)
    12@@ -597,6 +598,27 @@ inspecting signatures in Mach-O binaries.")
    13   (package-with-extra-patches glibc-2.27
    14     (search-our-patches "glibc-2.27-riscv64-Use-__has_include__-to-include-asm-syscalls.h.patch")))
    15
    16+(define-public systemtap-sdt
    17+  (package
    18+    (name "systemtap-sdt")
    19+    (version "4.6")
    20+    (source (origin
    21+              (method url-fetch)
    22+              (uri (string-append "https://sourceware.org/systemtap/ftp/releases/systemtap-" version
    23+                                  ".tar.gz"))
    24+              (sha256
    25+               (base32
    26+                "1bps2926x9m8mp2684wwwwjm4yb12mpylbnvnffk889b4c4p7yw0"))))
    27+    (build-system copy-build-system)
    28+    (arguments
    29+      '(#:install-plan
    30+        '(("includes/sys/sdt.h" "include/sys/sdt.h"))))
    31+    (synopsis "Systemtap header files defining tracing probe marcos")
    32+    (description "This package includes the <sys/sdt.h> header file used for static instrumentation compiled into userspace programs and libraries")
    33+    (home-page "https://sourceware.org/systemtap/")
    34+    (license license:gpl2)))
    35+
    36 (packages->manifest
    37  (append
    38   (list ;; The Basics
    39@@ -637,7 +659,9 @@ inspecting signatures in Mach-O binaries.")
    40         lief
    41         ;; Native gcc 7 toolchain
    42         gcc-toolchain-7
    43-        (list gcc-toolchain-7 "static"))
    44+        (list gcc-toolchain-7 "static")
    45+        ;; Tracing
    46+        systemtap-sdt)
    47   (let ((target (getenv "HOST")))
    48     (cond ((string-suffix? "-mingw32" target)
    49            ;; Windows
    
  7. 0xB10C commented at 7:17 pm on December 5, 2021: member

    Seems to be possible with option b) too. The configure/build/postprocess steps in the depends are optional and normal shell commands can be used. I haven’t figured out where to copy the includes/sys/sdt.h file from systemtap so that it makes it into depends/x86_64-linux-gnu/include/.

    I think option b) is cleaner than option a).

  8. 0xB10C commented at 5:11 pm on December 7, 2021: member

    @fanquake helped getting the includes copied. In this case it was: (note the && \ as only the first command has the correct ENV var set)

    0define $(package)_preprocess_cmds
    1  mkdir -p $($(package)_staging_prefix_dir)/include/sys && \
    2  cp -r includes/sys $($(package)_staging_prefix_dir)/include
    3endef
    

    He also commented:

    One catch is that if we don’t run configure and make, then we don’t end up with a properly named and filled out sdt-config.h. That is included from sdt.h, and determines whether the probes can use certain assembly, see _SDT_ASM_AUTOGROUP.

    Maybe this is mostly a legacy check, and we can assume that we can use it, although then we’d still have to modify the sdt.h header to drop the include and make sure _SDT_ASM_SECTION_AUTOGROUP_SUPPORT is defined ourselves.

    The annoying thing about having to run configure and make is that we’ll need to install a bunch of dependencies.

    The relevant section from sdt.h is

    0/* If the assembler supports the necessary feature, then we can play
    1 nice with code in COMDAT sections, which comes up in C++ code.
    2 Without that assembler support, some combinations of probe placements
    3 in certain kinds of C++ code may produce link-time errors.  */
    4#include "sdt-config.h"
    5#if _SDT_ASM_SECTION_AUTOGROUP_SUPPORT
    6# define _SDT_ASM_AUTOGROUP "?"
    7#else
    8# define _SDT_ASM_AUTOGROUP ""
    9#endif
    

    As we don’t need Systemtap itself, running configure and make would require additional dependencies and slow the depends build down. Both, the include of sdt-config.h in sdt.h and the sdt-config.h.in file were added and last touched in 2010 ( blame sdt.h, blame sdt-config.h.in), so it’s likely that the feature is supported by now and it should be possible to drop the include in a patch.

  9. 0xB10C commented at 5:25 pm on December 7, 2021: member

    gcc seems to have a problem with Systemtap 4.6 (Nov 2021). I’ll be using Systemtap 4.5 (May 2021) for now. From what I can tell, this is a know problem and it should be fixed in 4.7:

    https://sourceware.org/git/?p=systemtap.git;a=commit;h=1d3653936fc1fd13135a723a27e6c7e959793ad0 https://bugzilla.redhat.com/show_bug.cgi?id=2028798

  10. 0xB10C commented at 9:41 am on December 8, 2021: member

    I’ve successfully ran a GUIX build with the new sys/sdt.h systemtap depends as described above. All host triples with linux in the name contain the tracepoints (checked with readelf -n bitcoind). I haven’t looked at the macOS and Windows binaries. Maybe the macOS binaries contain tracepoints that can be listed with e.g. dtrace on macOS?

    host-triplet contains tracepoints synced signet tracepoints tested
    aarch64-linux-gnu :heavy_check_mark: :heavy_check_mark: :heavy_check_mark:
    arm-linux-gnueabihf :heavy_check_mark:
    powerpc64-linux-gnu :heavy_check_mark:
    powerpc64le-linux-gnu :heavy_check_mark:
    riscv64-linux-gnu :heavy_check_mark:
    x86_64-linux-gnu :heavy_check_mark: :heavy_check_mark:
    x86_64-apple-darwin19 :grey_question:
    x86_64-w64-mingw32 :grey_question: :heavy_check_mark:

    Will do a bit of basic testing and then open a PR.

  11. fanquake closed this on Jan 10, 2022

  12. sidhujag referenced this in commit 5ca60a8fdc on Jan 10, 2022
  13. DrahtBot locked this on Jan 10, 2023

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-07-05 19:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me