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

Missing iterator definition #1334

Open
xrl opened this issue Oct 3, 2023 · 5 comments
Open

Missing iterator definition #1334

xrl opened this issue Oct 3, 2023 · 5 comments
Labels
bug Something isn't working need-test-case Needs a test case

Comments

@xrl
Copy link

xrl commented Oct 3, 2023

Describe the bug

My build.rs script fails because the iterator type isn't available. Reproduced on both Mac OS X and Ubuntu Linux.

To Reproduce

You'll probably be curious what the inputs to this build are and what the auto-generating bindings look like

Expected behavior

I would have expected the bindings to fail because of something I defined but it looks like autocxx is pulling in funny code from the headers?

Additional context

I have build bindings with cxx-rs successfully here: https://github.com/rdkit-rs/rdkit-sys

And the errors from the repro are a little different on my OS X setup but similar in spirit: https://gist.github.com/xrl/91d94c3bef8b04a64985d4444c8604f2

namely:

warning: In file included from /Users/xlange/code/assaydepot/rdkit-autocxx-repro/target/debug/build/rdkit-autocxx-repro-af359ecff0c3ad28/out/autocxx-build-dir/cxx/gen0.cxx:3:
warning: /Users/xlange/code/assaydepot/rdkit-autocxx-repro/target/debug/build/rdkit-autocxx-repro-af359ecff0c3ad28/out/autocxx-build-dir/include/autocxxgen_ffi.h:37:31: error: use of undeclared identifier 'iterator'; did you mean 'boost_swap_impl::iterator'?
warning: typedef std::reverse_iterator<iterator> std_reverse_iterator_iterator_AutocxxConcrete;
warning:                               ^~~~~~~~
warning:                               boost_swap_impl::iterator
warning: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__iterator/iterator.h:24:57: note: 'boost_swap_impl::iterator' declared here
warning: struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 iterator
warning:                                                         ^
warning: In file included from /Users/xlange/code/assaydepot/rdkit-autocxx-repro/target/debug/build/rdkit-autocxx-repro-af359ecff0c3ad28/out/autocxx-build-dir/cxx/gen0.cxx:3:

@adetaylor
Copy link
Collaborator

Thanks - could you try to come up with a minimal test case using these instructions?

@xrl
Copy link
Author

xrl commented Oct 3, 2023

It looks like I need to pass in the right version of c++ to get this compiling but I'm not sure how to pass that in:

autocxx-reduce --clang-arg='-std=c++17' --problem "use of undeclared identifier 'iterator'" file -d "safety!(unsafe_ffi)" -d 'generate_ns("RDKit")' -I /opt/homebrew/include -I /opt/homebrew/include/rdkit --header 'GraphMol/ROMol.h' > creduce-stream.txt

Error:   × the include_cpp! macro couldn't be expanded into Rust bindings to C++:
  │ Bindgen was unable to generate the initial .rs bindings for this file.
  │ This may indicate a parsing problem with the C++ headers.

In file included from /var/folders/mc/3pj1vp8s239fn610rbv56f440000gp/T/.tmpX47vgY/listing.h:1:
In file included from /opt/homebrew/include/rdkit/GraphMol/ROMol.h:39:
In file included from /opt/homebrew/include/rdkit/RDGeneral/types.h:28:
/opt/homebrew/include/rdkit/RDGeneral/Dict.h:261:25: error: no template named 'is_same_v' in namespace 'std'; did you mean 'is_same'?
    static_assert(!std::is_same_v<T, std::string_view>,
                   ~~~~~^~~~~~~~~
                        is_same


I don't see this error when I set the C++ version in the autocxx builder like this:

    let mut builder = autocxx_build::Builder::new("src/main.rs", &include_paths)
        .extra_clang_args(&["-std=c++17"])
        .build()
        .unwrap();

Thoughts on how to forward the c++20 version in to the autocxx-reduce tooling?

@xrl
Copy link
Author

xrl commented Oct 16, 2023

@adetaylor I would appreciate some guidance. or perhaps there's a good spot to reach out to the community?

@adetaylor
Copy link
Collaborator

Yeah, sorry for the lack of response. I don't know what's going wrong with autocxx-reduce absorbing that clang arg.

autocxx-reduce causes problems of one kind or another for about 50% of the people who try to use it. It usually requires a little massaging itself to behave, so I'm not surprised you've encountered problems.

Unfortunately though I will need a minimized version of the C++ headers to be able to investigate this problem. I know from bitter experience that it takes multiple hours to reproduce problems which are not minimized, and I don't have hours spare at the moment - possibly after the holiday season.

I'd suggest your best bet is to struggle through getting autocxx-reduce to work (on Linux). Here's where it ought to be doing something with those arguments.

@xrl
Copy link
Author

xrl commented Oct 16, 2023

OK, I will work on a linux environment and rule out the os x flavored stuff. Thanks for the tip 👌

@adetaylor adetaylor added bug Something isn't working need-test-case Needs a test case labels Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working need-test-case Needs a test case
Projects
None yet
Development

No branches or pull requests

2 participants