Skip to content

bpf target tries to emit memcpy and fails to compile #93700

Open
@umanwizard

Description

@umanwizard

Consider this C code:

#include <stdint.h>
typedef struct {
    unsigned char x[8];
} buf_t;
void f(buf_t *buf, uint64_t y, uint64_t z) {
    if (z > 8) z = 8;
    unsigned char *y_bytes = (unsigned char *)&y;
    for (int i = 0; i < z; ++i) {
        buf->x[i] = y_bytes[i];
    }
}

It fails to compile on clang 18:

$ clang -O3 -target bpf test.c
test.c:5:6: error: A call to built-in function 'memcpy' is not supported.
    5 | void f(buf_t *buf, uint64_t y, uint64_t z) {
      |      ^
1 error generated.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions