llama.cpp
llama.cpp copied to clipboard
Compile bug: C++ One Definition Rule [-Wodr] violations in common/json.hpp
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 https://github.com/ollama/ollama/commit/5e2653f9fe454e948a8d48e3c15c21830c1ac26b)
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]
Origially https://github.com/ollama/ollama/issues/9117, may relate to https://github.com/nlohmann/json/issues/4116.
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
This issue was closed because it has been inactive for 14 days since being marked as stale.