This is an archive of the discontinued LLVM Phabricator instance.

[llvm-exegesis] Use mmap2 when mmap is unavailable to fix riscv32 build
ClosedPublic

Authored by raj.khem on Aug 20 2023, 1:57 PM.

Details

Summary

SYS_mmap is not available on RV32 and it fails to build

| /mnt/b/yoe/master/build/tmp/work-shared/llvm-project-source-17.0.0-r0/git/llvm/tools/llvm-exegesis/lib/X86/Target.cpp:1116:19: error: use of undeclared identifier 'SYS_mmap'
|  1116 |   generateSyscall(SYS_mmap, MmapCode);                                    
|       |                   ^                                                                                                                                                               
| /mnt/b/yoe/master/build/tmp/work-shared/llvm-project-source-17.0.0-r0/git/llvm/tools/llvm-exegesis/lib/X86/Target.cpp:1134:19: error: use of undeclared identifier 'SYS_mmap'
|  1134 |   generateSyscall(SYS_mmap, GeneratedCode);                                                                                                                                       |       |                   ^                                                                 
| 1 warning and 2 errors generated.

Diff Detail

Event Timeline

raj.khem created this revision.Aug 20 2023, 1:57 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 20 2023, 1:57 PM
raj.khem requested review of this revision.Aug 20 2023, 1:57 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 20 2023, 1:57 PM

This is also needed on 17.0.0 branch too.

MaskRay added inline comments.Aug 24 2023, 11:57 PM
llvm/tools/llvm-exegesis/lib/X86/Target.cpp
1094

I suggest that we write #if defined(SYS_mmap2) && !defined(SYS_mmap), which will help future 32-bit architectures.

// Some 32-bit architectures don't have mmap and use mmap2 instead ...

MaskRay retitled this revision from Fix build for riscv32 to [llvm-exegesis] Fix build for riscv32.Aug 24 2023, 11:57 PM
MaskRay added a subscriber: aidengrossman.

@aidengrossman This patch fixes an issue in D151023 that is not completely fixed by 82909f4e0529a0ac26adbd05eda7244b11d99cba

Once you adopt @MaskRay's comments regarding the comment wording and preprocessor directives, this should LGTM.

I'm surprised this wasn't caught earlier on (ideally soon after commit). It doesn't seem like there's any buildbot coverage for 32-bit RISCV? Not sure what would be involved in setting that up, but it would be nice to have the coverage to catch obvious regressions like this one more quickly rather than late in the release process.

Given how late we are in the release process, I'll go ahead, apply the changes, and land this patch.
I've landed other fixes for @raj.khem and hope that he doesn't mind:)

MaskRay accepted this revision.Aug 25 2023, 10:39 AM
This revision is now accepted and ready to land.Aug 25 2023, 10:39 AM
MaskRay retitled this revision from [llvm-exegesis] Fix build for riscv32 to [llvm-exegesis] Use mmap2 when mmap is unavailable to fix riscv32 build.Aug 25 2023, 10:42 AM
This revision was landed with ongoing or failed builds.Aug 25 2023, 10:43 AM
This revision was automatically updated to reflect the committed changes.
raj.khem updated this revision to Diff 553538.Aug 25 2023, 10:43 AM
raj.khem marked an inline comment as done.

@raj.khem Thank you for update! Already committed... Created https://github.com/llvm/llvm-project/issues/64994 for release/17.x backport.

Given how late we are in the release process, I'll go ahead, apply the changes, and land this patch.
I've landed other fixes for @raj.khem and hope that he doesn't mind:)

Not at all :) infact thank you for doing it