From e36b2ae53da11f462646204bce64349b0898a340 Mon Sep 17 00:00:00 2001 From: Michael Tuexen Date: Tue, 12 May 2020 23:06:08 +0200 Subject: sys/targets: fix tests when building on FreeBSD gmake test is failing on FreeBSD since switching to clang. To address this: * use g++ as the C preprocessor for now. * use a C compiler for compiling C sources and add -lc++ when compiling executor.cc. Without this, clang warns about using a C++ compiler for compiling C code. * some test configs add -no-pie, which is not used by clang. Add -Wno-unused-command-line-argument to silence a warning --- sys/targets/targets.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'sys') diff --git a/sys/targets/targets.go b/sys/targets/targets.go index 32a04e495..6a66d91f7 100644 --- a/sys/targets/targets.go +++ b/sys/targets/targets.go @@ -195,8 +195,8 @@ var List = map[string]map[string]*Target{ "amd64": { PtrSize: 8, PageSize: 4 << 10, - CCompiler: "c++", - CFlags: []string{"-m64", "-static"}, + CCompiler: "clang", + CFlags: []string{"-m64"}, NeedSyscallDefine: dontNeedSyscallDefine, }, "386": { @@ -204,8 +204,8 @@ var List = map[string]map[string]*Target{ PtrSize: 4, PageSize: 4 << 10, Int64Alignment: 4, - CCompiler: "c++", - CFlags: []string{"-m32", "-static"}, + CCompiler: "clang", + CFlags: []string{"-m32"}, NeedSyscallDefine: dontNeedSyscallDefine, }, }, @@ -344,6 +344,8 @@ var oses = map[string]osCommon{ ExecutorUsesShmem: true, ExecutorUsesForkServer: true, KernelObject: "kernel.full", + CPP: "g++", + cflags: []string{"-static", "-lc++"}, }, "netbsd": { BuildOS: "linux", @@ -425,6 +427,12 @@ func init() { if host := List[goos][runtime.GOARCH]; host != nil { target.CCompiler = host.CCompiler target.CPP = host.CPP + if goos == "freebsd" { + // For some configurations -no-pie is passed to the compiler, + // which is not used by clang. + // Ensure clang does not complain about it. + target.CFlags = append(target.CFlags, "-Wno-unused-command-line-argument") + } } } target.BuildOS = goos -- cgit mrf-deployment