Clang v12 throws errors with implicit declarations
Overview
clang
version 12 introduced raising errors for implicit declarations
Version 12 will ship with Mac OS Big Sur so this will cause issues with gdk install
and bundle install
A workaround is to run bundle install
then explicitly install the failed gems with build flags. For example:
gem install gitlab-puma:4.3.3.gitlab.2 -- --with-cflags="-Wno-error=implicit-function-declaration"
Known problem gems so far are:
- pg
- gitlab-puma
- thin
- rbtrace
Example stack trace
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.current directory: /.asdf/installs/ruby/2.6.6/lib/ruby/gems/2.6.0/gems/gitlab-puma-4.3.3.gitlab.2/ext/puma_http11
/.asdf/installs/ruby/2.6.6/bin/ruby -I /.asdf/installs/ruby/2.6.6/lib/ruby/2.6.0 -r ./siteconf20200819-27087-1bb8em3.rb extconf.rb checking for BIO_read() in -lcrypto... yes checking for SSL_CTX_new() in -lssl... yes checking for openssl/bio.h... yes checking for DTLS_method() in openssl/ssl.h... yes checking for TLS_server_method() in openssl/ssl.h... yes checking for SSL_CTX_set_min_proto_version in openssl/ssl.h... yes creating Makefile
current directory: /.asdf/installs/ruby/2.6.6/lib/ruby/gems/2.6.0/gems/gitlab-puma-4.3.3.gitlab.2/ext/puma_http11 make "DESTDIR=" clean
current directory: /.asdf/installs/ruby/2.6.6/lib/ruby/gems/2.6.0/gems/gitlab-puma-4.3.3.gitlab.2/ext/puma_http11 make "DESTDIR=" compiling http11_parser.c ext/puma_http11/http11_parser.c:44:18: warning: unused variable 'puma_parser_en_main' [-Wunused-const-variable] static const int puma_parser_en_main = 1; ^ 1 warning generated. compiling io_buffer.c compiling mini_ssl.c mini_ssl.c:145:7: warning: unused variable 'min' [-Wunused-variable] int min, ssl_options; ^ mini_ssl.c:299:40: warning: function 'raise_error' could be declared with attribute 'noreturn' [-Wmissing-noreturn] void raise_error(SSL* ssl, int result) { ^ 2 warnings generated. compiling puma_http11.c puma_http11.c:203:22: error: implicitly declaring library function 'isspace' with type 'int (int)' [-Werror,-Wimplicit-function-declaration] while (vlen > 0 && isspace(value[vlen - 1])) vlen--; ^ puma_http11.c:203:22: note: include the header <ctype.h> or explicitly provide a declaration for 'isspace' 1 error generated. make: *** [puma_http11.o] Error 1
make failed, exit code 2
Gem files will remain installed in /.asdf/installs/ruby/2.6.6/lib/ruby/gems/2.6.0/gems/gitlab-puma-4.3.3.gitlab.2 for inspection. Results logged to /.asdf/installs/ruby/2.6.6/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-19/2.6.0/gitlab-puma-4.3.3.gitlab.2/gem_make.out
An error occurred while installing gitlab-puma (4.3.3.gitlab.2), and Bundler cannot continue.
Make sure that gem install gitlab-puma -v '4.3.3.gitlab.2' --source 'https://rubygems.org/'
succeeds before bundling.
In Gemfile: gitlab-puma_worker_killer was resolved to 0.1.1.gitlab.1, which depends on gitlab-puma
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /.asdf/installs/ruby/2.6.6/lib/ruby/gems/2.6.0/gems/rbtrace-0.4.11/ext
/.asdf/installs/ruby/2.6.6/bin/ruby -I /.asdf/installs/ruby/2.6.6/lib/ruby/2.6.0 -r ./siteconf20200819-27087-1mmm4oi.rb extconf.rb -- tar zxvfo msgpack-1.1.0.tar.gz -- env CFLAGS=nil LDFLAGS=nil CC=nil -- ./configure --disable-dependency-tracking --disable-shared --with-pic --prefix=/.asdf/installs/ruby/2.6.6/lib/ruby/gems/2.6.0/gems/rbtrace-0.4.11/ext/dst/ --libdir=/.asdf/installs/ruby/2.6.6/lib/ruby/gems/2.6.0/gems/rbtrace-0.4.11/ext/dst/lib -- make install checking for -lmsgpackc_ext... yes checking for msgpack.h... yes checking for rb_during_gc() in ruby.h... yes checking for rb_gc_add_event_hook() in ruby.h,node.h... no checking for rb_postponed_job_register_one() in ruby.h... yes creating Makefile
current directory: /.asdf/installs/ruby/2.6.6/lib/ruby/gems/2.6.0/gems/rbtrace-0.4.11/ext make "DESTDIR=" clean
current directory: /.asdf/installs/ruby/2.6.6/lib/ruby/gems/2.6.0/gems/rbtrace-0.4.11/ext make "DESTDIR=" compiling rbtrace.c rbtrace.c:253:11: warning: implicit conversion loses integer precision: 'ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32] ret = sendto( ~ ^~~~~~~ rbtrace.c:359:38: warning: comparison of integers of different signs: 'int' and 'unsigned int' [-Wsign-compare] for (i=0, n=0; i<MAX_TRACERS && n<rbtracer.num; i++) { ~^~~~~~~~~~~~~ rbtrace.c:855:22: warning: implicit conversion loses integer precision: 'unsigned long' to 'socklen_t' (aka 'unsigned int') [-Wshorten-64-to-32] rbtracer.mqo_len = SUN_LEN(&rbtracer.mqo_addr); ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~ /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/un.h:101:42: note: expanded from macro 'SUN_LEN' (sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path)) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ rbtrace.c:922:40: warning: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'unsigned int' [-Wshorten-64-to-32] unsigned int msec = ary.ptr[1].via.u64; ~~~~ ~~~~~~~~~~~~~~~^~~ rbtrace.c:1048:13: warning: implicit conversion loses integer precision: 'ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32] ret = msgrcv(rbtracer.mqi_id, &msg, sizeof(msg)-sizeof(long), 0, IPC_NOWAIT); ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ rbtrace.c:1082:3: error: implicit declaration of function 'rb_postponed_job_register_one' is invalid in C99 [-Werror,-Wimplicit-function-declaration] rb_postponed_job_register_one(0, rbtrace__receive, 0); ^ 5 warnings and 1 error generated. make: *** [rbtrace.o] Error 1
make failed, exit code 2
Gem files will remain installed in /.asdf/installs/ruby/2.6.6/lib/ruby/gems/2.6.0/gems/rbtrace-0.4.11 for inspection. Results logged to /.asdf/installs/ruby/2.6.6/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-19/2.6.0/rbtrace-0.4.11/gem_make.out
An error occurred while installing rbtrace (0.4.11), and Bundler cannot continue.
Make sure that gem install rbtrace -v '0.4.11' --source 'https://rubygems.org/'
succeeds before bundling.
In Gemfile: rbtrace
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /.asdf/installs/ruby/2.6.6/lib/ruby/gems/2.6.0/gems/thin-1.7.2/ext/thin_parser
/.asdf/installs/ruby/2.6.6/bin/ruby -I /.asdf/installs/ruby/2.6.6/lib/ruby/2.6.0 -r ./siteconf20200819-27087-1mb4b02.rb extconf.rb checking for main() in -lc... yes creating Makefile
current directory: /.asdf/installs/ruby/2.6.6/lib/ruby/gems/2.6.0/gems/thin-1.7.2/ext/thin_parser make "DESTDIR=" clean
current directory: /.asdf/installs/ruby/2.6.6/lib/ruby/gems/2.6.0/gems/thin-1.7.2/ext/thin_parser make "DESTDIR=" compiling parser.c parser.c:31:18: warning: unused variable 'http_parser_en_main' [-Wunused-const-variable] static const int http_parser_en_main = 1; ^ 1 warning generated. compiling thin.c thin.c:242:3: error: implicit declaration of function 'thin_http_parser_init' is invalid in C99 [-Werror,-Wimplicit-function-declaration] thin_http_parser_init(hp); ^ thin.c:242:3: note: did you mean 'http_parser_init'? ./parser.h:41:5: note: 'http_parser_init' declared here int http_parser_init(http_parser *parser); ^ thin.c:260:3: error: implicit declaration of function 'thin_http_parser_init' is invalid in C99 [-Werror,-Wimplicit-function-declaration] thin_http_parser_init(http); ^ thin.c:277:3: error: implicit declaration of function 'thin_http_parser_init' is invalid in C99 [-Werror,-Wimplicit-function-declaration] thin_http_parser_init(http); ^ thin.c:294:3: error: implicit declaration of function 'thin_http_parser_finish' is invalid in C99 [-Werror,-Wimplicit-function-declaration] thin_http_parser_finish(http); ^ thin.c:294:3: note: did you mean 'Thin_HttpParser_finish'? thin.c:290:7: note: 'Thin_HttpParser_finish' declared here VALUE Thin_HttpParser_finish(VALUE self) ^ thin.c:296:10: error: implicit declaration of function 'thin_http_parser_is_finished' is invalid in C99 [-Werror,-Wimplicit-function-declaration] return thin_http_parser_is_finished(http) ? Qtrue : Qfalse; ^ thin.c:334:5: error: implicit declaration of function 'thin_http_parser_execute' is invalid in C99 [-Werror,-Wimplicit-function-declaration] thin_http_parser_execute(http, dptr, dlen, from); ^ thin.c:334:5: note: did you mean 'Thin_HttpParser_execute'? thin.c:317:7: note: 'Thin_HttpParser_execute' declared here VALUE Thin_HttpParser_execute(VALUE self, VALUE req_hash, VALUE data, VALUE start) ^ thin.c:338:8: error: implicit declaration of function 'thin_http_parser_has_error' is invalid in C99 [-Werror,-Wimplicit-function-declaration] if(thin_http_parser_has_error(http)) { ^ thin.c:338:8: note: did you mean 'http_parser_has_error'? ./parser.h:44:5: note: 'http_parser_has_error' declared here int http_parser_has_error(http_parser *parser); ^ thin.c:359:10: error: implicit declaration of function 'thin_http_parser_has_error' is invalid in C99 [-Werror,-Wimplicit-function-declaration] return thin_http_parser_has_error(http) ? Qtrue : Qfalse; ^ thin.c:374:10: error: implicit declaration of function 'thin_http_parser_is_finished' is invalid in C99 [-Werror,-Wimplicit-function-declaration] return thin_http_parser_is_finished(http) ? Qtrue : Qfalse; ^ 9 errors generated. make: *** [thin.o] Error 1
make failed, exit code 2
Gem files will remain installed in /.asdf/installs/ruby/2.6.6/lib/ruby/gems/2.6.0/gems/thin-1.7.2 for inspection. Results logged to /.asdf/installs/ruby/2.6.6/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-19/2.6.0/thin-1.7.2/gem_make.out
An error occurred while installing thin (1.7.2), and Bundler cannot continue.
Make sure that gem install thin -v '1.7.2' --source 'https://rubygems.org/'
succeeds before bundling.
In Gemfile: thin
Environment (optional)
- Operating System: macOS
- The contents of your
gdk.yml
(empty) - Ruby version:
ruby 2.6.6p146 (2020-03-31 revision 67876) [x86_64-darwin19]
- GDK version:
9acf178