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

cmd/cgo: can not include header file in package directory with Go 1.12beta1 #29333

Closed
nussjustin opened this issue Dec 19, 2018 · 3 comments

Comments

@nussjustin
Copy link
Contributor

commented Dec 19, 2018

What did you do?

Tried do get and build crawshaw.io/sqlite using go get with and without modules.

What did you expect to see?

No error.

What did you see instead?

With modules:

rm -rf $HOME/.cache/go-build && rm -rf /tmp/modtest && mkdir -p /tmp/modtest && cd /tmp/modtest && go1.12beta1 mod init test && go1.12beta1 get -a crawshaw.io/sqlite

Without modules:

rm -rf $HOME/.cache/go-build && rm -rf /tmp/gopath && mkdir /tmp/gopath && GOPATH=/tmp/gopath go1.12beta1 get -a crawshaw.io/sqlite

Output:

# crawshaw.io/sqlite
gcc did not produce error at completed:1
on input:

#line 1 "cgo-builtin-prolog"
#include <stddef.h> /* for ptrdiff_t and size_t below */

/* Define intgo when compiling with GCC.  */
typedef ptrdiff_t intgo;

#define GO_CGO_GOSTRING_TYPEDEF
typedef struct { const char *p; intgo n; } _GoString_;
typedef struct { char *p; intgo n; intgo c; } _GoBytes_;
_GoString_ GoString(char *p);
_GoString_ GoStringN(char *p, int l);
_GoBytes_ GoBytes(void *p, int n);
char *CString(_GoString_);
void *CBytes(_GoBytes_);
void *_CMalloc(size_t);

__attribute__ ((unused))
static size_t _GoStringLen(_GoString_ s) { return (size_t)s.n; }

__attribute__ ((unused))
static const char *_GoStringPtr(_GoString_ s) { return s.p; }
#line 17 "/tmp/gopath/src/crawshaw.io/sqlite/blob.go"
 #include <blocking_step.h>
 #include <sqlite3.h>
 #include <stdlib.h>
 #include <stdint.h>

