https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124374

            Bug ID: 124374
           Summary: bpf: selftests: order of attribute decl tags
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: cupermir at gcc dot gnu.org
  Target Milestone: ---

The BPF selftests rely on decl_tags to attribute function declarations with
strings. These strings are used later to validate whether the test prints the
expected content.

An example is the __msg macro:
#define __msg(msg) __attribute__((btf_decl_tag("comment:test_expect_msg="
XSTR(__COUNTER__) "=" msg)))

These messages are expected to be matched in the order they appear in the
source code. The BPF selftests do not rely on __COUNTER__ to determine the
sequence; instead, they simply append each tag to an array that is processed
linearly.

However, GCC and Clang emit these attributes into BTF differently. Per the C
standard, the order of attributes is not semantically significant.
Consequently, neither GCC nor Clang should be required to preserve the
source-code order when generating the BTF metadata.

Reply via email to