Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 2002024

Summary: don't set IsUnwindTablesDefault true for bpf targets
Product: Red Hat Enterprise Linux 8 Reporter: Yonghong Song <ys114321>
Component: clangAssignee: Tom Stellard <tstellar>
Status: CLOSED ERRATA QA Contact: Miloš Prchlík <mprchlik>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: CentOS StreamCC: bstinson, davide, jolsa, jwboyer, lmiksik, mcermak, mprchlik, sguelton, thoiland, tstellar, ykaliuta
Target Milestone: rcKeywords: Bugfix, Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: clang-12.0.1-2.module+el8.5.0+12651+6a7729ff Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of:
: 2005010 (view as bug list) Environment:
Last Closed: 2021-11-09 18:34:51 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2005010    

Description Yonghong Song 2021-09-07 17:54:32 UTC
Description of problem:

See the bpf mailing list discussion here:
https://lore.kernel.org/bpf/095f116b-7399-25a5-dca2-145cbd093326@fb.com/T/#mf02b028b693bb45551faa6df99092ca3d2b4bec6

fedora packaged clang has the following private patch which sets default unwindtalbe true for all architectures:
https://git.centos.org/rpms/clang/blob/b99d8d4a38320329e10570f308c3e2d8cf295c78/f/SOURCES/0002-PATCH-clang-Make-funwind-tables-the-default-on-all-a.patch

But as discussed in the bpf mailing list, this cause annoying user experience for bpf developers. Without the above private patch, everything works fine and no annoying .eh_frame section for bpf programs.

So I proposed to amend the above patch to set default unwindtable to false to bpf targets. The following is the new patch I proposed:

[$ ~/work/llvm-project/clang/lib/Driver] git diff
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index b2ddef141a75..6c074c4dc401 100644 
--- a/clang/lib/Driver/ToolChain.cpp    
+++ b/clang/lib/Driver/ToolChain.cpp    
@@ -257,7 +257,9 @@ std::string ToolChain::getInputFilename(const InputInfo &Input) const {
 }
 
 bool ToolChain::IsUnwindTablesDefault(const ArgList &Args) const {
-  return false;
+  if (getArch() == llvm::Triple::bpfel || getArch() == llvm::Triple::bpfeb)
+    return false;              
+  return true; 
 }
 
 Tool *ToolChain::getClang() const {
diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
index 1d8a3cdce92a..cbf6bc330936 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2705,6 +2705,9 @@ void Generic_GCC::printVerboseInfo(raw_ostream &OS) const {
 
 bool Generic_GCC::IsUnwindTablesDefault(const ArgList &Args) const {
   switch (getArch()) {
+  case llvm::Triple::bpfel:
+  case llvm::Triple::bpfeb:
+    return false;
   case llvm::Triple::aarch64:
   case llvm::Triple::ppc:
   case llvm::Triple::ppcle:
@@ -2713,7 +2716,7 @@ bool Generic_GCC::IsUnwindTablesDefault(const ArgList &Args) const {
   case llvm::Triple::x86_64:
     return true;
   default:
-    return false;
+    return true;
   }
 }



Version-Release number of selected component (if applicable):


How reproducible:
[$ ~/work/tests/llvm/eh_frame] cat t.c
int test() { return 0; }
[$ ~/work/tests/llvm/eh_frame] clang -target bpf -O2 -c t.c
[$ ~/work/tests/llvm/eh_frame] llvm-readelf -S t.o | grep eh_frame
  [ 3] .eh_frame         PROGBITS        0000000000000000 000050 000030 00   A  0   0  8
  [ 4] .rel.eh_frame     REL             0000000000000000 0000e0 000010 10      6   3  8

Steps to Reproduce:
1. compile t.c with clang target bpf to generate ELF file
2. check ELF section list for .eh_frame
3.

Actual results:
[$ ~/work/tests/llvm/eh_frame] llvm-readelf -S t.o | grep eh_frame
  [ 3] .eh_frame         PROGBITS        0000000000000000 000050 000030 00   A  0   0  8
  [ 4] .rel.eh_frame     REL             0000000000000000 0000e0 000010 10      6   3  8

Expected results:
[$ ~/work/tests/llvm/eh_frame] llvm-readelf -S t.o | grep eh_frame
[$ ~/work/tests/llvm/eh_frame]

Additional info:

Comment 13 errata-xmlrpc 2021-11-09 18:34:51 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (llvm-toolset:rhel8 bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2021:4233