#line 1 "cgo-generated-wrapper"
#line 1 "not-declared"
void __cgo_f_1_1(void) { __typeof__(CString) *__cgo_undefined__1; }
#line 1 "not-type"
void __cgo_f_1_2(void) { CString *__cgo_undefined__2; }
#line 1 "not-int-const"
void __cgo_f_1_3(void) { enum { __cgo_undefined__3 = (CString)*1 }; }
#line 1 "not-num-const"
void __cgo_f_1_4(void) { static const double __cgo_undefined__4 = (CString); }
#line 1 "not-str-lit"
void __cgo_f_1_5(void) { static const char __cgo_undefined__5[] = (CString); }
#line 2 "not-declared"
void __cgo_f_2_1(void) { __typeof__(SQLITE_LOCKED_SHAREDCACHE) *__cgo_undefined__1; }
#line 2 "not-type"
void __cgo_f_2_2(void) { SQLITE_LOCKED_SHAREDCACHE *__cgo_undefined__2; }
#line 2 "not-int-const"
void __cgo_f_2_3(void) { enum { __cgo_undefined__3 = (SQLITE_LOCKED_SHAREDCACHE)*1 }; }
#line 2 "not-num-const"
void __cgo_f_2_4(void) { static const double __cgo_undefined__4 = (SQLITE_LOCKED_SHAREDCACHE); }
#line 2 "not-str-lit"
void __cgo_f_2_5(void) { static const char __cgo_undefined__5[] = (SQLITE_LOCKED_SHAREDCACHE); }
#line 3 "not-declared"
void __cgo_f_3_1(void) { __typeof__(char) *__cgo_undefined__1; }
#line 3 "not-type"
void __cgo_f_3_2(void) { char *__cgo_undefined__2; }
#line 3 "not-int-const"
void __cgo_f_3_3(void) { enum { __cgo_undefined__3 = (char)*1 }; }
#line 3 "not-num-const"
void __cgo_f_3_4(void) { static const double __cgo_undefined__4 = (char); }
#line 3 "not-str-lit"
void __cgo_f_3_5(void) { static const char __cgo_undefined__5[] = (char); }
#line 4 "not-declared"
void __cgo_f_4_1(void) { __typeof__(free) *__cgo_undefined__1; }
#line 4 "not-type"
void __cgo_f_4_2(void) { free *__cgo_undefined__2; }
#line 4 "not-int-const"
void __cgo_f_4_3(void) { enum { __cgo_undefined__3 = (free)*1 }; }
#line 4 "not-num-const"
void __cgo_f_4_4(void) { static const double __cgo_undefined__4 = (free); }
#line 4 "not-str-lit"
void __cgo_f_4_5(void) { static const char __cgo_undefined__5[] = (free); }
#line 5 "not-declared"
void __cgo_f_5_1(void) { __typeof__(int) *__cgo_undefined__1; }
#line 5 "not-type"
void __cgo_f_5_2(void) { int *__cgo_undefined__2; }
#line 5 "not-int-const"
void __cgo_f_5_3(void) { enum { __cgo_undefined__3 = (int)*1 }; }
#line 5 "not-num-const"
void __cgo_f_5_4(void) { static const double __cgo_undefined__4 = (int); }
#line 5 "not-str-lit"
void __cgo_f_5_5(void) { static const char __cgo_undefined__5[] = (int); }
#line 6 "not-declared"
void __cgo_f_6_1(void) { __typeof__(sqlite3_blob) *__cgo_undefined__1; }
#line 6 "not-type"
void __cgo_f_6_2(void) { sqlite3_blob *__cgo_undefined__2; }
#line 6 "not-int-const"
void __cgo_f_6_3(void) { enum { __cgo_undefined__3 = (sqlite3_blob)*1 }; }
#line 6 "not-num-const"
void __cgo_f_6_4(void) { static const double __cgo_undefined__4 = (sqlite3_blob); }
#line 6 "not-str-lit"
void __cgo_f_6_5(void) { static const char __cgo_undefined__5[] = (sqlite3_blob); }
#line 7 "not-declared"
void __cgo_f_7_1(void) { __typeof__(sqlite3_blob_bytes) *__cgo_undefined__1; }
#line 7 "not-type"
void __cgo_f_7_2(void) { sqlite3_blob_bytes *__cgo_undefined__2; }
#line 7 "not-int-const"
void __cgo_f_7_3(void) { enum { __cgo_undefined__3 = (sqlite3_blob_bytes)*1 }; }
#line 7 "not-num-const"
void __cgo_f_7_4(void) { static const double __cgo_undefined__4 = (sqlite3_blob_bytes); }
#line 7 "not-str-lit"
void __cgo_f_7_5(void) { static const char __cgo_undefined__5[] = (sqlite3_blob_bytes); }
#line 8 "not-declared"
void __cgo_f_8_1(void) { __typeof__(sqlite3_blob_close) *__cgo_undefined__1; }
#line 8 "not-type"
void __cgo_f_8_2(void) { sqlite3_blob_close *__cgo_undefined__2; }
#line 8 "not-int-const"
void __cgo_f_8_3(void) { enum { __cgo_undefined__3 = (sqlite3_blob_close)*1 }; }
#line 8 "not-num-const"
void __cgo_f_8_4(void) { static const double __cgo_undefined__4 = (sqlite3_blob_close); }
#line 8 "not-str-lit"
void __cgo_f_8_5(void) { static const char __cgo_undefined__5[] = (sqlite3_blob_close); }
#line 9 "not-declared"
void __cgo_f_9_1(void) { __typeof__(sqlite3_blob_open) *__cgo_undefined__1; }
#line 9 "not-type"
void __cgo_f_9_2(void) { sqlite3_blob_open *__cgo_undefined__2; }
#line 9 "not-int-const"
void __cgo_f_9_3(void) { enum { __cgo_undefined__3 = (sqlite3_blob_open)*1 }; }
#line 9 "not-num-const"
void __cgo_f_9_4(void) { static const double __cgo_undefined__4 = (sqlite3_blob_open); }
#line 9 "not-str-lit"
void __cgo_f_9_5(void) { static const char __cgo_undefined__5[] = (sqlite3_blob_open); }
#line 10 "not-declared"
void __cgo_f_10_1(void) { __typeof__(sqlite3_blob_read) *__cgo_undefined__1; }
#line 10 "not-type"
void __cgo_f_10_2(void) { sqlite3_blob_read *__cgo_undefined__2; }
#line 10 "not-int-const"
void __cgo_f_10_3(void) { enum { __cgo_undefined__3 = (sqlite3_blob_read)*1 }; }
#line 10 "not-num-const"
void __cgo_f_10_4(void) { static const double __cgo_undefined__4 = (sqlite3_blob_read); }
#line 10 "not-str-lit"
void __cgo_f_10_5(void) { static const char __cgo_undefined__5[] = (sqlite3_blob_read); }
#line 11 "not-declared"
void __cgo_f_11_1(void) { __typeof__(sqlite3_blob_write) *__cgo_undefined__1; }
#line 11 "not-type"
void __cgo_f_11_2(void) { sqlite3_blob_write *__cgo_undefined__2; }
#line 11 "not-int-const"
void __cgo_f_11_3(void) { enum { __cgo_undefined__3 = (sqlite3_blob_write)*1 }; }
#line 11 "not-num-const"
void __cgo_f_11_4(void) { static const double __cgo_undefined__4 = (sqlite3_blob_write); }
#line 11 "not-str-lit"
void __cgo_f_11_5(void) { static const char __cgo_undefined__5[] = (sqlite3_blob_write); }
#line 12 "not-declared"
void __cgo_f_12_1(void) { __typeof__(sqlite3_int64) *__cgo_undefined__1; }
#line 12 "not-type"
void __cgo_f_12_2(void) { sqlite3_int64 *__cgo_undefined__2; }
#line 12 "not-int-const"
void __cgo_f_12_3(void) { enum { __cgo_undefined__3 = (sqlite3_int64)*1 }; }
#line 12 "not-num-const"
void __cgo_f_12_4(void) { static const double __cgo_undefined__4 = (sqlite3_int64); }
#line 12 "not-str-lit"
void __cgo_f_12_5(void) { static const char __cgo_undefined__5[] = (sqlite3_int64); }
#line 13 "not-declared"
void __cgo_f_13_1(void) { __typeof__(wait_for_unlock_notify) *__cgo_undefined__1; }
#line 13 "not-type"
void __cgo_f_13_2(void) { wait_for_unlock_notify *__cgo_undefined__2; }
#line 13 "not-int-const"
void __cgo_f_13_3(void) { enum { __cgo_undefined__3 = (wait_for_unlock_notify)*1 }; }
#line 13 "not-num-const"
void __cgo_f_13_4(void) { static const double __cgo_undefined__4 = (wait_for_unlock_notify); }
#line 13 "not-str-lit"
void __cgo_f_13_5(void) { static const char __cgo_undefined__5[] = (wait_for_unlock_notify); }
#line 1 "completed"
int __cgo__1 = __cgo__2;

