llvm/bpf: disable llvm builtins for bpf target

As bpf program has no global section for constant values (especially strings),
so use llvm's builtins (like memcpy, memset, etc) will lead to compilation failure
(something like this: A call to built-in function 'memcpy' is not supported.)

Signed-off-by: Tw <tw19881113@gmail.com>
This commit is contained in:
Tw 2023-03-28 16:26:24 +08:00 committed by Veikka Tuominen
parent 9c3bea8482
commit 11903436a9

View File

@ -2719,6 +2719,9 @@ pub const DeclGen = struct {
if (comp.bin_file.options.llvm_cpu_features) |s| {
llvm_fn.addFunctionAttr("target-features", s);
}
if (comp.getTarget().cpu.arch.isBpf()) {
llvm_fn.addFunctionAttr("no-builtins", "");
}
}
fn resolveGlobalDecl(dg: *DeclGen, decl_index: Module.Decl.Index) Error!*llvm.Value {