-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
ROOT doesn't compile with new nlohmann-json version 3.11.0 #11130
Comments
Thanks, I'll try right away. |
Almost, now I have a different problem having to do with json:
Any remedy for that? |
Ah, I see that error too now, just needed to enable ROOT 7 in the cmake config. So the issue is related to the latest nlohmann json release, and comes from these two PRs:
This is unfortunate, and we can't just update the forward declarations because they will change with each nlohmann json version now. I assigned this issue to @Axel-Naumann, because probably he remembers best why the manual forward declaration was introduced. Optimally, we'll find a solution where the official |
Also marking this as critical, because we don't want to make any new release with broken compilation I guess |
I not yet test latest |
Main problem is cling. If Official |
I updated the issue description to talk about |
llvm13 branch works with plain |
Ok, then I still don't understand the issue. Yesterday I understood that it's not related to LLVM, but that ROOT's forward declaration is simply "wrong" for newer versions of |
Original issue related to the fact, that each new version of https://github.com/root-project/root/blob/master/graf3d/eve7/inc/ROOT/REveElement.hxx#L24-L37 Without llvm13 one cannot directly include |
My understanding is the following, please correct me: As soon as we include diff --git a/graf3d/eve/inc/TEveCalo.h b/graf3d/eve/inc/TEveCalo.h
index 9be7925a6b..3ca258105f 100644
--- a/graf3d/eve/inc/TEveCalo.h
+++ b/graf3d/eve/inc/TEveCalo.h
@@ -21,6 +21,8 @@
#include "TEveCaloData.h"
#include <vector>
+#include <nlohmann/json.hpp>
+
class TClass;
class TEveRGBAPalette;
diff --git a/graf3d/eve7/inc/ROOT/REveElement.hxx b/graf3d/eve7/inc/ROOT/REveElement.hxx
index 2a127888a2..fb237fdfb6 100644
--- a/graf3d/eve7/inc/ROOT/REveElement.hxx
+++ b/graf3d/eve7/inc/ROOT/REveElement.hxx
@@ -16,26 +16,13 @@
#include <ROOT/REveVector.hxx>
#include <ROOT/REveProjectionBases.hxx>
+#include <nlohmann/json.hpp>
+
#include <map>
#include <memory>
class TGeoMatrix;
-namespace nlohmann {
-template<typename T, typename SFINAE>
-struct adl_serializer;
-
-template <template <typename U, typename V, typename... Args> class ObjectType,
- template <typename U, typename... Args> class ArrayType, class StringType, class BooleanType,
- class NumberIntegerType, class NumberUnsignedType, class NumberFloatType,
- template <typename U> class AllocatorType, template <typename T, typename SFINAE = void> class JSONSerializer,
- class BinaryType>
-class basic_json;
-
-using json = basic_json<std::map, std::vector, std::string, bool, std::int64_t, std::uint64_t, double, std::allocator,
- adl_serializer, std::vector<std::uint8_t>>;
-} // namespace nlohmann
-
namespace ROOT {
namespace Experimental {
we get errors because the symbols are provided by two modules. The only way out would be to have a decoupled json module, but that is bad for other reasons.
Not sure what's supposed to change with llvm13, but the diff I posted above fails with identical error message. And in my opinion, rightfully so. |
Since nlohmann/json#3590, the basic_json class and the json using-declaration are located in a "versioned, ABI-tagged inline namespace". This makes it impossible to forward declare the type in REveElement.hxx. Instead introduce a new struct REveJsonWrapper that just wraps a json object (after including the full nlohmann/json.hpp). As the struct is under our control, we can easily forward declare the type and use it for method arguments. Fixes root-project#11130
This should be tested - I compile llvm13 branch, replace forward declaration in eve7 and add TJSONFile with nlohmann/json in header. It works, but makes lot of warnings. Why one cannot include same header file from different modules? |
Indeed, placing |
Not really. One can generate dictionary and compile code. |
Now that we have a module, this should work. Fixes root-project#11130
@kgizdov I suppose you're asking for the Arch Linux package in particular? (thanks btw, I'm a user myself) As the diff --git a/graf3d/eve7/inc/ROOT/REveElement.hxx b/graf3d/eve7/inc/ROOT/REveElement.hxx
index 2a127888a2..9deb3af147 100644
--- a/graf3d/eve7/inc/ROOT/REveElement.hxx
+++ b/graf3d/eve7/inc/ROOT/REveElement.hxx
@@ -16,26 +16,13 @@
#include <ROOT/REveVector.hxx>
#include <ROOT/REveProjectionBases.hxx>
+#include <nlohmann/json_fwd.hpp>
+
#include <map>
#include <memory>
class TGeoMatrix;
-namespace nlohmann {
-template<typename T, typename SFINAE>
-struct adl_serializer;
-
-template <template <typename U, typename V, typename... Args> class ObjectType,
- template <typename U, typename... Args> class ArrayType, class StringType, class BooleanType,
- class NumberIntegerType, class NumberUnsignedType, class NumberFloatType,
- template <typename U> class AllocatorType, template <typename T, typename SFINAE = void> class JSONSerializer,
- class BinaryType>
-class basic_json;
-
-using json = basic_json<std::map, std::vector, std::string, bool, std::int64_t, std::uint64_t, double, std::allocator,
- adl_serializer, std::vector<std::uint8_t>>;
-} // namespace nlohmann
-
namespace ROOT {
namespace Experimental {
(tested on |
uh, @Axel-Naumann @linev since nlohmann/json#3679 (included in 3.11.2), |
@hahnjo CMake can natively check if a specific bit of code compiles - I think if you have a check on the forward declaration snippet and flip a flag based on successful compilation or not, it would be better and will not suffer unsupported versions, no? |
@kgizdov the problem is the two cases are non-exhaustive: For versions before 3.11.0, our own forward declaration will always work. Starting with 3.11.2, |
Another "simple" approach to compile ROOT is specify |
@hahnjo, your CMake test will either compile or not. It can't both compile and not compile at the same time. If including the forward declaration in a CMake test compiles, you set a variable that enables it in the code; otherwise, the forward declaration is switched off in the code. What am I missing? |
Version 3.11 of nlohmann/json introduced "versioned, ABI-tagged inline namespace"s, which breaks our forward declaration. Fortunately, we can assume the json_fwd.hpp header to be present starting from that same version because the JSON_MultipleHeaders option now defaults to ON and even if not, json_fwd.hpp is installed since patch version 3.11.2. For earlier versions, both methods work but json_fwd.hpp isn't guaranteed to be installed. Still use it if available. Fixes root-project#11130
Third time's a charm: #11205
The case where the forward declaration doesn't work and the |
well, that's easily fixed as well: try_compile(FWD_DECLARE MYBINDIR forward_declare.cpp)
try_compile(FWD_HEADER MYBINDIR forward_header.cpp)
if(FWD_DECLARE)
message("Using forward declaration for nlohmann_json")
elseif(FWD_HEADER)
message("Using forward header from nlohmann_json")
else()
set(DO_WHATEVER_NLOHMANM_3.11.0_NEEDS ON)
message("using the special code that nlohmann 3.11.0 needs")
endif() But it's up to you. Arch Linux package builds now, so I am satisfied. Thanks for the help and quick response! |
The problem is I don't know what |
Version 3.11 of nlohmann/json introduced "versioned, ABI-tagged inline namespace"s, which breaks our forward declaration. Fortunately, we can assume the json_fwd.hpp header to be present starting from that same version because the JSON_MultipleHeaders option now defaults to ON and even if not, json_fwd.hpp is installed since patch version 3.11.2. For earlier versions, both methods work but json_fwd.hpp isn't guaranteed to be installed. Still use it if available. Fixes root-project#11130
Version 3.11 of nlohmann/json introduced "versioned, ABI-tagged inline namespace"s, which breaks our forward declaration. Fortunately, we can assume the json_fwd.hpp header to be present starting from that same version because the JSON_MultipleHeaders option now defaults to ON and even if not, json_fwd.hpp is installed since patch version 3.11.2. For earlier versions, both methods work but json_fwd.hpp isn't guaranteed to be installed. Still use it if available. Fixes #11130
Version 3.11 of nlohmann/json introduced "versioned, ABI-tagged inline namespace"s, which breaks our forward declaration. Fortunately, we can assume the json_fwd.hpp header to be present starting from that same version because the JSON_MultipleHeaders option now defaults to ON and even if not, json_fwd.hpp is installed since patch version 3.11.2. For earlier versions, both methods work but json_fwd.hpp isn't guaranteed to be installed. Still use it if available. Fixes root-project#11130 (cherry picked from commit ed56a35)
For try_compile(FWD_DECLARE MYBINDIR forward_declare.cpp)
try_compile(FWD_HEADER MYBINDIR forward_header.cpp)
if(FWD_DECLARE)
message("Using forward declaration for nlohmann_json")
elseif(FWD_HEADER)
message("Using forward header from nlohmann_json")
else()
set(DO_WHATEVER_NLOHMANM_3.11.0_NEEDS ON)
message(FATAL_ERROR "You are probably running nlohmann_json version 3.11.0 which is deemed unusable by its creator (https://github.com/nlohmann/json/releases/tag/v3.11.0). Please install a working version of nlohmann_json. If you think you're seeing this message in error and you have a different version of nlohmann_json installed, please report it as a bug.")
endif() but the advantage of this way is that it's version independent and will work when it works, even if the default behaviour changes in the future again. |
But that's what I'm saying all the time and what the (already merged) PR does... Except that we don't need it so convoluted, we know when our forward declaration breaks (and will be broken forever). |
The point was not to depend on the version if the behaviour changes in the future. Again, it's a finer point; probably, it doesn't matter. Thanks for fixing it so quickly! |
Version 3.11 of nlohmann/json introduced "versioned, ABI-tagged inline namespace"s, which breaks our forward declaration. Fortunately, we can assume the json_fwd.hpp header to be present starting from that same version because the JSON_MultipleHeaders option now defaults to ON and even if not, json_fwd.hpp is installed since patch version 3.11.2. For earlier versions, both methods work but json_fwd.hpp isn't guaranteed to be installed. Still use it if available. Fixes #11130 (cherry picked from commit ed56a35)
from #11130 (comment)
Original bug report regarding glibc 2.36
Describe the bug
ArchLinux recently upgraded to
glibc 2.36
, and that resulted in ROOT not compiling with either GCC 11.3.0 or GCC 12.1.1Expected behaviour
ROOT should compile with
glibc 2.36
.To Reproduce
glibc 2.36
and relevant compilersSetup
Additional context
An interesting caveat is that it seems ROOT also requires 32-bit specific headers (
gnu/stubs-32.h
) as well.Error log:
The text was updated successfully, but these errors were encountered: