Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(pkg/driverbuiler): avoid overriding CC at build time. #322

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/driverbuilder/builder/builders.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const (
-DGIT_COMMIT=%s \
-DDRIVER_DEVICE_NAME=%s \
-DPROBE_DEVICE_NAME=%s \
-DCMAKE_C_COMPILER=%s \
.. && \
sed -i s/'DRIVER_COMMIT ""'/'DRIVER_COMMIT "%s"'/g driver/src/driver_config.h`
)
Expand Down Expand Up @@ -76,7 +77,6 @@ type commonTemplateData struct {
ModuleFullPath string
BuildModule bool
BuildProbe bool
GCCVersion string
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need the templated GCCVersion anymore since we already pass a correctly formatted cmake command to builders.

CmakeCmd string
}

Expand Down Expand Up @@ -311,7 +311,6 @@ func (c Config) toTemplateData(b Builder, kr kernelrelease.KernelRelease) common
ModuleFullPath: c.ToDriverFullPath(),
BuildModule: len(c.ModuleFilePath) > 0,
BuildProbe: len(c.ProbeFilePath) > 0,
GCCVersion: c.GCCVersion,
CmakeCmd: fmt.Sprintf(cmakeCmdFmt,
c.DriverName,
c.DriverName,
Expand All @@ -320,6 +319,7 @@ func (c Config) toTemplateData(b Builder, kr kernelrelease.KernelRelease) common
c.DriverVersion,
c.DeviceName,
c.DeviceName,
"/usr/bin/gcc-"+c.GCCVersion,
c.DriverVersion),
}
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/driverbuilder/builder/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type localTemplateData struct {
DownloadSrc bool
DriverVersion string
KernelRelease string
GCCPath string
}

func (l *LocalBuilder) TemplateData(c Config, kr kernelrelease.KernelRelease, _ []string) interface{} {
Expand All @@ -54,7 +55,6 @@ func (l *LocalBuilder) TemplateData(c Config, kr kernelrelease.KernelRelease, _
ModuleFullPath: l.GetModuleFullPath(c, kr),
BuildModule: len(c.ModuleFilePath) > 0,
BuildProbe: len(c.ProbeFilePath) > 0,
GCCVersion: l.GccPath,
CmakeCmd: fmt.Sprintf(cmakeCmdFmt,
c.DriverName,
c.DriverName,
Expand All @@ -63,12 +63,14 @@ func (l *LocalBuilder) TemplateData(c Config, kr kernelrelease.KernelRelease, _
c.DriverVersion,
c.DeviceName,
c.DeviceName,
l.GccPath,
c.DriverVersion),
},
UseDKMS: l.UseDKMS,
DownloadSrc: len(l.SrcDir) == 0, // if no srcdir is provided, download src!
DriverVersion: c.DriverVersion,
KernelRelease: c.KernelRelease,
GCCPath: l.GccPath,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When building through dkms, cmake is not involved, therefore for local script, it must still be passed somehow.

}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/driverbuilder/builder/templates/alinux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ mkdir -p build && cd build

{{ if .BuildModule }}
# Build the module
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=/tmp/kernel driver
make KERNELDIR=/tmp/kernel driver
strip -g {{ .ModuleFullPath }}
# Print results
modinfo {{ .ModuleFullPath }}
Expand Down
2 changes: 1 addition & 1 deletion pkg/driverbuilder/builder/templates/almalinux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ mkdir -p build && cd build

{{ if .BuildModule }}
# Build the module
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=/tmp/kernel driver
make KERNELDIR=/tmp/kernel driver
strip -g {{ .ModuleFullPath }}
# Print results
modinfo {{ .ModuleFullPath }}
Expand Down
2 changes: 1 addition & 1 deletion pkg/driverbuilder/builder/templates/amazonlinux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ mkdir -p build && cd build

{{ if .BuildModule }}
# Build the module
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=/tmp/kernel LD=/usr/bin/ld.bfd CROSS_COMPILE="" driver
make KERNELDIR=/tmp/kernel LD=/usr/bin/ld.bfd CROSS_COMPILE="" driver
strip -g {{ .ModuleFullPath }}
# Print results
modinfo {{ .ModuleFullPath }}
Expand Down
2 changes: 1 addition & 1 deletion pkg/driverbuilder/builder/templates/archlinux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ mkdir -p build && cd build

{{ if .BuildModule }}
# Build the module
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=/tmp/kernel driver
make KERNELDIR=/tmp/kernel driver
strip -g {{ .ModuleFullPath }}
# Print results
modinfo {{ .ModuleFullPath }}
Expand Down
2 changes: 1 addition & 1 deletion pkg/driverbuilder/builder/templates/centos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ mkdir -p build && cd build

{{ if .BuildModule }}
# Build the module
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=/tmp/kernel driver
make KERNELDIR=/tmp/kernel driver
strip -g {{ .ModuleFullPath }}
# Print results
modinfo {{ .ModuleFullPath }}
Expand Down
2 changes: 1 addition & 1 deletion pkg/driverbuilder/builder/templates/debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ mkdir -p build && cd build

{{ if .BuildModule }}
# Build the module
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=$sourcedir driver
make KERNELDIR=$sourcedir driver
strip -g {{ .ModuleFullPath }}
# Print results
modinfo {{ .ModuleFullPath }}
Expand Down
2 changes: 1 addition & 1 deletion pkg/driverbuilder/builder/templates/fedora.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ mkdir -p build && cd build

{{ if .BuildModule }}
# Build the module
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=/tmp/kernel driver
make KERNELDIR=/tmp/kernel driver
strip -g {{ .ModuleFullPath }}
# Print results
modinfo {{ .ModuleFullPath }}
Expand Down
2 changes: 1 addition & 1 deletion pkg/driverbuilder/builder/templates/flatcar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ mkdir -p build && cd build

{{ if .BuildModule }}
# Build the module
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=/tmp/kernel driver
make KERNELDIR=/tmp/kernel driver
strip -g {{ .ModuleFullPath }}
# Print results
modinfo {{ .ModuleFullPath }}
Expand Down
6 changes: 3 additions & 3 deletions pkg/driverbuilder/builder/templates/local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,18 @@ mkdir -p build && cd build
echo "* Building kmod with DKMS"
# Build the module using DKMS
echo "#!/usr/bin/env bash" > "/tmp/falco-dkms-make"
echo "make CC={{ .GCCVersion }} \$@" >> "/tmp/falco-dkms-make"
echo "make CC={{ .GCCPath }} \$@" >> "/tmp/falco-dkms-make"
chmod +x "/tmp/falco-dkms-make"
dkms install --directive="MAKE='/tmp/falco-dkms-make'" -m "{{ .ModuleDriverName }}" -v "{{ .DriverVersion }}" -k "{{ .KernelRelease }}"
rm -Rf "/tmp/falco-dkms-make"
{{ else }}
echo "* Building kmod"
{{ if .DownloadSrc }}
# Build the module - cmake configured
make CC={{ .GCCVersion }} driver
make driver
{{ else }}
# Build the module - preconfigured sources
make CC={{ .GCCVersion }}
make CC={{ .GCCPath }}
{{ end }}
strip -g {{ .ModuleFullPath }}
# Print results
Expand Down
2 changes: 1 addition & 1 deletion pkg/driverbuilder/builder/templates/opensuse.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ mkdir -p build && cd build

{{ if .BuildModule }}
# Build the module
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=$sourcedir driver
make KERNELDIR=$sourcedir driver
strip -g {{ .ModuleFullPath }}
# Print results
modinfo {{ .ModuleFullPath }}
Expand Down
2 changes: 1 addition & 1 deletion pkg/driverbuilder/builder/templates/oracle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ mkdir -p build && cd build

{{ if .BuildModule }}
# Build the module
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=/tmp/kernel driver
make KERNELDIR=/tmp/kernel driver
strip -g {{ .ModuleFullPath }}
# Print results
modinfo {{ .ModuleFullPath }}
Expand Down
2 changes: 1 addition & 1 deletion pkg/driverbuilder/builder/templates/photonos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ mkdir -p build && cd build

{{ if .BuildModule }}
# Build the module
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=/tmp/kernel driver
make KERNELDIR=/tmp/kernel driver
strip -g {{ .ModuleFullPath }}
# Print results
modinfo {{ .ModuleFullPath }}
Expand Down
2 changes: 1 addition & 1 deletion pkg/driverbuilder/builder/templates/redhat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ mkdir -p build && cd build

{{ if .BuildModule }}
# Build the module
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=/tmp/kernel driver
make KERNELDIR=/tmp/kernel driver
strip -g {{ .ModuleFullPath }}
# Print results
modinfo {{ .ModuleFullPath }}
Expand Down
2 changes: 1 addition & 1 deletion pkg/driverbuilder/builder/templates/rocky.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ mkdir -p build && cd build

{{ if .BuildModule }}
# Build the module
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=/tmp/kernel driver
make KERNELDIR=/tmp/kernel driver
strip -g {{ .ModuleFullPath }}
# Print results
modinfo {{ .ModuleFullPath }}
Expand Down
2 changes: 1 addition & 1 deletion pkg/driverbuilder/builder/templates/sles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ mkdir -p build && cd build

{{ if .BuildModule }}
# Build the module
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=$sourcedir driver
make KERNELDIR=$sourcedir driver
strip -g {{ .ModuleFullPath }}
# Print results
modinfo {{ .ModuleFullPath }}
Expand Down
2 changes: 1 addition & 1 deletion pkg/driverbuilder/builder/templates/ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ mkdir -p build && cd build

{{ if .BuildModule }}
# Build the module
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=$sourcedir driver
make KERNELDIR=$sourcedir driver
strip -g {{ .ModuleFullPath }}
# Print results
modinfo {{ .ModuleFullPath }}
Expand Down
2 changes: 1 addition & 1 deletion pkg/driverbuilder/builder/templates/vanilla.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ mkdir -p build && cd build

{{ if .BuildModule }}
# Build the module
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=/tmp/kernel driver
make KERNELDIR=/tmp/kernel driver
strip -g {{ .ModuleFullPath }}
# Print results
modinfo {{ .ModuleFullPath }}
Expand Down
Loading