full error output:
/tmp/gopath/src/crawshaw.io/sqlite/blob.go:17:11: fatal error: blocking_step.h: No such file or directory
 // #include <blocking_step.h>
           ^~~~~~~~~~~~~~~~~
compilation terminated.

Does this issue reproduce with the latest release (go1.11.4)?

No. Using the go1.11.4 tool instead of the go1.12beta1 tool works both with and without modules.

Using the Go 1.11.4 snap also works.

System details

go version go1.12beta1 linux/amd64
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/justinn/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/justinn/.gopath"
GOPROXY=""
GORACE=""
GOROOT="/home/justinn/sdk/go1.12beta1"
GOTMPDIR=""
GOTOOLDIR="/home/justinn/sdk/go1.12beta1/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
GOROOT/bin/go version: go version go1.12beta1 linux/amd64
GOROOT/bin/go tool compile -V: compile version go1.12beta1
uname -sr: Linux 4.19.4-arch1-1-ARCH
LSB Version:	1.4
Distributor ID:	Antergos
Description:	Antergos Linux
Release:	rolling
Codename:	n/a
/usr/lib/libc.so.6: GNU C Library (GNU libc) stable release version 2.28.
lldb --version: lldb version 7.0.1
gdb --version: GNU gdb (GDB) 8.2
@AlexRouSg

This comment has been minimized.

Copy link
Contributor

commented Dec 19, 2018

Looks like the issue is with using #include <...>
If you changed it to #include "blocking_step.h" which searches the source directory instead it compiles fine.

cc @ianlancetaylor

@nussjustin

This comment has been minimized.

Copy link
Contributor Author

commented Dec 19, 2018

git bisect points to eeb8aeb

@gopherbot

This comment has been minimized.

Copy link

commented Dec 19, 2018

Change https://golang.org/cl/155037 mentions this issue: cmd/cgo: ensure the command passed to run retains a trailing dash

@gopherbot gopherbot closed this in d9e2ba4 Dec 19, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.