This is an archive of the discontinued LLVM Phabricator instance.

[AIX][cmake] Set atomics related macros when build with xlclang
ClosedPublic

Authored by lkail on Oct 14 2021, 2:00 AM.

Details

Summary

Set HAVE_CXX_ATOMICS_WITHOUT_LIB or HAVE_LIBATOMIC when build LLVM with xlclang. With these macros set, libraries like libLLVMSupport are able to know whether it's necessary to add -latomic to dependent system libs. If HAVE_LIBATOMIC is set, llvm-config --system-libs appends -latomic to its output.

Diff Detail

Event Timeline

lkail created this revision.Oct 14 2021, 2:00 AM
lkail requested review of this revision.Oct 14 2021, 2:00 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 14 2021, 2:00 AM
lkail updated this revision to Diff 379638.Oct 14 2021, 2:35 AM
lkail updated this revision to Diff 379645.Oct 14 2021, 2:59 AM
jsji added a comment.Oct 14 2021, 6:40 AM

Can we set LLVM_COMPILER_IS_GCC_COMPATIBLE in ./llvm/cmake/modules/DetermineGCCCompatible.cmake instead?

lkail added a comment.EditedOct 15 2021, 2:48 AM

Can we set LLVM_COMPILER_IS_GCC_COMPATIBLE in ./llvm/cmake/modules/DetermineGCCCompatible.cmake instead?

xlclang is in theory compatible with gcc's command line syntax as clang, but there are some unexpected behaviors exposed if enable it in current LLVM cmake system. For example, when LLVM_ENABLE_WERROR is set which is our default configuration, current cmake config only add -Werror when LLVM_COMPILER_IS_GCC_COMPATIBLE

# Warnings-as-errors handling for GCC-compatible compilers:                                                                                                                                   
if ( LLVM_COMPILER_IS_GCC_COMPATIBLE )                                                                                                                                                        
  append_if(LLVM_ENABLE_WERROR "-Werror" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)                                                                                                                       
  append_if(LLVM_ENABLE_WERROR "-Wno-error" CMAKE_REQUIRED_FLAGS)                                                                                                                             
endif( LLVM_COMPILER_IS_GCC_COMPATIBLE )

If -Werror is added to xlclang's compile flags, some files are unable to compile due to treating warning as error

/home/lkail/llvm/dev/llvm-project/llvm/lib/Support/BuryPointer.cpp:22:3: error: 1540-2990 The attribute " __attribute__((used))" is not supported. The attribute is ignored.
  LLVM_ATTRIBUTE_USED static const void *GraveYard[kGraveYardMaxSize];
jsji accepted this revision as: jsji.Oct 15 2021, 6:49 AM

LGTM. Let us deal with the LLVM_COMPILER_IS_GCC_COMPATIBLE in a follow up patch later.

This revision is now accepted and ready to land.Oct 15 2021, 6:49 AM
This revision was landed with ongoing or failed builds.Oct 18 2021, 2:18 AM
This revision was automatically updated to reflect the committed changes.