From e49a71c6b4816329720ebec3eed3523259e604bb Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Mon, 17 May 2021 15:16:25 +0000 Subject: sys/syz-extract: clean up const generation on FreeBSD * Create the correct machine symlink on non-amd64 architectures * Remove an unneeded amd64 include directory * Pass the compiler and C flags from the target to the compiler --- sys/syz-extract/freebsd.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sys/syz-extract/freebsd.go b/sys/syz-extract/freebsd.go index 0c3e8fd8d..f1537e2a0 100644 --- a/sys/syz-extract/freebsd.go +++ b/sys/syz-extract/freebsd.go @@ -25,7 +25,12 @@ func (*freebsd) prepare(sourcedir string, build bool, arches []*Arch) error { } func (*freebsd) prepareArch(arch *Arch) error { - if err := os.Symlink(filepath.Join(arch.sourceDir, "sys", "amd64", "include"), + archName := arch.target.Arch + // Use the the correct name for FreeBSD/i386 + if archName == "386" { + archName = "i386" + } + if err := os.Symlink(filepath.Join(arch.sourceDir, "sys", archName, "include"), filepath.Join(arch.buildDir, "machine")); err != nil { return fmt.Errorf("failed to create link: %v", err) } @@ -45,7 +50,6 @@ func (*freebsd) processFile(arch *Arch, info *compiler.ConstInfo) (map[string]ui "-D__BSD_VISIBLE=1", "-I", filepath.Join(arch.sourceDir, "sys"), "-I", filepath.Join(arch.sourceDir, "sys", "sys"), - "-I", filepath.Join(arch.sourceDir, "sys", "amd64"), "-I", arch.buildDir, } for _, incdir := range info.Incdirs { @@ -56,10 +60,12 @@ func (*freebsd) processFile(arch *Arch, info *compiler.ConstInfo) (map[string]ui args = append(args, "-I"+dir) } } + args = append(args, arch.target.CFlags...) params := &extractParams{ AddSource: "#include ", DeclarePrintf: true, TargetEndian: arch.target.HostEndian, } - return extract(info, "gcc", args, params) + cc := arch.target.CCompiler + return extract(info, cc, args, params) } -- cgit mrf-deployment