autocxx
                                
                                 autocxx copied to clipboard
                                
                                    autocxx copied to clipboard
                            
                            
                            
                        Overrides throws candidate expects n arguments, n provided
Using a struct with overrides seems to fail the build, i'm trying to use libtorrent but it throws a few hundred candidate expects x arguments, x provided errors and fails the build
use autocxx::prelude::*;
use std::ffi::CStr;
include_cpp! {
    #include "libtorrent/version.hpp"
    #include "libtorrent/session.hpp"
    
    safety!(unsafe_ffi)
    generate!("libtorrent::version")
    generate!("libtorrent::session")
}
imported code: https://github.com/arvidn/libtorrent/blob/e9bbf16bdd899f42aef0f0c2b1f214de2c15ac92/include/libtorrent/session.hpp#L160-L190
		explicit session(session_params const& params);
		explicit session(session_params&& params);
		session(session_params const& params, session_flags_t flags);
		session(session_params&& params, session_flags_t flags);
		session();
		session(session_params&& params, io_context& ios);
		session(session_params const& params, io_context& ios);
		session(session_params&& params, io_context& ios, session_flags_t);
		session(session_params const& params, io_context& ios, session_flags_t);
		session(session&&);
		session& operator=(session&&) &;
		session(session const&) = delete;
		session& operator=(session const&) = delete;
ouput:
[...] (a few hundreds/thousands similar warnings)
  cargo:warning=  181 |   session(session_params&& params, io_context& ios, session_flags_t);
  cargo:warning=      |                                                     ^~~~~~~~~~~~~~~
  cargo:warning=/home/dev/fkn-proxy/libtorrent/session.hpp:180:3: note: candidate: 'libtorrent::session::session(const libtorrent::session_params&, boost::asio::io_context&)'
  cargo:warning=  180 |   session(session_params const& params, io_context& ios);
  cargo:warning=      |   ^~~~~~~
  cargo:warning=/home/dev/fkn-proxy/libtorrent/session.hpp:180:3: note:   candidate expects 2 arguments, 3 provided
  cargo:warning=/home/dev/fkn-proxy/libtorrent/session.hpp:179:3: note: candidate: 'libtorrent::session::session(libtorrent::session_params&&, boost::asio::io_context&)'
  cargo:warning=  179 |   session(session_params&& params, io_context& ios);
  cargo:warning=      |   ^~~~~~~
  cargo:warning=/home/dev/fkn-proxy/libtorrent/session.hpp:179:3: note:   candidate expects 2 arguments, 3 provided
  cargo:warning=/home/dev/fkn-proxy/libtorrent/session.hpp:164:3: note: candidate: 'libtorrent::session::session()'
  cargo:warning=  164 |   session();
  cargo:warning=      |   ^~~~~~~
  cargo:warning=/home/dev/fkn-proxy/libtorrent/session.hpp:164:3: note:   candidate expects 0 arguments, 3 provided
  cargo:warning=/home/dev/fkn-proxy/libtorrent/session.hpp:163:3: note: candidate: 'libtorrent::session::session(libtorrent::session_params&&, libtorrent::session_handle::session_flags_t)'
  cargo:warning=  163 |   session(session_params&& params, session_flags_t flags);
  cargo:warning=      |   ^~~~~~~
  cargo:warning=/home/dev/fkn-proxy/libtorrent/session.hpp:163:3: note:   candidate expects 2 arguments, 3 provided
  cargo:warning=/home/dev/fkn-proxy/libtorrent/session.hpp:162:3: note: candidate: 'libtorrent::session::session(const libtorrent::session_params&, libtorrent::session_handle::session_flags_t)'
  cargo:warning=  162 |   session(session_params const& params, session_flags_t flags);
  cargo:warning=      |   ^~~~~~~
  cargo:warning=/home/dev/fkn-proxy/libtorrent/session.hpp:162:3: note:   candidate expects 2 arguments, 3 provided
  cargo:warning=/home/dev/fkn-proxy/libtorrent/session.hpp:161:12: note: candidate: 'libtorrent::session::session(libtorrent::session_params&&)'
  cargo:warning=  161 |   explicit session(session_params&& params);
  cargo:warning=      |            ^~~~~~~
  cargo:warning=/home/dev/fkn-proxy/libtorrent/session.hpp:161:12: note:   candidate expects 1 argument, 3 provided
  cargo:warning=/home/dev/fkn-proxy/libtorrent/session.hpp:160:12: note: candidate: 'libtorrent::session::session(const libtorrent::session_params&)'
  cargo:warning=  160 |   explicit session(session_params const& params);
  cargo:warning=      |            ^~~~~~~
  cargo:warning=/home/dev/fkn-proxy/libtorrent/session.hpp:160:12: note:   candidate expects 1 argument, 3 provided
  exit status: 1
