This is an archive of the discontinued LLVM Phabricator instance.

[linux] Use cmake to detect support process_vm_readv (bug #23918)
ClosedPublic

Authored by labath on Jun 25 2015, 3:00 AM.

Details

Summary

Some old linux versions do not have process_vm_readv function defined. Even older versions do not
have even the __NR_process_vm_readv syscall number. We use cmake to detect these situations and
fallback appropriately: in the first case, we can issue the syscall manually, while it the latter
case, we need to drop fast memory read support completely.

Diff Detail

Repository
rL LLVM

Event Timeline

labath updated this revision to Diff 28442.Jun 25 2015, 3:00 AM
labath retitled this revision from to [linux] Use cmake to detect support process_vm_readv (bug #23918).
labath updated this object.
labath edited the test plan for this revision. (Show Details)
labath added reviewers: ovyalov, Eugene.Zelenko.
labath added a subscriber: Unknown Object (MLST).
ovyalov accepted this revision.Jun 25 2015, 11:08 AM
ovyalov edited edge metadata.
ovyalov added inline comments.
cmake/modules/LLDBConfig.cmake
258 ↗(On Diff #28442)

Do we need to cast from ssize_t to int?

258 ↗(On Diff #28442)

Could you pass nullptr for const struct iovec *?

source/Host/linux/LibcGlue.cpp
10 ↗(On Diff #28442)

s/files/file

This revision is now accepted and ready to land.Jun 25 2015, 11:08 AM

Please define -DHAVE_PROCESS_VM_READV and -DHAVE_NR_PROCESS_VM_READV without values and check them with #ifdef/#ifndef.

I had preprocessor errors with #if ! applied to undefined variable in Uio.h and LibcGlue.cpp.

Build was successful after I changed #if ! to #ifdef.

Eugene.Zelenko requested changes to this revision.Jun 25 2015, 11:11 AM
Eugene.Zelenko edited edge metadata.

Sorry, forgot to set flag in my previous post.

This revision now requires changes to proceed.Jun 25 2015, 11:11 AM

Just dug in more and this is what I have in DependInfo.cmake files:

"HAVE_NR_PROCESS_VM_READV=1"
"HAVE_PROCESS_VM_READV="

HAVE_PROCESS_VM_READV is defined without value. However, value is completely irrelevant, fact of variable definition should be enough .

labath updated this revision to Diff 28554.Jun 26 2015, 3:53 AM
labath edited edge metadata.
  • Fix preprocessor macro definitions
  • Make function check more type-safe
labath updated this revision to Diff 28555.Jun 26 2015, 3:55 AM
labath edited edge metadata.
  • Fix typo

My apologies, it seems I misunderstood the operation of check_cxx_source_compiles. Please try it again.

cmake/modules/LLDBConfig.cmake
258 ↗(On Diff #28442)

done.

source/Host/linux/LibcGlue.cpp
10 ↗(On Diff #28442)

Done.

source/Host/linux/LibcGlue.cpp also need to include #include <unistd.h> (for syscall() prototype). Sorry, I didn't catch it yesterday because I incorrectly applied ifndef.

Man page tells to define #define _GNU_SOURCE before #include <unistd.h>.

I'm not sure, but probably macro should start from HAS, not HAVE, since they are about operation system.

This revision was automatically updated to reflect the committed changes.

source/Host/linux/LibcGlue.cpp also need to include #include <unistd.h> (for syscall() prototype). Sorry, I didn't catch it yesterday because I incorrectly applied ifndef.

I've added unistd.h and committed. Let me know if you see any problems.

Man page tells to define #define _GNU_SOURCE before #include <unistd.h>.

This macro is defined (for me at least) on the compiler command line. If this is not the case for you, then we can work it out separately.

I'm not sure, but probably macro should start from HAS, not HAVE, since they are about operation system.

I am testing a feature of the c library (the support in the actual running kernel will be tested at runtime - we need this that way), which seems consistent with all the other HAVE_ macros i've seen.

Should be OK now.