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

Compile bug: C++ One Definition Rule [-Wodr] violations in common/json.hpp #11876

Open
srcshelton opened this issue Feb 14, 2025 · 2 comments
Open

Comments

@srcshelton
Copy link

Git commit

llama.cpp bundled with ollama-0.5.11: https://github.com/ollama/ollama/tree/v0.5.11/llama/llama.cpp… which I think is 8962422 (from ollama/ollama@5e2653f)

Operating systems

Linux

GGML backends

CPU

Problem description & steps to reproduce

llama.cpp (as part of ollama) compiles successfully, but generates the following warnings with gcc-14.2:

* QA Notice: Package triggers severe warnings which indicate that it may exhibit random runtime failures.
 * ollama-0.5.11/llama/llama.cpp/common/json.hpp:19726:11: warning: type 'union json_value' violates the C++ One Definition Rule [-Wodr]
 * ollama-0.5.11/llama/llama.cpp/common/json.hpp:23492:12: warning: type 'struct data' violates the C++ One Definition Rule [-Wodr]
 * ollama-0.5.11/llama/llama.cpp/common/json.hpp:19400:7: warning: type 'struct basic_json' violates the C++ One Definition Rule [-Wodr]
 * ollama-0.5.11/llama/llama.cpp/common/json-schema-to-grammar.h:8:13: warning: 'json_schema_to_grammar' violates the C++ One Definition Rule [-Wodr]

First Bad Commit

No response

Compile command

ninja -j6 -l0

Relevant log output

* QA Notice: Package triggers severe warnings which indicate that it may exhibit random runtime failures.
 * ollama-0.5.11/llama/llama.cpp/common/json.hpp:19726:11: warning: type 'union json_value' violates the C++ One Definition Rule [-Wodr]
 * ollama-0.5.11/llama/llama.cpp/common/json.hpp:23492:12: warning: type 'struct data' violates the C++ One Definition Rule [-Wodr]
 * ollama-0.5.11/llama/llama.cpp/common/json.hpp:19400:7: warning: type 'struct basic_json' violates the C++ One Definition Rule [-Wodr]
 * ollama-0.5.11/llama/llama.cpp/common/json-schema-to-grammar.h:8:13: warning: 'json_schema_to_grammar' violates the C++ One Definition Rule [-Wodr]
@srcshelton
Copy link
Author

Origially ollama/ollama#9117, may relate to nlohmann/json#4116.

@srcshelton
Copy link
Author

More detailed build output:

# github.com/ollama/ollama
ollama-0.5.11/llama/llama.cpp/common/json.hpp:19726:11: warning: type 'union json_value' violates the C++ One Definition Rule [-Wodr]
19726 |     union json_value
      |           ^
llama/llama.cpp/common/json.hpp:19726:11: note: a different type is defined in another translation unit
19726 |     union json_value
      |           ^
ollama-0.5.11/llama/llama.cpp/common/json.hpp:19729:19: note: the first difference of corresponding definitions is field 'object'
19729 |         object_t* object;
      |                   ^
llama/llama.cpp/common/json.hpp:19729:19: note: a field of same name but different type is defined in another translation unit
19729 |         object_t* object;
      |                   ^
ollama-0.5.11/llama/llama.cpp/common/json.hpp:19726:11: note: type name 'nlohmann::json_abi_v3_11_3::ordered_map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, nlohmann::json_abi_v3_11_3::basic_json<nlohmann::json_abi_v3_11_3::ordered_map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> >, void>, std::less<void>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, nlohmann::json_abi_v3_11_3::basic_json<nlohmann::json_abi_v3_11_3::ordered_map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> >, void> > > >' should match type name 'nlohmann::json_abi_v3_11_3::ordered_map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, nlohmann::json_abi_v3_11_3::basic_json<nlohmann::json_abi_v3_11_3::ordered_map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> >, void>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, nlohmann::json_abi_v3_11_3::basic_json<nlohmann::json_abi_v3_11_3::ordered_map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> >, void> > > >'
19726 |     union json_value
      |           ^
ollama-0.5.11/llama/llama.cpp/common/json.hpp:23492:12: warning: type 'struct data' violates the C++ One Definition Rule [-Wodr]
23492 |     struct data
      |            ^
llama/llama.cpp/common/json.hpp:23492:12: note: a different type is defined in another translation unit
23492 |     struct data
      |            ^
ollama-0.5.11/llama/llama.cpp/common/json.hpp:23498:20: note: the first difference of corresponding definitions is field 'm_value'
23498 |         json_value m_value = {};
      |                    ^
llama/llama.cpp/common/json.hpp:23498:20: note: a field of same name but different type is defined in another translation unit
23498 |         json_value m_value = {};
      |                    ^
ollama-0.5.11/llama/llama.cpp/common/json.hpp:19726:11: note: type 'union json_value' itself violates the C++ One Definition Rule
19726 |     union json_value
      |           ^
llama/llama.cpp/common/json.hpp:19726:11: note: the incompatible type is defined here
19726 |     union json_value
      |           ^
ollama-0.5.11/llama/llama.cpp/common/json.hpp:19400:7: warning: type 'struct basic_json' violates the C++ One Definition Rule [-Wodr]
19400 | class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-special-member-functions)  
      |       ^
llama/llama.cpp/common/json.hpp:19400:7: note: a different type is defined in another translation unit
19400 | class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-special-member-functions)  
      |       ^
ollama-0.5.11/llama/llama.cpp/common/json.hpp:23523:10: note: the first difference of corresponding definitions is field 'm_data'
23523 |     data m_data = {};
      |          ^
llama/llama.cpp/common/json.hpp:23523:10: note: a field of same name but different type is defined in another translation unit
23523 |     data m_data = {};
      |          ^
ollama-0.5.11/llama/llama.cpp/common/json.hpp:23492:12: note: type 'struct data' itself violates the C++ One Definition Rule
23492 |     struct data
      |            ^
llama/llama.cpp/common/json.hpp:23492:12: note: the incompatible type is defined here
23492 |     struct data
      |            ^
ollama-0.5.11/llama/llama.cpp/common/json-schema-to-grammar.h:8:13: warning: 'json_schema_to_grammar' violates the C++ One Definition Rule [-Wodr]
    8 | std::string json_schema_to_grammar(const nlohmann::ordered_json& schema);
      |             ^
llama/llama.cpp/common/json-schema-to-grammar.cpp:1038:13: note: type mismatch in parameter 1
 1038 | std::string json_schema_to_grammar(const json & schema) {
      |             ^
llama/llama.cpp/common/json-schema-to-grammar.cpp:1038:13: note: 'json_schema_to_grammar' was previously declared here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant