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/go: error: pointer is missing a nullability type specifier when building on catalina #35247

Closed
Tochemey opened this issue Oct 30, 2019 · 14 comments

Comments

@Tochemey
Copy link

@Tochemey Tochemey commented Oct 30, 2019

What version of Go are you using (go version)?

$ go version
go version go1.13.3 darwin/amd64

Does this issue reproduce with the latest release?

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/arsenegandote/Library/Caches/go-build"
GOENV="/Users/arsenegandote/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/arsenegandote/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.13.3/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.13.3/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/_9/v2g8jyjj051bj38hln17lchw0000gn/T/go-build584306134=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

go test -mod=vendor

What did you expect to see?

At least the test should run

What did you see instead?

runtime/cgo

In file included from _cgo_export.c:3:
/usr/local/include/stdlib.h:134:25: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
/usr/local/include/stdlib.h:134:25: note: insert '_Nullable' if the pointer may be null
/usr/local/include/stdlib.h:134:25: note: insert '_Nonnull' if the pointer should never be null
/usr/local/include/stdlib.h:135:22: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
/usr/local/include/stdlib.h:135:22: note: insert '_Nullable' if the pointer may be null
/usr/local/include/stdlib.h:135:22: note: insert '_Nonnull' if the pointer should never be null
/usr/local/include/stdlib.h:136:23: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
/usr/local/include/stdlib.h:136:23: note: insert '_Nullable' if the pointer may be null
/usr/local/include/stdlib.h:136:23: note: insert '_Nonnull' if the pointer should never be null
/usr/local/include/stdlib.h:139:20: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
/usr/local/include/stdlib.h:139:20: note: insert '_Nullable' if the pointer may be null
/usr/local/include/stdlib.h:139:20: note: insert '_Nonnull' if the pointer should never be null
/usr/local/include/stdlib.h:141:26: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
/usr/local/include/stdlib.h:141:26: note: insert '_Nullable' if the pointer may be null
/usr/local/include/stdlib.h:141:26: note: insert '_Nonnull' if the pointer should never be null
/usr/local/include/stdlib.h:141:45: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
/usr/local/include/stdlib.h:141:45: note: insert '_Nullable' if the pointer may be null
/usr/local/include/stdlib.h:141:45: note: insert '_Nonnull' if the pointer should never be null
/usr/local/include/stdlib.h:142:59: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
/usr/local/include/stdlib.h:142:59: note: insert '_Nullable' if the pointer may be null
/usr/local/include/stdlib.h:142:59: note: insert '_Nonnull' if the pointer should never be null
/usr/local/include/stdlib.h:142:73: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
/usr/local/include/stdlib.h:142:73: note: insert '_Nullable' if the pointer may be null
/usr/local/include/stdlib.h:142:73: note: insert '_Nonnull' if the pointer should never be null
/usr/local/include/stdlib.h:141:6: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
/usr/local/include/stdlib.h:141:6: note: insert '_Nullable' if the pointer may be null
/usr/local/include/stdlib.h:141:6: note: insert '_Nonnull' if the pointer should never be null
/usr/local/include/stdlib.h:147:25: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
/usr/local/include/stdlib.h:147:25: note: insert '_Nullable' if the pointer may be null
/usr/local/include/stdlib.h:147:25: note: insert '_Nonnull' if the pointer should never be null
/usr/local/include/stdlib.h:147:6: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
/usr/local/include/stdlib.h:147:6: note: insert '_Nullable' if the pointer may be null
/usr/local/include/stdlib.h:147:6: note: insert '_Nonnull' if the pointer should never be null
/usr/local/include/stdlib.h:156:23: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
/usr/local/include/stdlib.h:156:23: note: insert '_Nullable' if the pointer may be null
/usr/local/include/stdlib.h:156:23: note: insert '_Nonnull' if the pointer should never be null
/usr/local/include/stdlib.h:157:26: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
/usr/local/include/stdlib.h:157:26: note: insert '_Nullable' if the pointer may be null
/usr/local/include/stdlib.h:157:26: note: insert '_Nonnull' if the pointer should never be null
/usr/local/include/stdlib.h:157:52: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
/usr/local/include/stdlib.h:157:52: note: insert '_Nullable' if the pointer may be null
/usr/local/include/stdlib.h:157:52: note: insert '_Nonnull' if the pointer should never be null
/usr/local/include/stdlib.h:158:21: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
/usr/local/include/stdlib.h:158:21: note: insert '_Nullable' if the pointer may be null
/usr/local/include/stdlib.h:158:21: note: insert '_Nonnull' if the pointer should never be null
/usr/local/include/stdlib.h:158:46: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
/usr/local/include/stdlib.h:158:46: note: insert '_Nullable' if the pointer may be null
/usr/local/include/stdlib.h:158:46: note: insert '_Nonnull' if the pointer should never be null
/usr/local/include/stdlib.h:160:18: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
/usr/local/include/stdlib.h:160:18: note: insert '_Nullable' if the pointer may be null
/usr/local/include/stdlib.h:160:18: note: insert '_Nonnull' if the pointer should never be null
/usr/local/include/stdlib.h:161:43: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
/usr/local/include/stdlib.h:161:43: note: insert '_Nullable' if the pointer may be null
/usr/local/include/stdlib.h:161:43: note: insert '_Nonnull' if the pointer should never be null
/usr/local/include/stdlib.h:161:57: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
/usr/local/include/stdlib.h:161:57: note: insert '_Nullable' if the pointer may be null
/usr/local/include/stdlib.h:161:57: note: insert '_Nonnull' if the pointer should never be null
fatal error: too many errors emitted, stopping now [-ferror-limit=]

Compilation finished with exit code 2

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Oct 30, 2019

Has clang really decided to enable the -Wnullability-completeness warning by default, as suggested by https://bcain-llvm.readthedocs.io/projects/clang/en/latest/DiagnosticsReference/#wnullability-completeness ? That seems designed to break all existing code. I must be missing something.

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Oct 30, 2019

Note that these warnings are for /usr/local/include/stdlib.h, which does not come from Go. Is that the version of stdlib.h that corresponds to the C compiler that you are using?

@andybons andybons added this to the Unplanned milestone Oct 30, 2019
@andybons andybons changed the title go build issue on macos catalina cmd/go: build issue on macos catalina Oct 30, 2019
@Tochemey

This comment has been minimized.

Copy link
Author

@Tochemey Tochemey commented Oct 30, 2019

@ianlancetaylor I cannot really tell. I just did an upgrade to catalina and installed golang. So when I try to build I got the error. During the installation I did not get any errors that could have given a hint.

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Oct 30, 2019

Unless someone else is seeing this problem on catalina, I suspect this is a problem with the installation on your system.

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Oct 30, 2019

Sorry, I mean a problem with the XCode installation. I don't see a reason to think that there is anything wrong with the Go installation.

@42yeah

This comment has been minimized.

Copy link

@42yeah 42yeah commented Oct 31, 2019

Had the same problem. Upgraded to catalina and this appears:

# runtime/cgo
In file included from _cgo_export.c:3:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdlib.h:134:25: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
...

Also tried using clang to compile some random source including stdlib.h, and it did it gave out bunches of warnings almost identical to the above, however those weren't error, only warnings:

❯ clang a.c
In file included from a.c:1:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdlib.h:134:25: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
double   atof(const char *);
...
@dust347

This comment has been minimized.

Copy link

@dust347 dust347 commented Oct 31, 2019

I also have same problem after upgrade to catalina

export CGO_CPPFLAGS="-Wno-error -Wno-nullability-completeness -Wno-expansion-to-defined"

Maybe it can be solved

@ALTree ALTree changed the title cmd/go: build issue on macos catalina cmd/go: error: pointer is missing a nullability type specifier when building on catalina Oct 31, 2019
@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Nov 1, 2019

I don't understand how XCode could possibly be shipping a <stdlib.h> that cannot be compiled without warnings in the default compiler setting. Can somebody investigate that? What happens if you simply compile the C program

#include <stdlib.h>

? Do you get warnings?

@yiyanwannian

This comment has been minimized.

Copy link

@yiyanwannian yiyanwannian commented Nov 4, 2019

Encounter same issue

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Nov 4, 2019

@yiyanwannian Please see my question in #35247 (comment) which has not yet been answered. Thanks.

@42yeah

This comment has been minimized.

Copy link

@42yeah 42yeah commented Nov 5, 2019

@ianlancetaylor Please see my comment above. And here's the content of a.c:

#include <stdlib.h>

int main() {

  return 0;
}

It has the same problem when being compiled, however those were only warnings. When in cgo, those became errors.

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Nov 5, 2019

I'm sorry, somehow I missed that comment.

If clang is emitting a lot of warnings for code that simply includes <stdlib.h>, I can't help but feel that that is a problem with the installation.

I see this issue raised for C code on Stack Overflow at https://stackoverflow.com/questions/58429844/c-multiple-warnings-pointer-is-missing-a-nullability-type-specifier-when-com .

This just seems to me like something that Apple has to fix.

In the meantime see if https://golang.org/cl/205457 fixes the problems.

@bradfitz

This comment has been minimized.

Copy link
Member

@bradfitz bradfitz commented Nov 5, 2019

A Catalina builder would've caught this (#34748).

@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Nov 5, 2019

Change https://golang.org/cl/205457 mentions this issue: runtime/cgo: add -Wno-nullability-completeness on Darwin

@gopherbot gopherbot closed this in fb37821 Nov 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
8 participants
You can’t perform that action at this time.