Skip to content

Commit 8db4a3c

Browse files
committed
chore(pkg/driverbuiler): avoid overriding CC at build time.
Instead, set CMAKE_C_COMPILER variable at cmake configure step. Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
1 parent 0753b39 commit 8db4a3c

19 files changed

+24
-22
lines changed

pkg/driverbuilder/builder/builders.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ const (
4747
-DGIT_COMMIT=%s \
4848
-DDRIVER_DEVICE_NAME=%s \
4949
-DPROBE_DEVICE_NAME=%s \
50+
-DCMAKE_C_COMPILER=%s \
5051
.. && \
5152
sed -i s/'DRIVER_COMMIT ""'/'DRIVER_COMMIT "%s"'/g driver/src/driver_config.h`
5253
)
@@ -76,7 +77,6 @@ type commonTemplateData struct {
7677
ModuleFullPath string
7778
BuildModule bool
7879
BuildProbe bool
79-
GCCVersion string
8080
CmakeCmd string
8181
}
8282

@@ -311,7 +311,6 @@ func (c Config) toTemplateData(b Builder, kr kernelrelease.KernelRelease) common
311311
ModuleFullPath: c.ToDriverFullPath(),
312312
BuildModule: len(c.ModuleFilePath) > 0,
313313
BuildProbe: len(c.ProbeFilePath) > 0,
314-
GCCVersion: c.GCCVersion,
315314
CmakeCmd: fmt.Sprintf(cmakeCmdFmt,
316315
c.DriverName,
317316
c.DriverName,
@@ -320,6 +319,7 @@ func (c Config) toTemplateData(b Builder, kr kernelrelease.KernelRelease) common
320319
c.DriverVersion,
321320
c.DeviceName,
322321
c.DeviceName,
322+
"/usr/bin/gcc-"+c.GCCVersion,
323323
c.DriverVersion),
324324
}
325325
}

pkg/driverbuilder/builder/local.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ type localTemplateData struct {
4343
DownloadSrc bool
4444
DriverVersion string
4545
KernelRelease string
46+
GCCPath string
4647
}
4748

4849
func (l *LocalBuilder) TemplateData(c Config, kr kernelrelease.KernelRelease, _ []string) interface{} {
@@ -54,7 +55,6 @@ func (l *LocalBuilder) TemplateData(c Config, kr kernelrelease.KernelRelease, _
5455
ModuleFullPath: l.GetModuleFullPath(c, kr),
5556
BuildModule: len(c.ModuleFilePath) > 0,
5657
BuildProbe: len(c.ProbeFilePath) > 0,
57-
GCCVersion: l.GccPath,
5858
CmakeCmd: fmt.Sprintf(cmakeCmdFmt,
5959
c.DriverName,
6060
c.DriverName,
@@ -63,12 +63,14 @@ func (l *LocalBuilder) TemplateData(c Config, kr kernelrelease.KernelRelease, _
6363
c.DriverVersion,
6464
c.DeviceName,
6565
c.DeviceName,
66+
l.GccPath,
6667
c.DriverVersion),
6768
},
6869
UseDKMS: l.UseDKMS,
6970
DownloadSrc: len(l.SrcDir) == 0, // if no srcdir is provided, download src!
7071
DriverVersion: c.DriverVersion,
7172
KernelRelease: c.KernelRelease,
73+
GCCPath: l.GccPath,
7274
}
7375
}
7476

pkg/driverbuilder/builder/templates/alinux.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ mkdir -p build && cd build
4545

4646
{{ if .BuildModule }}
4747
# Build the module
48-
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=/tmp/kernel driver
48+
make KERNELDIR=/tmp/kernel driver
4949
strip -g {{ .ModuleFullPath }}
5050
# Print results
5151
modinfo {{ .ModuleFullPath }}

pkg/driverbuilder/builder/templates/almalinux.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ mkdir -p build && cd build
4545

4646
{{ if .BuildModule }}
4747
# Build the module
48-
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=/tmp/kernel driver
48+
make KERNELDIR=/tmp/kernel driver
4949
strip -g {{ .ModuleFullPath }}
5050
# Print results
5151
modinfo {{ .ModuleFullPath }}

pkg/driverbuilder/builder/templates/amazonlinux.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ mkdir -p build && cd build
4848

4949
{{ if .BuildModule }}
5050
# Build the module
51-
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=/tmp/kernel LD=/usr/bin/ld.bfd CROSS_COMPILE="" driver
51+
make KERNELDIR=/tmp/kernel LD=/usr/bin/ld.bfd CROSS_COMPILE="" driver
5252
strip -g {{ .ModuleFullPath }}
5353
# Print results
5454
modinfo {{ .ModuleFullPath }}

pkg/driverbuilder/builder/templates/archlinux.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ mkdir -p build && cd build
4545

4646
{{ if .BuildModule }}
4747
# Build the module
48-
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=/tmp/kernel driver
48+
make KERNELDIR=/tmp/kernel driver
4949
strip -g {{ .ModuleFullPath }}
5050
# Print results
5151
modinfo {{ .ModuleFullPath }}

pkg/driverbuilder/builder/templates/centos.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ mkdir -p build && cd build
4646

4747
{{ if .BuildModule }}
4848
# Build the module
49-
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=/tmp/kernel driver
49+
make KERNELDIR=/tmp/kernel driver
5050
strip -g {{ .ModuleFullPath }}
5151
# Print results
5252
modinfo {{ .ModuleFullPath }}

pkg/driverbuilder/builder/templates/debian.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ mkdir -p build && cd build
5353

5454
{{ if .BuildModule }}
5555
# Build the module
56-
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=$sourcedir driver
56+
make KERNELDIR=$sourcedir driver
5757
strip -g {{ .ModuleFullPath }}
5858
# Print results
5959
modinfo {{ .ModuleFullPath }}

pkg/driverbuilder/builder/templates/fedora.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ mkdir -p build && cd build
4545

4646
{{ if .BuildModule }}
4747
# Build the module
48-
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=/tmp/kernel driver
48+
make KERNELDIR=/tmp/kernel driver
4949
strip -g {{ .ModuleFullPath }}
5050
# Print results
5151
modinfo {{ .ModuleFullPath }}

pkg/driverbuilder/builder/templates/flatcar.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ mkdir -p build && cd build
5252

5353
{{ if .BuildModule }}
5454
# Build the module
55-
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=/tmp/kernel driver
55+
make KERNELDIR=/tmp/kernel driver
5656
strip -g {{ .ModuleFullPath }}
5757
# Print results
5858
modinfo {{ .ModuleFullPath }}

pkg/driverbuilder/builder/templates/local.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,18 @@ mkdir -p build && cd build
4848
echo "* Building kmod with DKMS"
4949
# Build the module using DKMS
5050
echo "#!/usr/bin/env bash" > "/tmp/falco-dkms-make"
51-
echo "make CC={{ .GCCVersion }} \$@" >> "/tmp/falco-dkms-make"
51+
echo "make CC={{ .GCCPath }} \$@" >> "/tmp/falco-dkms-make"
5252
chmod +x "/tmp/falco-dkms-make"
5353
dkms install --directive="MAKE='/tmp/falco-dkms-make'" -m "{{ .ModuleDriverName }}" -v "{{ .DriverVersion }}" -k "{{ .KernelRelease }}"
5454
rm -Rf "/tmp/falco-dkms-make"
5555
{{ else }}
5656
echo "* Building kmod"
5757
{{ if .DownloadSrc }}
5858
# Build the module - cmake configured
59-
make CC={{ .GCCVersion }} driver
59+
make driver
6060
{{ else }}
6161
# Build the module - preconfigured sources
62-
make CC={{ .GCCVersion }}
62+
make CC={{ .GCCPath }}
6363
{{ end }}
6464
strip -g {{ .ModuleFullPath }}
6565
# Print results

pkg/driverbuilder/builder/templates/opensuse.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ mkdir -p build && cd build
4848

4949
{{ if .BuildModule }}
5050
# Build the module
51-
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=$sourcedir driver
51+
make KERNELDIR=$sourcedir driver
5252
strip -g {{ .ModuleFullPath }}
5353
# Print results
5454
modinfo {{ .ModuleFullPath }}

pkg/driverbuilder/builder/templates/oracle.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ mkdir -p build && cd build
4545

4646
{{ if .BuildModule }}
4747
# Build the module
48-
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=/tmp/kernel driver
48+
make KERNELDIR=/tmp/kernel driver
4949
strip -g {{ .ModuleFullPath }}
5050
# Print results
5151
modinfo {{ .ModuleFullPath }}

pkg/driverbuilder/builder/templates/photonos.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ mkdir -p build && cd build
4848

4949
{{ if .BuildModule }}
5050
# Build the module
51-
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=/tmp/kernel driver
51+
make KERNELDIR=/tmp/kernel driver
5252
strip -g {{ .ModuleFullPath }}
5353
# Print results
5454
modinfo {{ .ModuleFullPath }}

pkg/driverbuilder/builder/templates/redhat.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ mkdir -p build && cd build
4747

4848
{{ if .BuildModule }}
4949
# Build the module
50-
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=/tmp/kernel driver
50+
make KERNELDIR=/tmp/kernel driver
5151
strip -g {{ .ModuleFullPath }}
5252
# Print results
5353
modinfo {{ .ModuleFullPath }}

pkg/driverbuilder/builder/templates/rocky.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ mkdir -p build && cd build
4545

4646
{{ if .BuildModule }}
4747
# Build the module
48-
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=/tmp/kernel driver
48+
make KERNELDIR=/tmp/kernel driver
4949
strip -g {{ .ModuleFullPath }}
5050
# Print results
5151
modinfo {{ .ModuleFullPath }}

pkg/driverbuilder/builder/templates/sles.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ mkdir -p build && cd build
5050

5151
{{ if .BuildModule }}
5252
# Build the module
53-
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=$sourcedir driver
53+
make KERNELDIR=$sourcedir driver
5454
strip -g {{ .ModuleFullPath }}
5555
# Print results
5656
modinfo {{ .ModuleFullPath }}

pkg/driverbuilder/builder/templates/ubuntu.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ mkdir -p build && cd build
4949

5050
{{ if .BuildModule }}
5151
# Build the module
52-
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=$sourcedir driver
52+
make KERNELDIR=$sourcedir driver
5353
strip -g {{ .ModuleFullPath }}
5454
# Print results
5555
modinfo {{ .ModuleFullPath }}

pkg/driverbuilder/builder/templates/vanilla.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ mkdir -p build && cd build
6262

6363
{{ if .BuildModule }}
6464
# Build the module
65-
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=/tmp/kernel driver
65+
make KERNELDIR=/tmp/kernel driver
6666
strip -g {{ .ModuleFullPath }}
6767
# Print results
6868
modinfo {{ .ModuleFullPath }}

0 commit comments

Comments
 (0)