Opened 12 years ago

Closed 11 years ago

#622 closed defect (fixed)

C++ ABI check fails with e.g. CXXFLAGS=-fabi-version=0

Reported by: Hristo Venev Owned by: Olly Betts
Priority: normal Milestone: 1.2.16
Component: Build system Version:
Severity: normal Keywords:
Cc: Blocked By:
Blocking: Operating System: All

Description

./include/xapian/version.h:28:2: error: #error The C++ ABI version of compiler you are using does not match
./include/xapian/version.h:29:2: error: #error that of the compiler used to build the library. The versions
./include/xapian/version.h:30:2: error: #error must match or your program will not work correctly.
./include/xapian/version.h:31:2: error: #error The Xapian library was built with g++ 4.8.0

cxxcpp_flags does not contain CXXFLAGS which affect ABI version. For example, -fabi-version=0

Attachments (1)

xapian.patch (964 bytes ) - added by Hristo Venev 12 years ago.
Fix

Download all attachments as: .zip

Change History (5)

by Hristo Venev, 12 years ago

Attachment: xapian.patch added

Fix

comment:1 by Olly Betts, 12 years ago

Milestone: 1.3.2
Severity: criticalnormal
Status: newassigned
Summary: C++ ABI does not match. While compiling xapianC++ ABI check fails with e.g. CXXFLAGS=-fabi-version=0

Thanks.

I'm just wondering if there might have been a good reason why we didn't just pass all the flags in the first place - the current code seems oddly complex otherwise. Otherwise it looks good.

comment:2 by Olly Betts, 12 years ago

This code was added in [7202] - no clues there.

I think the concern must have been that "$CXXCPP" might not handle arbitrary compiler flags - for the GNU toolchain it'll be fine, but if if we're using a generic /lib/cpp it might not like compiler-specific flags.

CPPFLAGS should be safe to pass to the preprocessor, but it's not helpful to ignore CXXFLAGS=-D_GLIBCXX_DEBUG - while it's technically incorrect (should be in CPPFLAGS) it works and having the build fail due to claimed ABI incompatibilities isn't helpful. And passing CPPFLAGS wouldn't help here.

The only alternative to passing all flags (as your patch does) seems to be adding -fabi-version* to the pattern to allow through - but there are bound to be other ABI changing flags, and even if we managed to get a complete list, new ones might appear with time.

So I think let's just apply this patch, and if we do hit problems with some compilers or platforms, we can try to special case them. The ABI checking machinery is only implemented for some compilers - those defining GNUC (GCC and some which pretend to be GCC), and MSVC - so for other compilers we could just not pass CXXFLAGS, or something.

comment:3 by Olly Betts, 11 years ago

Milestone: 1.3.21.2.16

OK, committed a fix to trunk in r17303.

I too the approach of adding both CPPFLAGS and CXXFLAGS only for MSVC and compilers defining GNUC (since those may need the additional flags, and we know they should handle all CXXFLAGS); for others compilers, I only added CPPFLAGS.

The autoconf manual advises in the docs for AC_PREPROC_IFELSE that:

This macro uses `CPPFLAGS', but not `CFLAGS', because `-g', `-O', etc. are not valid options to many C preprocessors.

It's unclear if that's also true for C++ compilers, but CXXCPP can be cpp if $CXX -E doesn't work, and I'd rather avoid possible regressions for compilers and platforms I'm unable to test on.

Marking to backport for 1.2.16.

comment:4 by Olly Betts, 11 years ago

Resolution: fixed
Status: assignedclosed

Backported in r17419.

Note: See TracTickets for help on using tickets.