// cgo and non-cgo worlds, so it necessarily has files in both.
// In that case gcc only gets the gcc_* files.
var gccfiles []string
+ gccfiles = append(gccfiles, cfiles...)
+ cfiles = nil
if a.p.Standard && a.p.ImportPath == "runtime/cgo" {
filter := func(files, nongcc, gcc []string) ([]string, []string) {
for _, f := range files {
}
return nongcc, gcc
}
- cfiles, gccfiles = filter(cfiles, cfiles[:0], gccfiles)
sfiles, gccfiles = filter(sfiles, sfiles[:0], gccfiles)
} else {
- gccfiles = append(cfiles, sfiles...)
- cfiles = nil
+ gccfiles = append(gccfiles, sfiles...)
sfiles = nil
}
tg.grepStdout(`\* another-branch`, "not on correct default branch")
}
-func TestDisallowedCSourceFiles(t *testing.T) {
- tg := testgo(t)
- defer tg.cleanup()
- tg.setenv("GOPATH", filepath.Join(tg.pwd(), "testdata"))
- tg.runFail("build", "badc")
- tg.grepStderr("C source files not allowed", "go test did not say C source files not allowed")
-}
-
func TestErrorMessageForSyntaxErrorInTestGoFileSaysFAIL(t *testing.T) {
tg := testgo(t)
defer tg.cleanup()
}
p.Target = p.target
+ // If cgo is not enabled, ignore cgo supporting sources
+ // just as we ignore go files containing import "C".
+ if !buildContext.CgoEnabled {
+ p.CFiles = nil
+ p.CXXFiles = nil
+ p.MFiles = nil
+ p.SwigFiles = nil
+ p.SwigCXXFiles = nil
+ p.SysoFiles = nil
+ // Note that SFiles are okay (they go to the Go assembler)
+ // and HFiles are okay (they might be used by the SFiles).
+ }
+
// The gc toolchain only permits C source files with cgo.
if len(p.CFiles) > 0 && !p.usesCgo() && !p.usesSwig() && buildContext.Compiler == "gc" {
p.Error = &PackageError{
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build cgo
-
#include <stdarg.h>
#include <android/log.h>
#include "libcgo.h"
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build cgo
-
#include <string.h> /* for strerror */
#include <pthread.h>
#include <signal.h>
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build cgo
-
#include <string.h> /* for strerror */
#include <pthread.h>
#include <signal.h>
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build cgo
-
#include <pthread.h>
#include <signal.h>
#include <stdio.h>
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build cgo
-
#include <pthread.h>
#include <signal.h>
#include <stdio.h>
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build cgo
-
#include <string.h> /* for strerror */
#include <pthread.h>
#include <signal.h>
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build cgo
-
#include <string.h> /* for strerror */
#include <pthread.h>
#include <signal.h>
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build cgo
-
#include <limits.h>
#include <pthread.h>
#include <signal.h>
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build cgo
-
#include <limits.h>
#include <pthread.h>
#include <signal.h>
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build cgo
-
#include <sys/types.h>
#include <sys/signalvar.h>
#include <pthread.h>
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build cgo
-
// +build !android,linux
#include <stdarg.h>
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build cgo
-
#include <sys/types.h>
#include <sys/signalvar.h>
#include <pthread.h>
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build cgo
-
#include <sys/types.h>
#include <sys/signalvar.h>
#include <pthread.h>
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build cgo
-
#include <sys/types.h>
#include <machine/sysarch.h>
#include <sys/signalvar.h>
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build cgo
-
// TODO: see issue #10410
// +build linux
// +build ppc64 ppc64le
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build cgo
-
#include <stdio.h>
#include <stdlib.h>
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build cgo
-
#include <stdio.h>
#include <stdlib.h>
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build cgo
-
#include <pthread.h>
#include <string.h>
#include <signal.h>
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build cgo
-
#include <pthread.h>
#include <errno.h>
#include <string.h> // strerror
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build cgo
-
#include <pthread.h>
#include <string.h>
#include <signal.h>
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build cgo
-
#include <pthread.h>
#include <string.h>
#include <signal.h>
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build cgo
-
// +build ppc64 ppc64le
#include <pthread.h>
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build cgo
-
// +build linux,amd64
#include <errno.h>
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build cgo
-
#include <sys/types.h>
#include <pthread.h>
#include <signal.h>
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build cgo
-
#include <sys/types.h>
#include <pthread.h>
#include <signal.h>
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build cgo
-
#include <sys/types.h>
#include <pthread.h>
#include <signal.h>
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build cgo
-
#include <sys/types.h>
#include <dlfcn.h>
#include <errno.h>
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build cgo
-
#include <sys/types.h>
#include <dlfcn.h>
#include <errno.h>
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build cgo
-
// Emulation of the Unix signal SIGSEGV.
//
// On iOS, Go tests and apps under development are run by lldb.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build cgo
-
// +build !lldb
// +build darwin
// +build arm arm64
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build cgo
-
#include <pthread.h>
#include <string.h>
#include <signal.h>
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build cgo
-
#include "libcgo.h"
/* Stub for calling malloc from Go */
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build cgo
-
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <process.h>
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build cgo
-
#define WIN64_LEAN_AND_MEAN
#include <windows.h>
#include <process.h>