Skip to content

opencv-rust breaks profiling scenarios #348

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

Closed
montekki opened this issue Jun 28, 2022 · 3 comments
Closed

opencv-rust breaks profiling scenarios #348

montekki opened this issue Jun 28, 2022 · 3 comments

Comments

@montekki
Copy link

Before reporting an issue please first check the
troubleshooting guide. If
the issue you're encountering is not solved thereby please state the following in your bugreport:

  1. Operating system: ubuntu 21.10
  2. The way you installed OpenCV: manual compilation
  3. OpenCV version: from ubuntu packages:
    Package: libopencv-core4.5
    Version: 4.5.3+dfsg-1ubuntu1
    New: yes
  4. rustc version (rustc --version): rustc 1.64.0-nightly (2f3ddd9f5 2022-06-27)

Trying to run the standard grcov workflow seems broken due to some dead code not being eliminated:

env CARGO_INCREMENTAL=0 RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"  RUSTDOCFLAGS="-Cpanic=abort" cargo test --all-features --no-fail-fast
 = note: /usr/bin/ld: /tmp/opencv-rust/target/debug/deps/marshalling-616d85a659d99857.11xbdp47wnty2i45.rcgu.o: in function `opencv::opencv::hub::imgproc::bounding_rect':
          /tmp/opencv-rust/src/opencv/hub/imgproc.rs:2746: undefined reference to `cv_boundingRect_const__InputArrayR'
          /usr/bin/ld: /tmp/opencv-rust/target/debug/deps/marshalling-616d85a659d99857.11xbdp47wnty2i45.rcgu.o: in function `opencv::opencv::hub::imgproc::min_area_rect':
          /tmp/opencv-rust/src/opencv/hub/imgproc.rs:5790: undefined reference to `cv_minAreaRect_const__InputArrayR'
          /usr/bin/ld: /tmp/opencv-rust/target/debug/deps/marshalling-616d85a659d99857.11xbdp47wnty2i45.rcgu.o: in function `opencv::opencv::hub::imgproc::get_structuring_element':
          /tmp/opencv-rust/src/opencv/hub/imgproc.rs:5132: undefined reference to `cv_getStructuringElement_int_Size_Point'
          /usr/bin/ld: /tmp/opencv-rust/target/debug/deps/marshalling-616d85a659d99857.1wqrjlo7a4mr3vpi.rcgu.o: in function `opencv::opencv::hub::highgui::named_window':
          /tmp/opencv-rust/src/opencv/hub/highgui.rs:853: undefined reference to `cv_namedWindow_const_StringR_int'
          /usr/bin/ld: /tmp/opencv-rust/target/debug/deps/marshalling-616d85a659d99857.1wqrjlo7a4mr3vpi.rcgu.o: in function `opencv::opencv::hub::highgui::create_trackbar':
          /tmp/opencv-rust/src/opencv/hub/highgui.rs:524: undefined reference to `cv_createTrackbar_const_StringR_const_StringR_intX_int_TrackbarCallback_voidX'
          /usr/bin/ld: /tmp/opencv-rust/target/debug/deps/marshalling-616d85a659d99857.1wqrjlo7a4mr3vpi.rcgu.o: in function `opencv::opencv::hub::highgui::set_trackbar_pos':
          /tmp/opencv-rust/src/opencv/hub/highgui.rs:1207: undefined reference to `cv_setTrackbarPos_const_StringR_const_StringR_int'
          /usr/bin/ld: /tmp/opencv-rust/target/debug/deps/marshalling-616d85a659d99857.1wtqmdt5zd0woqn6.rcgu.o: in function `opencv::opencv::hub::aruco::DetectorParameters::create':
          /tmp/opencv-rust/src/opencv/hub/aruco.rs:1710: undefined reference to `cv_aruco_DetectorParameters_create'
          /usr/bin/ld: /tmp/opencv-rust/target/debug/deps/marshalling-616d85a659d99857.1wtqmdt5zd0woqn6.rcgu.o: in function `opencv::opencv::hub::aruco::DetectorParameters::default':
          /tmp/opencv-rust/src/opencv/hub/aruco.rs:1700: undefined reference to `cv_aruco_DetectorParameters_DetectorParameters'
          /usr/bin/ld: /tmp/opencv-rust/target/debug/deps/marshalling-616d85a659d99857.3nkvkx3dpia7qndu.rcgu.o: in function `opencv::opencv::hub::core::FileStorage::new':
          /tmp/opencv-rust/src/opencv/hub/core.rs:10285: undefined reference to `cv_FileStorage_FileStorage_const_StringR_int_const_StringR'
          /usr/bin/ld: /tmp/opencv-rust/target/debug/deps/marshalling-616d85a659d99857.3nkvkx3dpia7qndu.rcgu.o: in function `opencv::opencv::hub::core::_InputArray::from_mat':
          /tmp/opencv-rust/src/opencv/hub/core.rs:20484: undefined reference to `cv__InputArray__InputArray_const_MatR'
          /usr/bin/ld: /tmp/opencv-rust/target/debug/deps/marshalling-616d85a659d99857.3nkvkx3dpia7qndu.rcgu.o: in function `opencv::opencv::hub::core::use_optimized':
          /tmp/opencv-rust/src/opencv/hub/core.rs:7442: undefined reference to `cv_useOptimized'
          /usr/bin/ld: /tmp/opencv-rust/target/debug/deps/marshalling-616d85a659d99857.3nkvkx3dpia7qndu.rcgu.o: in function `opencv::opencv::hub::core::get_tick_count':
          /tmp/opencv-rust/src/opencv/hub/core.rs:3893: undefined reference to `cv_getTickCount'
          /usr/bin/ld: /tmp/opencv-rust/target/debug/deps/marshalling-616d85a659d99857.3nkvkx3dpia7qndu.rcgu.o: in function `opencv::opencv::hub::core::type_to_string':
          /tmp/opencv-rust/src/opencv/hub/core.rs:7419: undefined reference to `cv_typeToString_int'
          /usr/bin/ld: /tmp/opencv-rust/target/debug/deps/marshalling-616d85a659d99857.3nkvkx3dpia7qndu.rcgu.o: in function `opencv::opencv::hub::core::set_use_optimized':
          /tmp/opencv-rust/src/opencv/hub/core.rs:6945: undefined reference to `cv_setUseOptimized_bool'
          /usr/bin/ld: /tmp/opencv-rust/target/debug/deps/marshalling-616d85a659d99857.3nkvkx3dpia7qndu.rcgu.o: in function `opencv::opencv::hub::core::get_cpu_tick_count':
          /tmp/opencv-rust/src/opencv/hub/core.rs:3755: undefined reference to `cv_getCPUTickCount'
          /usr/bin/ld: /tmp/opencv-rust/target/debug/deps/marshalling-616d85a659d99857.3nkvkx3dpia7qndu.rcgu.o: in function `opencv::opencv::hub::core::get_number_of_cpus':
          /tmp/opencv-rust/src/opencv/hub/core.rs:3821: undefined reference to `cv_getNumberOfCPUs'
          /usr/bin/ld: /tmp/opencv-rust/target/debug/deps/marshalling-616d85a659d99857.3nkvkx3dpia7qndu.rcgu.o: in function `opencv::opencv::hub::core::get_tick_frequency':
          /tmp/opencv-rust/src/opencv/hub/core.rs:3913: undefined reference to `cv_getTickFrequency'

So in case the crate has opencv-rust as a dependency it cannot be profiled atm

@twistedfall
Copy link
Owner

That's a lot of undefined references even to the basic things, are the opencv so's getting linked at all? I'm not really familiar with this profiling workflow, can you please provide the instructions to reproduce the issue?

@montekki
Copy link
Author

montekki commented Jun 28, 2022

I just run this in the repo (has to be nightly rustc):

CARGO_INCREMENTAL=0 RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"  RUSTDOCFLAGS="-Cpanic=abort" cargo test --all-features --no-fail-fast

@twistedfall
Copy link
Owner

From my testing it looks like the particular culprit is -Clink-dead-code, not the -Zprofile by itself and there is an open bugreport regarding very similar issue: rust-lang/rust#64685 Looks like you would need to wait until this is fixed or adjust the pipeline to not include the -Clink-dead-code.

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

No branches or pull requests

2 participants