Thanks. That shouldn't fail in the way you're experiencing.
I wonder if you could kindly follow the instructions here to provide a minimized test case in this bug? At the very least, a repro.json would be very helpful. In my experience 90% of the work is reproducing somebody's situation, and only 10% is actually fixing the bug, so if you can make it easy for me to reproduce it that would be much appreciated.
I'm really unsure how to reproduce the issue within the minimized tests cases(Being a beginner in both rust and C++ certainely doesn't help me). Libtorrent is probably doing something weird that's causing issues with autocxx but i couldn't find what it is.
What i could do though if that's fine with you, is make a minimalist docker file that's able to reproduce the issues.
What it would contain is just the basic steps to build libtorrent and a small file with rust's include_cpp and generate! calls that generate the errors.
Please just build your project like this: AUTOCXX_REPRO_CASE=repro.json cargo build and then attach repro.json here. That might be enough.
Oh, sorry for that, i kind of got hung up on the first methods of reporting. Here's the repro.json
Thanks, but that doesn't seem correct. It appears to have some generate_pod! directives which are causing a different problem. I need a repro.json from a build which reproduces the candidate expects x arguments error you have reported.
I'm not sure what is going wrong, the repro.json i sent is the one that outputs all of the candidate expects x arguments, here's some of the ones i got from building it with the repro
  cargo:warning=/home/dev/fkn-proxy/libtorrent/session.hpp:163:3: note:   candidate expects 2 arguments, 3 provided
  cargo:warning=/home/dev/fkn-proxy/libtorrent/session.hpp:162:3: note: candidate: 'libtorrent::session::session(const libtorrent::session_params&, libtorrent::session_handle::session_flags_t)'
  cargo:warning=  162 |   session(session_params const& params, session_flags_t flags);
  cargo:warning=      |   ^~~~~~~
  cargo:warning=/home/dev/fkn-proxy/libtorrent/session.hpp:162:3: note:   candidate expects 2 arguments, 3 provided
  cargo:warning=/home/dev/fkn-proxy/libtorrent/session.hpp:161:12: note: candidate: 'libtorrent::session::session(libtorrent::session_params&&)'
  cargo:warning=  161 |   explicit session(session_params&& params);
  cargo:warning=      |            ^~~~~~~
  cargo:warning=/home/dev/fkn-proxy/libtorrent/session.hpp:161:12: note:   candidate expects 1 argument, 3 provided
  cargo:warning=/home/dev/fkn-proxy/libtorrent/session.hpp:160:12: note: candidate: 'libtorrent::session::session(const libtorrent::session_params&)'
  cargo:warning=  160 |   explicit session(session_params const& params);
  cargo:warning=      |            ^~~~~~~
  cargo:warning=/home/dev/fkn-proxy/libtorrent/session.hpp:160:12: note:   candidate expects 1 argument, 3 provided
  exit status: 1
  --- stderr
  /tmp/.tmpg6fyYt:53:9: warning: #pragma once in main file [-Wpragma-once-outside-header]
  #pragma once
          ^
  1 warning generated.
  error occurred: Command "c++" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-I" "/usr/local/include" "-I" "/usr/include" "-I" "/home/dev/fkn-proxy/target/debug/build/rust-http-proxy-libtorrent-87ef3f569c1d3085/out/autocxx-build-dir/include" "-I" "/usr/local/include" "-I" "/usr/include" "-I" "/home/dev/fkn-proxy" "-I" "/home/dev/fkn-proxy/target/debug/build/rust-http-proxy-libtorrent-87ef3f569c1d3085/out" "-Wall" "-Wextra" "-std=c++14" "-o" "/home/dev/fkn-proxy/target/debug/build/rust-http-proxy-libtorrent-87ef3f569c1d3085/out/autocxx-build-dir/cxx/gen0.o" "-c" "/home/dev/fkn-proxy/target/debug/build/rust-http-proxy-libtorrent-87ef3f569c1d3085/out/autocxx-build-dir/cxx/gen0.cxx" with args "c++" did not execute successfully (status code exit status: 1).
and here's my rust code
use autocxx::prelude::*;
include_cpp! {
    #include "libtorrent/session.hpp"
    safety!(unsafe_ffi)
    generate!("libtorrent::session")
}
fn main() {
}
Is there something i could do to give you a better repro.json file?
Aha! I have a theory. There was briefly a bug where autocxx made a mistake with the repro.json file. That's probably what happened. In that case I should be able to fix the file and try using it again tomorrow. No need for you to do anything else right now.
OK, yes, your repro.json was fine all along, sorry for saying it wasn't right :) I am now working on reducing it to a minimal test case. This is completely automatic but takes a long time - there's quite a lot of code in this repro.json so it will take at least a few days.
Here's the results of the minimization. I'm not 100% sure this makes sense, I'll check it out later.
namespace std {
inline namespace a {}
} // namespace std
namespace libtorrent {
char version;
}
namespace std {
namespace a {
template <typename b, typename = b, typename = b> class c;
}
typedef c<char> string;
namespace a {
template <typename, typename, typename> class c { c(); };
} // namespace a
} // namespace std
namespace libtorrent {
struct session;
}
namespace rust {
namespace {
class Str {};
} // namespace
} // namespace rust
Annoyingly it seems I must have messed up the minimization. I am starting again. Gah! Another week to wait...
It looks like this library seems to show up multiple bugs in autocxx's codegen, so I anticipate that there may be several cycles here before this works.
Sorry for the lack of progress here - this seemed to result in a test case which passed. I think I need to restart the minimization from scratch once again and hope I can reproduce the actual failure that you were encountering.