Skip to content

Commit 441c2ae

Browse files
committed
Refactor include generation in eBPF C code to remove support for built-in headers, simplifying the process.
1 parent f8e8c05 commit 441c2ae

1 file changed

Lines changed: 2 additions & 15 deletions

File tree

src/ebpf_c_codegen.ml

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,7 +1109,7 @@ let generate_declarations_in_source_order ctx _ir_multi_program type_aliases =
11091109

11101110
(** Generate standard eBPF includes *)
11111111

1112-
let generate_includes ctx ?(program_types=[]) ?(include_builtin_headers=false) () =
1112+
let generate_includes ctx ?(program_types=[]) () =
11131113
(* Essential kernel types must come first *)
11141114
let base_type_includes = [
11151115
"#include <linux/types.h>";
@@ -1145,19 +1145,6 @@ let generate_includes ctx ?(program_types=[]) ?(include_builtin_headers=false) (
11451145
let unique_context_includes = List.filter (fun inc ->
11461146
not (List.mem inc all_base_includes)) context_includes in
11471147

1148-
(* Only add builtin headers if explicitly requested (for debugging/testing) *)
1149-
let builtin_includes = if include_builtin_headers then
1150-
List.fold_left (fun acc prog_type ->
1151-
match prog_type with
1152-
| Ast.Xdp -> "#include \"xdp.h\"" :: acc
1153-
| Ast.Tc -> "#include \"tc.h\"" :: acc
1154-
| Ast.Kprobe -> "#include \"kprobe.h\"" :: acc
1155-
| _ -> acc
1156-
) [] program_types
1157-
else
1158-
[] (* Skip builtin headers - enum constants come from system headers *)
1159-
in
1160-
11611148
(* For kprobe programs, only emit kprobe includes which contain everything needed *)
11621149
let has_kprobe = List.exists (function Ast.Kprobe -> true | _ -> false) program_types in
11631150
if has_kprobe then (
@@ -1188,7 +1175,7 @@ let generate_includes ctx ?(program_types=[]) ?(include_builtin_headers=false) (
11881175
emit_blank_line ctx
11891176
) else (
11901177
(* For non-kprobe programs, use standard processing *)
1191-
let all_includes = builtin_includes @ standard_includes @ unique_context_includes @ base_type_includes in
1178+
let all_includes = standard_includes @ unique_context_includes @ base_type_includes in
11921179
List.iter (emit_line ctx) all_includes;
11931180
emit_blank_line ctx;
11941181

0 commit comments

Comments
 (0)