-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Inclusion of nlohmann/json.hpp causes OS/ABI to change on Linux #1410
Comments
Thanks for reporting! I have no idea how to proceed here. |
I have looked around to see if there is anyway to set the OS/ABI with the compiler/linker options, but it seems to be poorly documented. I have tried some suggestion, i.e. -fno-jump-tables, but none of them worked. The code I am trying to integrate your json.hpp with is quite large with multiple modules generated by many people. In Linux the main program and all the loadable libraries have System V ABI, so I need to be able to generate my loadable with json.hpp the same. |
To track down the issue, we can use
Comparing its output to the case when
For
In the source code,
I suspect the However, I'm afraid this is not limited only to
This is not always true. A better code sample is posted in my next comment: #1410 (comment) |
In my program with json.hpp included I get the following " u " values
Is there any ability to change this so that GNU extensions are not used? The code my module is interacting with is Regards |
The "u" symbols present in the object may differ based on your usage. That's because the linker can removed unused symbols from the final executable. It is interesting that all "u" symbols showing up for you is from
I am no expert on this but and it seems not easy. Here are some posts discussing this issue: https://stackoverflow.com/questions/11931420 There are probably various cases that such symbol shows up in the binary object. The previous sample code I posted at #1410 (comment) doesn't always work. The following code (which is very simple singleton pattern) seems trigger "u" symbol generation too.
|
This can be fixed by simply wrapping
Whether this should be done for the library is potentially contentious since it's an import from ranges-V3 and consistency might be desirable. However, it's a change you can make to your own copy of json.hpp very easily. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I was away so I could not do a test before the bot auto closed this issue. I have tried this, but it still shows the same " u " strings. So there must be something else in the json.hpp which is triggering this behaviour. |
Should I reopen? Does anyone has an idea? |
It needs someone to look at it as just including json.hpp should leave the 'flavour' of the environment as it was, i.e. it should add no 'special' processing. If this is not going to be the case then it makes it very difficult for developers to use this code to assist with json processing. |
I do not know what you mean with "special processing" or "flavor of the environment". :-/ |
Sorry, Australian colloquialisms! I want to use this code to enable the use of json schemas for validating messages passing information between plugins within a program and between instances of the program running on different machines. I suspect that when this has been done it will then be used to pass information to other programs/projects as well. Due to the nature of the project I am working on I cannot change the OSABI, which is currently "UNIX - System V", i.e. generic, as the project is built for Linux, Windows, osX and Raspberry PI and is worked on, like yours, by an international team. I tried the fix that FrancoisChabot suggested, but it made no difference, the OSABI still changed. I am not familiar enough with the use of namespaces, etc., to workout what is going on or where to make changes to fix the issue. I gave an example program that demonstrates the problem when I opened this issue. If you want to look at my plugin (it will compile and link independent of the main program, but does require wxWidgets 3.1.2) you will find it here: https://github.com/jongough/ocpn_draw_pi . To use the json.hpp you will need to set 'OD_JSON_SCHEMA_VALIDATOR' to true in the CMakeCache.txt file. You will see the same output as I posted on the 7th Jan when issuing this command: |
I am not at all familiar in these issues. I hope someone who is can support here. |
Maybe relates: https://www.acodersjourney.com/20-abi-breaking-changes/ |
That certainly looks close, particularly from item 8 onwards. I think you may be doing 'stuff' with const variables that could be causing the issue, certainly FrancoisChabot seemed to be suggesting changes to try and hide this. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Is there any work progressing on this issue? It is being marked as stale, but, to me, it appears still to be an issue. |
It looks like this issue is not solvable, so I probably wont be able to use this work in my project. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I have got the schema checking working but I have to hand change the OS/ABI back to the default. I have no idea what is causing the issue, but on linux changing the OS/ABI seems to work. I have not tried it yet on windows to see if it is a problem. But it would be very helpful if you could find out why your code is doing this. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
What is the issue you have?
Trying to incorporate a json schema validator using nlohmann/json.hpp into C++ code causes the linux gcc compiler/linker to change the OSABI from UNIX - System V (ELF OS/ABI value 0) to UNIX - GNU (ELF OS/ABI value 3). This makes it impossible to run with existing programs as it fails the compliance test at runtime.
Please describe the steps to reproduce the issue. Can you provide a small but working code example?
A simple program called testOSABI.cpp:
If compiled with:
gcc testOSABI.cpp -o testOSABI.o -Inlohmann_json/single_include
Then use readelf
readelf -h testOSABI.o
will give:
If the program has the
#include
statement uncommented and the same process followed the readelf will give:What is the expected behaviour?
The two outputs should be the same for the OS/ABI value
And what is the actual behaviour instead?
The two OS/ABI values are different. This will stop a program with json.hpp included from interacting successfully with one that does not have json.hpp included.
Which compiler and operating system are you using? Is it a supported compiler?
gcc 7.3.0 on Ubuntu based Linux Mint 19 with kernel 4.18.0-13-generic
Did you use a released version of the library or the version from the
develop
branch?Release
The text was updated successfully, but these errors were encountered: