Skip to content
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

example fails to compile on ubuntu / rustc 1.53.0 #1

Open
Licenser opened this issue Jul 13, 2021 · 5 comments · May be fixed by #2
Open

example fails to compile on ubuntu / rustc 1.53.0 #1

Licenser opened this issue Jul 13, 2021 · 5 comments · May be fixed by #2

Comments

@Licenser
Copy link

Hi,

I tried to run the example code and it fails to compile. I use the dtrace provided by systemtap-sdt-dev on Ubuntu and rust 1.53.0.

The error is the following:

  = note: /usr/bin/ld: /home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/build/sonde-test-29186d9285cdc020/out/libsonde-ffi.a(sonde-ffiU70Emz.o): in function `hello_probe_you':
          /home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/build/sonde-test-29186d9285cdc020/out/sonde-ffiU70Emz.c:9: undefined reference to `HELLO_YOU'
          collect2: error: ld returned 1 exit status

or in full:

warning: /home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/build/sonde-test-29186d9285cdc020/out/sonde-ffiU70Emz.c: In function ‘hello_probe_world’:
warning: /home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/build/sonde-test-29186d9285cdc020/out/sonde-ffiU70Emz.c:5:5: warning: implicit declaration of function ‘HELLO_WORLD’ [-Wimplicit-function-declaration]
warning:     5 |     HELLO_WORLD();
warning:       |     ^~~~~~~~~~~
warning: /home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/build/sonde-test-29186d9285cdc020/out/sonde-ffiU70Emz.c: In function ‘hello_probe_you’:
warning: /home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/build/sonde-test-29186d9285cdc020/out/sonde-ffiU70Emz.c:9:5: warning: implicit declaration of function ‘HELLO_YOU’ [-Wimplicit-function-declaration]
warning:     9 |     HELLO_YOU(arg0, arg1);
warning:       |     ^~~~~~~~~
warning: /home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/build/sonde-test-29186d9285cdc020/out/sonde-ffiU70Emz.c: In function ‘hello_probe_me’:
warning: /home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/build/sonde-test-29186d9285cdc020/out/sonde-ffiU70Emz.c:13:5: warning: implicit declaration of function ‘HELLO_ME’ [-Wimplicit-function-declaration]
warning:    13 |     HELLO_ME();
warning:       |     ^~~~~~~~
warning: /home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/build/sonde-test-29186d9285cdc020/out/sonde-ffiU70Emz.c: In function ‘hello_probe_you_me’:
warning: /home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/build/sonde-test-29186d9285cdc020/out/sonde-ffiU70Emz.c:17:5: warning: implicit declaration of function ‘HELLO_YOU_ME’ [-Wimplicit-function-declaration]
warning:    17 |     HELLO_YOU_ME();
warning:       |     ^~~~~~~~~~~~
warning: /home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/build/sonde-test-29186d9285cdc020/out/sonde-ffiU70Emz.c: In function ‘salut_probe_le_monde’:
warning: /home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/build/sonde-test-29186d9285cdc020/out/sonde-ffiU70Emz.c:22:5: warning: implicit declaration of function ‘SALUT_LE_MONDE’ [-Wimplicit-function-declaration]
warning:    22 |     SALUT_LE_MONDE();
warning:       |     ^~~~~~~~~~~~~~
warning: /home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/build/sonde-test-29186d9285cdc020/out/sonde-ffiU70Emz.c: In function ‘salut_probe_toi’:
warning: /home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/build/sonde-test-29186d9285cdc020/out/sonde-ffiU70Emz.c:26:5: warning: implicit declaration of function ‘SALUT_TOI’ [-Wimplicit-function-declaration]
warning:    26 |     SALUT_TOI();
warning:       |     ^~~~~~~~~
warning: /home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/build/sonde-test-29186d9285cdc020/out/sonde-ffiU70Emz.c: In function ‘salut_probe_moi’:
warning: /home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/build/sonde-test-29186d9285cdc020/out/sonde-ffiU70Emz.c:30:5: warning: implicit declaration of function ‘SALUT_MOI’ [-Wimplicit-function-declaration]
warning:    30 |     SALUT_MOI();
warning:       |     ^~~~~~~~~
error: linking with `cc` failed: exit status: 1
  |
  = note: "cc" "-m64" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-Wl,--as-needed" "-L" "/home/heinz/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/deps/sonde_test-3dd6d5dc97a09a63.sonde_test.3x2z20gm-cgu.0.rcgu.o" "/home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/deps/sonde_test-3dd6d5dc97a09a63.sonde_test.3x2z20gm-cgu.1.rcgu.o" "/home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/deps/sonde_test-3dd6d5dc97a09a63.sonde_test.3x2z20gm-cgu.10.rcgu.o" "/home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/deps/sonde_test-3dd6d5dc97a09a63.sonde_test.3x2z20gm-cgu.11.rcgu.o" "/home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/deps/sonde_test-3dd6d5dc97a09a63.sonde_test.3x2z20gm-cgu.12.rcgu.o" "/home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/deps/sonde_test-3dd6d5dc97a09a63.sonde_test.3x2z20gm-cgu.13.rcgu.o" "/home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/deps/sonde_test-3dd6d5dc97a09a63.sonde_test.3x2z20gm-cgu.14.rcgu.o" "/home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/deps/sonde_test-3dd6d5dc97a09a63.sonde_test.3x2z20gm-cgu.15.rcgu.o" "/home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/deps/sonde_test-3dd6d5dc97a09a63.sonde_test.3x2z20gm-cgu.2.rcgu.o" "/home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/deps/sonde_test-3dd6d5dc97a09a63.sonde_test.3x2z20gm-cgu.3.rcgu.o" "/home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/deps/sonde_test-3dd6d5dc97a09a63.sonde_test.3x2z20gm-cgu.4.rcgu.o" "/home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/deps/sonde_test-3dd6d5dc97a09a63.sonde_test.3x2z20gm-cgu.5.rcgu.o" "/home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/deps/sonde_test-3dd6d5dc97a09a63.sonde_test.3x2z20gm-cgu.6.rcgu.o" "/home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/deps/sonde_test-3dd6d5dc97a09a63.sonde_test.3x2z20gm-cgu.7.rcgu.o" "/home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/deps/sonde_test-3dd6d5dc97a09a63.sonde_test.3x2z20gm-cgu.8.rcgu.o" "/home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/deps/sonde_test-3dd6d5dc97a09a63.sonde_test.3x2z20gm-cgu.9.rcgu.o" "-o" "/home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/deps/sonde_test-3dd6d5dc97a09a63" "/home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/deps/sonde_test-3dd6d5dc97a09a63.32b8j1duep7cebtu.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro" "-Wl,-znow" "-nodefaultlibs" "-L" "/home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/deps" "-L" "/home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/build/sonde-test-29186d9285cdc020/out" "-L" "/home/heinz/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "-Wl,--whole-archive" "-lsonde-ffi" "-Wl,--no-whole-archive" "-Wl,--start-group" "/home/heinz/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-b6b48477bfa8c673.rlib" "/home/heinz/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-f560ec02638f7ffe.rlib" "/home/heinz/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-9c8eadb7013c9e0b.rlib" "/home/heinz/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-8b0ec8dbdb85d0bf.rlib" "/home/heinz/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-ba5d5ee707c805d2.rlib" "/home/heinz/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-55166126dbdd5e46.rlib" "/home/heinz/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-c327b365eae3b2f3.rlib" "/home/heinz/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-416439b546a0d033.rlib" "/home/heinz/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-2581188d29552e15.rlib" "/home/heinz/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-da7b2635bfcce6ef.rlib" "/home/heinz/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-09200ed1945e7b2b.rlib" "/home/heinz/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-223ac369b29f5000.rlib" "/home/heinz/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-39562fe6600dd936.rlib" "/home/heinz/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-9b411bb7a19f81b3.rlib" "/home/heinz/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-64ea0581d80339f7.rlib" "/home/heinz/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-b2dbda88b377d685.rlib" "/home/heinz/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-2a8415a96ed1d7dc.rlib" "-Wl,--end-group" "/home/heinz/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-c4d9a5b072ee3191.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc"
  = note: /usr/bin/ld: /home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/build/sonde-test-29186d9285cdc020/out/libsonde-ffi.a(sonde-ffiU70Emz.o): in function `hello_probe_you':
          /home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/build/sonde-test-29186d9285cdc020/out/sonde-ffiU70Emz.c:9: undefined reference to `HELLO_YOU'
          collect2: error: ld returned 1 exit status
          

error: aborting due to previous error

The following warnings were emitted during compilation:

warning: /home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/build/sonde-test-29186d9285cdc020/out/sonde-ffiU70Emz.c: In function ‘hello_probe_world’:
warning: /home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/build/sonde-test-29186d9285cdc020/out/sonde-ffiU70Emz.c:5:5: warning: implicit declaration of function ‘HELLO_WORLD’ [-Wimplicit-function-declaration]
warning:     5 |     HELLO_WORLD();
warning:       |     ^~~~~~~~~~~
warning: /home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/build/sonde-test-29186d9285cdc020/out/sonde-ffiU70Emz.c: In function ‘hello_probe_you’:
warning: /home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/build/sonde-test-29186d9285cdc020/out/sonde-ffiU70Emz.c:9:5: warning: implicit declaration of function ‘HELLO_YOU’ [-Wimplicit-function-declaration]
warning:     9 |     HELLO_YOU(arg0, arg1);
warning:       |     ^~~~~~~~~
warning: /home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/build/sonde-test-29186d9285cdc020/out/sonde-ffiU70Emz.c: In function ‘hello_probe_me’:
warning: /home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/build/sonde-test-29186d9285cdc020/out/sonde-ffiU70Emz.c:13:5: warning: implicit declaration of function ‘HELLO_ME’ [-Wimplicit-function-declaration]
warning:    13 |     HELLO_ME();
warning:       |     ^~~~~~~~
warning: /home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/build/sonde-test-29186d9285cdc020/out/sonde-ffiU70Emz.c: In function ‘hello_probe_you_me’:
warning: /home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/build/sonde-test-29186d9285cdc020/out/sonde-ffiU70Emz.c:17:5: warning: implicit declaration of function ‘HELLO_YOU_ME’ [-Wimplicit-function-declaration]
warning:    17 |     HELLO_YOU_ME();
warning:       |     ^~~~~~~~~~~~
warning: /home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/build/sonde-test-29186d9285cdc020/out/sonde-ffiU70Emz.c: In function ‘salut_probe_le_monde’:
warning: /home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/build/sonde-test-29186d9285cdc020/out/sonde-ffiU70Emz.c:22:5: warning: implicit declaration of function ‘SALUT_LE_MONDE’ [-Wimplicit-function-declaration]
warning:    22 |     SALUT_LE_MONDE();
warning:       |     ^~~~~~~~~~~~~~
warning: /home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/build/sonde-test-29186d9285cdc020/out/sonde-ffiU70Emz.c: In function ‘salut_probe_toi’:
warning: /home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/build/sonde-test-29186d9285cdc020/out/sonde-ffiU70Emz.c:26:5: warning: implicit declaration of function ‘SALUT_TOI’ [-Wimplicit-function-declaration]
warning:    26 |     SALUT_TOI();
warning:       |     ^~~~~~~~~
warning: /home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/build/sonde-test-29186d9285cdc020/out/sonde-ffiU70Emz.c: In function ‘salut_probe_moi’:
warning: /home/heinz/Projects/Other/sonde-rs/sonde-test/target/debug/build/sonde-test-29186d9285cdc020/out/sonde-ffiU70Emz.c:30:5: warning: implicit declaration of function ‘SALUT_MOI’ [-Wimplicit-function-declaration]
warning:    30 |     SALUT_MOI();
warning:       |     ^~~~~~~~~

