Package: abi-compliance-checker
Version: 2.3-1
Severity: normal
Tags: patch
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu lunar ubuntu-patch

Hi Mathieu,

I'm currently using abi-compliance-checker to do some archive-wide analysis
of armhf library ABIs, and how those would change if we turned on 64-bit
time_t.  In the process, I discovered a bug in a-c-c's -cxx-incompatible
option: when checking whether any symbol names need to be mangled to not
break when compiled with the C++ frontend, it fails to pass the preprocessor
defines (-U__cplusplus -D_Bool=\"bool\") to the preprocessor that it's set
up to pass when doing a full compilation!  The result is that a good number
of libraries which use C++-incompatible symbol names are handled wrong at
the preprocessor stage, so even if the headers are successfully mangled by
a-c-c, the preprocessed code passed to the compiler is the wrong code and
can't be successfully compiled.

The attached patch addresses this and ensures we're always passing the same
-D and -U options to the preprocessor when compiling C code.

Thanks for considering,
-- 
Steve Langasek                   Give me a lever long enough and a Free OS
Debian Developer                   to set it on, and I can move the world.
Ubuntu Developer                                   https://www.debian.org/
slanga...@ubuntu.com                                     vor...@debian.org
diff -Nru abi-compliance-checker-2.3/debian/patches/consistent-C-flags.patch 
abi-compliance-checker-2.3/debian/patches/consistent-C-flags.patch
--- abi-compliance-checker-2.3/debian/patches/consistent-C-flags.patch  
1969-12-31 16:00:00.000000000 -0800
+++ abi-compliance-checker-2.3/debian/patches/consistent-C-flags.patch  
2023-02-03 07:53:52.000000000 -0800
@@ -0,0 +1,24 @@
+Description: use consistent flags to GCC when doing two passes
+ When using the -cxx-incompatible option, a-c-c runs gcc in two passes,
+ a preprocessor pass and a compilation pass, with a step in between to try
+ to fix up C code to be C++-compatible.  However, a-c-c passes -U__cplusplus
+ during the compilation pass but *not* to the preprocessor pass, which can
+ result in the detection of C code to fail.  Pass the preprocessor instruction
+ to the preprocessor pass where it belongs!
+Author: Steve Langasek <steve.langa...@ubuntu.com>
+Last-Update: 2023-02-03
+Forwarded: no
+
+Index: abi-compliance-checker-2.3/modules/Internals/TUDump.pm
+===================================================================
+--- abi-compliance-checker-2.3.orig/modules/Internals/TUDump.pm
++++ abi-compliance-checker-2.3/modules/Internals/TUDump.pm
+@@ -640,7 +640,7 @@
+     my ($HeaderPath, $IncStr, $LVer) = @_;
+     
+     my $TmpDir = $In::Opt{"Tmp"};
+-    my $PreprocessCmd = getCompileCmd($HeaderPath, "-E", $IncStr, $LVer);
++    my $PreprocessCmd = getCompileCmd($HeaderPath, "-U__cplusplus 
-D_Bool=\"bool\" -E", $IncStr, $LVer);
+     my $Content = undef;
+     
+     if(not defined $In::Opt{"MinGWCompat"}
diff -Nru abi-compliance-checker-2.3/debian/patches/series 
abi-compliance-checker-2.3/debian/patches/series
--- abi-compliance-checker-2.3/debian/patches/series    2021-12-09 
02:01:04.000000000 -0800
+++ abi-compliance-checker-2.3/debian/patches/series    2023-02-03 
07:48:24.000000000 -0800
@@ -3,3 +3,4 @@
 oom-exec-helper.patch
 fpic-for-arm64.patch
 0659b3b0a23e3535f41c6fd8dee5255ad8e29f7e.patch
+consistent-C-flags.patch

Reply via email to