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

Multiple Declaration Errors for namespace std in ARM #197

Open
FireBoyAJ24 opened this issue Sep 29, 2024 · 1 comment
Open

Multiple Declaration Errors for namespace std in ARM #197

FireBoyAJ24 opened this issue Sep 29, 2024 · 1 comment

Comments

@FireBoyAJ24
Copy link

FireBoyAJ24 commented Sep 29, 2024

Description

When building the OMPL make update_bindings on ARM, we get an error: pygccxml.declarations.runtime_errors.multiple_declarations_found_t: Multiple declarations have been found. Matcher: [(decl type==namespace_t) and (name==std)]. Context of this issue comes from ompl/ompl#1116.

Is it possible that the standard C++ library headers are treated differently (unexpectedly) in ARM compared to X86_64 in PygccXML?

I placed this issue in pygccxml as the error comes from this package compared to py++ and OMPL.

Expected Behavior

In X86_64, we are able to make the Python bindings with no errors. However, in ARM, we get the error stated in the description.

Example Code to Test the Error

from pygccxml import utils
from pygccxml import declarations
from pygccxml import parser
from pyplusplus import module_builder, messages
from pyplusplus.module_builder import call_policies

# Find the location of the xml generator (castxml or gccxml)
generator_path, generator_name = utils.find_xml_generator()

# Configure the xml generator
xml_generator_config = parser.xml_generator_configuration_t(
    xml_generator_path=generator_path,
    xml_generator=generator_name)

print(generator_name, generator_path)

name = "util"

mb = module_builder.module_builder_t(
            files=['util.h'],
            # cache is not used with compilation_mode = parser.COMPILATION_MODE.ALL_AT_ONCE
            # cache = '/workspaces/ompl_workspace/build/Release/pyplusplus_'+name+'.cache',
            xml_generator_config=xml_generator_config,
            compilation_mode=parser.COMPILATION_MODE.ALL_AT_ONCE,
            indexing_suite_version=2)
mb.classes().always_expose_using_scope = True
std_ns_decls = mb.namespace("std")

declarations.print_declarations(std_ns_decls)

Example util.h file:

// Copyright 2004-2006 Roman Yakovenko.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#ifndef __hello_world_hpp__
#define __hello_world_hpp__

#include <string>

//I want to rename color to Color
enum color{ red, green, blue };

struct genealogical_tree{/*...*/};

struct animal{

    explicit animal( const std::string& name="" )
    : m_name( name )
    {}

    //I need to set call policies to the function
    genealogical_tree& genealogical_tree_ref()
    { return m_genealogical_tree; }

    std::string name() const
    { return m_name; }

private:
    std::string m_name;
    genealogical_tree m_genealogical_tree;
};

//I want to exclude next declarations:
struct impl1{};
struct impl2{};

inline int* get_int_ptr(){ return 0;}
inline int* get_int_ptr(int){ return 0;}
inline int* get_int_ptr(double){ return 0;}

#endif//__hello_world_hpp__

Error:

Traceback (most recent call last):
  File "/workspaces/ompl_workspace/pyplusplus_test/generate_bindings.py", line 28, in <module>
    std_ns_decls = mb.namespace("std")
  File "/usr/local/lib/python3.10/dist-packages/pyplusplus/module_builder/module_builder.py", line 265, in namespace
    return self.global_ns.namespace( name=name
  File "/usr/local/lib/python3.10/dist-packages/pygccxml/declarations/namespace.py", line 117, in namespace
    self._find_single(
  File "/usr/local/lib/python3.10/dist-packages/pygccxml/declarations/scopedef.py", line 464, in _find_single
    found = matcher.get_single(decl_matcher, decls, False)
  File "/usr/local/lib/python3.10/dist-packages/pygccxml/declarations/scopedef.py", line 92, in get_single
    raise runtime_errors.multiple_declarations_found_t(decl_matcher)
pygccxml.declarations.runtime_errors.multiple_declarations_found_t: Multiple declarations have been found. Matcher: [(decl type==namespace_t) and (name==std)]

Tried Potential Solutions

  • We tried using different compilation modes (FILE_BY_FILE) instead of ALL_AT_ONCE and was able to build the util module but got the same multiple declaration error in other packages (base, geometric, etc).
  • We tried cache as well and got the same multiple declaration error.
  • We tried CastXML SuperBuild versions 0.6.5, 0.5.0 and 0.4.8. We still got the same multiple declaration error.
  • We tried 2.5.0 and 2.2.1 pygccxml and found the same error.
  • The error was found in Ubuntu Jammy.

Resources

@iMichka
Copy link
Contributor

iMichka commented Oct 13, 2024

Hey. Thanks for letting me know.

I think the best thing to do would be to have a minimal c/c++ code example to be able to reproduce this outside of the OMPL build context. So I can try to write a test case for it and debug it.

I do not have an ARM machine right now (might buy a ARM Mac next year though).
I need to check if I can set ARM CI on Github, I think they announced ARM machines lately.

The bug might also be in CastXML.
Another solution would be to provide the xml files that have been generated, because I think I can also explore their content and see what is going on.

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