lvc / abi-compliance-checker

A tool for checking backward API/ABI compatibility of a C/C++ library
https://lvc.github.io/abi-compliance-checker/
GNU Lesser General Public License v2.1
625 stars 78 forks source link

ABI compliance checker thinks that C is C++ #64

Open jan-cerny opened 7 years ago

jan-cerny commented 7 years ago

Hello,

I have been using abi-compliance-checker for a long time to check API/ABI compatibility while making an upstream releases of OpenSCAP.

However after I upgraded to Fedora 26, abi-compliance-checker stopped working, because it started to treat the C source code as C++. Unfortunately C++ has some keywords that are not keywords in C, so gcc reports errors. Our code is writen in C.

See this log: https://paste.fedoraproject.org/paste/zcjCZMUb7IsOwJTRjkk7DA

I have discovered option -cxx-incompatible that looks like solving the problem according to its description. However it mitigates only the error with operator, but not with export keyword.

Option -lang C seems to have no effect, gcc still treats it as C++.

I am using abi-compliance-checker-2.1-1.fc26.noarch on Fedora 26 now.

Last time when it worked correctly was with abi-compliance-checker 1.99.20 on Fedora 24. But Fedora 24 is EOL, and also I don't have it anymore, and on Fedora 26 there's no possibility to downgrade.

Is there any way how to check the C code as C code?

Thank you.

lvc commented 7 years ago

Hello,

Actually, the code is always compiled by G++ since -fdump-translation-unit option of GCC is valid for C++ only. The checker tries to replace all C++ keywords in the code to C compatible ones before creating the translation unit dump. And seems there are two problems with the checker:

  1. It doesn't handle 'export' keyword properly
  2. It doesn't detect language of the project properly (not sure)

The first problem is fixed right now by the commit 59e148db186e38cbe40358e7adc4948fdfd5636a. But I cannot identify the second one. Probably this is not the issue. Please try latest versions of the checker from master without -cxx-incompatible option.

Also I recommend you to use ABI Dumper tool instead of creating ABI dumps by ABICC to avoid headers compilation step at all. Like this was done in the ABI Tracker project: https://abi-laboratory.pro/tracker/timeline/openscap/

Thanks for reporting this.

jan-cerny commented 7 years ago

@lvc Thank you very much. I will check that.

I wasn't aware of ABI tracker. That's awesome project. Good job!

vinc17fr commented 4 years ago

There's also the issue that GCC knows _Decimal64 with C, but not with C++.

vinc17fr commented 4 years ago

Concerning the decimal floats, a workaround is to add decimal/decimal in the include_preamble section and the following defines in the defines section:

#define _Decimal32 std::decimal::decimal32
#define _Decimal64 std::decimal::decimal64
#define _Decimal128 std::decimal::decimal128

But abi-compliance-checker should be able to detect the use of C decimal floats automatically and do that in this case.