Opened 4 years ago

#13569 new Patches

Broken build on newer versions of LLVM

Reported by: Emil Gilliam <egilliam@…> Owned by: timblechmann
Milestone: To Be Determined Component: atomic
Version: Boost 1.63.0 Severity: Problem
Keywords: Cc:

Description

Starting with LLVM r331746, the use of compare-and-swap on a const object is not allowed. On x86 and Clang, this breaks several places in atomic/detail/ops_gcc_x86_dcas.hpp, like this:

if defined(__clang__)
            // Clang cannot allocate eax:edx register pairs but it has sync intrinsics
            value = __sync_val_compare_and_swap(&storage, (storage_type)0, (storage_type)0);
#elif defined(BOOST_ATOMIC_DETAIL_X86_NO_ASM_AX_DX_PAIRS)
...

The use of compare-and-swap is actually a workaround for a Clang limitation which hasn't existed for a long time. Clang versions newer than 4.0.1 understand "=&A" contraints. I am attaching a proposed patch to ops_css_x86_dcas.hpp and config.hpp which detects the Clang version (using a has_feature), and if it's new enough, uses the "=&A" constraint, otherwise falls back to the existing compare-and-swap. (I had to do a bit of fancy footwork with the #ifs to make this happen.)

Attachments (2)

boost-atomic-patch.txt (6.0 KB ) - added by Emil Gilliam <egilliam@…> 4 years ago.
Patch to Boost to fix compare-and-swap of const object in newer LLVM
boost-atomic.patch (5.6 KB ) - added by Emil Gilliam <egilliam@…> 4 years ago.
IGNORE OTHER ATTACHMENT - file paths are corrected in this patch.

Download all attachments as: .zip

Change History (2)

by Emil Gilliam <egilliam@…>, 4 years ago

Attachment: boost-atomic-patch.txt added

Patch to Boost to fix compare-and-swap of const object in newer LLVM

by Emil Gilliam <egilliam@…>, 4 years ago

Attachment: boost-atomic.patch added

IGNORE OTHER ATTACHMENT - file paths are corrected in this patch.

Note: See TracTickets for help on using tickets.