error: could not compile `sonde-test`
@viraptor
Copy link

Confirming with nightly-2021-06-17. The compilation also returned:

warning: /home/viraptor/Projects/radicle-bins/target/debug/build/librad-c673d1f2bda997f5/out/sonde-ffit23MWz.c: In function ‘radicleusdt_probe_have’:
warning: /home/viraptor/Projects/radicle-bins/target/debug/build/librad-c673d1f2bda997f5/out/sonde-ffit23MWz.c:5:5: warning: implicit declaration of function ‘RADICLEUSDT_HAVE’ [-Wimplicit-function-declaration]
warning:     5 |     RADICLEUSDT_HAVE(arg0, arg1);
warning:       |     ^~~~~~~~~~~~~~~~
warning: /home/viraptor/Projects/radicle-bins/target/debug/build/librad-c673d1f2bda997f5/out/sonde-ffit23MWz.c: In function ‘radicleusdt_probe_want’:
warning: /home/viraptor/Projects/radicle-bins/target/debug/build/librad-c673d1f2bda997f5/out/sonde-ffit23MWz.c:9:5: warning: implicit declaration of function ‘RADICLEUSDT_WANT’ [-Wimplicit-function-declaration]
warning:     9 |     RADICLEUSDT_WANT(arg0, arg1);
warning:       |     ^~~~~~~~~~~~~~~~

for the two probes I defined.

@viraptor
Copy link

Looking deeper into it with .keep_c_file(true).keep_h_file(true), it looks like the C file is generated fine with single-line probe functions, but the H file is empty.

@viraptor
Copy link

Turns out that sonde is trying to run dtrace -arch ..., but that option is not available on my system. (comes from systemtap-sdt-devel-4.5-1.fc34.x86_64)

@viraptor
Copy link

After disabling the arch option, I get missing semaphore references:

  = note: /usr/bin/ld: /home/viraptor/Projects/radicle-bins/target/debug/deps/liblibrad-f52937073f009397.rlib(sonde-ffirHuimV.o): in function `radicleusdt_probe_have':
          /home/viraptor/Projects/radicle-bins/target/debug/build/librad-a5f8d94bdfce4775/out/sonde-ffirHuimV.c:6: undefined reference to `have_semaphore'
          /usr/bin/ld: /home/viraptor/Projects/radicle-bins/target/debug/deps/liblibrad-f52937073f009397.rlib(sonde-ffirHuimV.o):(.note.stapsdt+0x24): undefined reference to `have_semaphore'
          /usr/bin/ld: /home/viraptor/Projects/radicle-bins/target/debug/deps/liblibrad-f52937073f009397.rlib(sonde-ffirHuimV.o):(.note.stapsdt+0x78): undefined reference to `want_semaphore'
          /usr/bin/ld: /home/viraptor/Projects/radicle-bins/target/debug/deps/liblibrad-f52937073f009397.rlib(sonde-ffirHuimV.o): in function `radicleusdt_probe_want':
          /home/viraptor/Projects/radicle-bins/target/debug/build/librad-a5f8d94bdfce4775/out/sonde-ffirHuimV.c:10: undefined reference to `want_semaphore'

@viraptor
Copy link

There are two solutions:

  • if you don't want semaphores for argument construction, you can add #include <sys/sdt.h> before the include for the header file
  • if you do want them, you need to also call dtrace -G ... and include the object file when compiling the library

This could be a builder option.

@viraptor viraptor linked a pull request Sep 3, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants