Skip to content

Commit

Permalink
fix: 5.10.x kernels use llvm-12
Browse files Browse the repository at this point in the history
Signed-off-by: Austin Brogle <[email protected]>
  • Loading branch information
abroglesc authored and poiana committed Apr 22, 2022
1 parent bf48e62 commit 3ea18c6
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions pkg/driverbuilder/builder/amazonlinux.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ modinfo {{ .ModuleFullPath }}
{{ if .BuildProbe }}
# Build the eBPF probe
cd {{ .DriverBuildDir }}/bpf
make LLC=/usr/bin/llc-7 CLANG=/usr/bin/clang-7 CC=/usr/bin/gcc KERNELDIR=/tmp/kernel
make LLC=/usr/bin/llc-{{ .LLVMVersion }} CLANG=/usr/bin/clang-{{ .LLVMVersion }} CC=/usr/bin/gcc KERNELDIR=/tmp/kernel
ls -l probe.o
{{ end }}
`
Expand All @@ -95,6 +95,7 @@ type amazonlinuxTemplateData struct {
ModuleFullPath string
BuildModule bool
BuildProbe bool
LLVMVersion string
}

// Script compiles the script to build the kernel module and/or the eBPF probe.
Expand Down Expand Up @@ -138,6 +139,7 @@ func script(c Config, targetType Type) (string, error) {
ModuleFullPath: ModuleFullPath,
BuildModule: len(c.Build.ModuleFilePath) > 0,
BuildProbe: len(c.Build.ProbeFilePath) > 0,
LLVMVersion: amazonLLVMVersionFromKernelRelease(kv),
}

buf := bytes.NewBuffer(nil)
Expand Down Expand Up @@ -325,9 +327,21 @@ func bunzip(data io.Reader) (res []byte, err error) {
}

func amazonGccVersionFromKernelRelease(kr kernelrelease.KernelRelease) string {
switch kr.Version {
switch kr.Version {
case "5":
return "10"
}
return "8"
}
return "8"
}

func amazonLLVMVersionFromKernelRelease(kr kernelrelease.KernelRelease) string {
switch kr.Version {
case "5":
switch kr.PatchLevel {
case "10":
return "12"
}
return "7"
}
return "7"
}

0 comments on commit 3ea18c6

Please sign in to comment.