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

runtime/cgo: "hello world" does not compile for GOOS=android due to -Wall in gcc_android.c #51911

Closed
aep opened this issue Mar 24, 2022 · 9 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Android
Milestone

Comments

@aep
Copy link

aep commented Mar 24, 2022

go version go1.17.7 linux/amd64

gcc_android.c currently doesnt compile. I don't think it should be built with -Wall anyway, as it's hard to keep updated with the latest android changes

package main
import "fmt"
func main() {  fmt.Println("hello world") }
CGO_CFLAGS="-I/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/"  CGO_ENABLED=1 GOOS=android GOARCH=arm64 go build
In file included from /home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/linux/signal.h:21,
                 from /home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/bits/signal_types.h:42,
                 from /home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/signal.h:37,
                 from /home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/sys/select.h:40,
                 from /home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/sys/time.h:37,
                 from /home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/time.h:33,
                 from /home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/pthread.h:37,
                 from gcc_android.c:7:
/usr/include/asm/signal.h:61: note: this is the location of the previous definition
   61 | #define SIGRTMAX        _NSIG
      | 
cc1: all warnings being treated as errors



@mknyszek mknyszek added OS-Android NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Mar 24, 2022
@mknyszek mknyszek added this to the Backlog milestone Mar 24, 2022
@mknyszek mknyszek changed the title cgo does not compile for GOOS=android due to -Wall in gcc_android.c runtime/cgo: "hello world" does not compile for GOOS=android due to -Wall in gcc_android.c Mar 24, 2022
@mknyszek
Copy link
Contributor

CC @golang/runtime

And specifically @ianlancetaylor and @cherrymui. I'm not sure if this actually belongs in runtime/cgo (probably not), but I'm not sure where else to attribute it. I don't actually know what invokes the C compiler at the end of the day for cgo.

@cherrymui
Copy link
Member

What is the warning? It seems the message above mentioned the source code location it warns at, but not what it warns. Thanks.

@aep
Copy link
Author

aep commented Mar 24, 2022

Are you saying you want to fix the android headers instead of removing -Wall?
That's just a game of whack-a-mole. There's plenty more.

cd cmd; \
	CGO_CFLAGS="-I/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/" \
	CGO_ENABLED=1 GOOS=android GOARCH=arm64 go build -ldflags="-s -w" -o ../cmd/carrier3-android-arm64
# runtime/cgo
In file included from /home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/sys/cdefs.h:357,
                 from /home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/alloca.h:36,
                 from /home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:32,
                 from _cgo_export.c:3:
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/android/api-level.h:142:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  142 | int android_get_application_target_sdk_version() __INTRODUCED_IN(24);
      | ^~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/android/api-level.h:162:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  162 | int android_get_device_api_level() __INTRODUCED_IN(29);
      | ^~~
In file included from /home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/malloc.h:30,
                 from /home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:34,
                 from _cgo_export.c:3:
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdio.h:62:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
   62 | extern FILE* stdin __INTRODUCED_IN(23);
      | ^~~~~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdio.h:63:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
   63 | extern FILE* stdout __INTRODUCED_IN(23);
      | ^~~~~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdio.h:64:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
   64 | extern FILE* stderr __INTRODUCED_IN(23);
      | ^~~~~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdio.h:123:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  123 | ssize_t getdelim(char** __line_ptr, size_t* __line_length_ptr, int __delimiter, FILE* __fp) __INTRODUCED_IN(18);
      | ^~~~~~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdio.h:124:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  124 | ssize_t getline(char** __line_ptr, size_t* __line_length_ptr, FILE* __fp) __INTRODUCED_IN(18);
      | ^~~~~~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdio.h:144:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  144 | int dprintf(int __fd, const char* __fmt, ...) __printflike(2, 3) __INTRODUCED_IN(21);
      | ^~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdio.h:145:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  145 | int vdprintf(int __fd, const char* __fmt, va_list __args) __printflike(2, 0) __INTRODUCED_IN(21);
      | ^~~
In file included from /home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/malloc.h:30,
                 from /home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:34,
                 from _cgo_export.c:3:
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdio.h:262:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  262 | int fgetpos64(FILE* __fp, fpos64_t* __pos) __INTRODUCED_IN(24);
      | ^~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdio.h:263:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  263 | int fsetpos64(FILE* __fp, const fpos64_t* __pos) __INTRODUCED_IN(24);
      | ^~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdio.h:264:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  264 | int fseeko64(FILE* __fp, off64_t __offset, int __whence) __INTRODUCED_IN(24);
      | ^~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdio.h:265:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  265 | off64_t ftello64(FILE* __fp) __INTRODUCED_IN(24);
      | ^~~~~~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdio.h:283:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  283 | FILE* fopen64(const char* __path, const char* __mode) __INTRODUCED_IN(24);
      | ^~~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdio.h:289:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  289 | FILE* freopen64(const char* __path, const char* __mode, FILE* __fp) __INTRODUCED_IN(24);
      | ^~~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdio.h:295:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  295 | FILE* tmpfile64(void) __INTRODUCED_IN(24);
      | ^~~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdio.h:308:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  308 | char* ctermid(char* __buf) __INTRODUCED_IN(26);
      | ^~~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdio.h:326:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  326 | FILE* fmemopen(void* __buf, size_t __size, const char* __mode) __INTRODUCED_IN(23);
      | ^~~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdio.h:327:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  327 | FILE* open_memstream(char** __ptr, size_t* __size_ptr) __INTRODUCED_IN(23);
      | ^~~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdio.h:340:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  340 | void clearerr_unlocked(FILE* __fp) __INTRODUCED_IN(23);
      | ^~~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdio.h:341:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  341 | int feof_unlocked(FILE* __fp) __INTRODUCED_IN(23);
      | ^~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdio.h:342:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  342 | int ferror_unlocked(FILE* __fp) __INTRODUCED_IN(23);
      | ^~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdio.h:347:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  347 | int fileno_unlocked(FILE* __fp) __INTRODUCED_IN(24);
      | ^~~
In file included from /home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:34,
                 from _cgo_export.c:3:
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/malloc.h:75:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
   75 | void* reallocarray(void* __ptr, size_t __item_count, size_t __item_size) __BIONIC_ALLOC_SIZE(2, 3) __wur __INTRODUCED_IN(29);
      | ^~~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/malloc.h:104:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  104 | size_t malloc_usable_size(const void* __ptr) __INTRODUCED_IN(17);
      | ^~~~~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/malloc.h:168:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  168 | int malloc_info(int __must_be_zero, FILE* __fp) __INTRODUCED_IN(23);
      | ^~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/malloc.h:196:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  196 | int mallopt(int __option, int __value) __INTRODUCED_IN(26);
      | ^~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/malloc.h:211:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  211 | extern void* (*volatile __malloc_hook)(size_t __byte_count, const void* __caller) __INTRODUCED_IN(28);
      | ^~~~~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/malloc.h:222:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  222 | extern void* (*volatile __realloc_hook)(void* __ptr, size_t __byte_count, const void* __caller) __INTRODUCED_IN(28);
      | ^~~~~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/malloc.h:233:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  233 | extern void (*volatile __free_hook)(void* __ptr, const void* __caller) __INTRODUCED_IN(28);
      | ^~~~~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/malloc.h:244:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  244 | extern void* (*volatile __memalign_hook)(size_t __alignment, size_t __byte_count, const void* __caller) __INTRODUCED_IN(28);
      | ^~~~~~
In file included from _cgo_export.c:3:
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:47:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
   47 | __noreturn void _Exit(int __status) __INTRODUCED_IN(21);
      | ^~~~~~~~~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:56:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
   56 | int at_quick_exit(void (*__fn)(void)) __INTRODUCED_IN(21);
      | ^~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:57:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
   57 | void quick_exit(int __status) __noreturn __INTRODUCED_IN(21);
      | ^~~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:72:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
   72 | int mkostemp64(char* __template, int __flags) __INTRODUCED_IN(23);
      | ^~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:73:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
   73 | int mkostemp(char* __template, int __flags) __INTRODUCED_IN(23);
      | ^~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:74:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
   74 | int mkostemps64(char* __template, int __suffix_length, int __flags) __INTRODUCED_IN(23);
      | ^~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:75:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
   75 | int mkostemps(char* __template, int __suffix_length, int __flags) __INTRODUCED_IN(23);
      | ^~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:80:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
   80 | int mkstemp64(char* __template) __INTRODUCED_IN(21);
      | ^~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:86:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
   86 | int mkstemps64(char* __template, int __flags) __INTRODUCED_IN(23);
      | ^~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:98:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
   98 | int posix_memalign(void** __memptr, size_t __alignment, size_t __size) __INTRODUCED_IN(17);
      | ^~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:104:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  104 | void* aligned_alloc(size_t __alignment, size_t __size) __INTRODUCED_IN(28);
      | ^~~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:109:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  109 | long double strtold(const char* __s, char** __end_ptr) __RENAME_LDBL(strtod, 3, 21);
      | ^~~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:113:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  113 | unsigned long strtoul_l(const char* __s, char** __end_ptr, int __base, locale_t __l) __INTRODUCED_IN(26);
      | ^~~~~~~~
In file included from _cgo_export.c:3:
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:136:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  136 | int rand_r(unsigned int* __seed_ptr) __INTRODUCED_IN(21);
      | ^~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:145:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  145 | void lcong48(unsigned short __param[7]) __INTRODUCED_IN(23);
      | ^~~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:156:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  156 | char* initstate(unsigned int __seed, char* __state, size_t __n) __INTRODUCED_IN(21);
      | ^~~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:157:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  157 | char* setstate(char* __state) __INTRODUCED_IN(21);
      | ^~~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:164:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  164 | int posix_openpt(int __flags) __INTRODUCED_IN(21);
      | ^~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:173:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  173 | int getsubopt(char** __option, char* const* __tokens, char** __value_ptr) __INTRODUCED_IN(26);
      | ^~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:207:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  207 | int getloadavg(double __averages[], int __n) __INTRODUCED_IN(29);
      | ^~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:214:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  214 | const char* getprogname(void) __INTRODUCED_IN(21);
      | ^~~~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:215:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  215 | void setprogname(const char* __name) __INTRODUCED_IN(21);
      | ^~~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:219:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  219 | int mblen(const char* __s, size_t __n) __INTRODUCED_IN(26) __VERSIONER_NO_GUARD;
      | ^~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:219:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:221:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  221 | int mbtowc(wchar_t* __wc_ptr, const char* __s, size_t __n) __INTRODUCED_IN(21) __VERSIONER_NO_GUARD;
      | ^~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:221:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:222:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  222 | int wctomb(char* __dst, wchar_t __wc) __INTRODUCED_IN(21) __VERSIONER_NO_GUARD;
      | ^~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:222:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:227:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  227 | size_t __ctype_get_mb_cur_max(void) __INTRODUCED_IN(21);
      | ^~~~~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:243:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  243 | int abs(int __x) __attribute_const__ __INTRODUCED_IN(19);
      | ^~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:244:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  244 | long labs(long __x) __attribute_const__ __INTRODUCED_IN(19);
      | ^~~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:245:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  245 | long long llabs(long long __x) __attribute_const__ __INTRODUCED_IN(19);
      | ^~~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:251:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  251 | float strtof(const char* __s, char** __end_ptr) __INTRODUCED_IN(21);
      | ^~~~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:252:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  252 | double atof(const char* __s) __attribute_pure__ __INTRODUCED_IN(21);
      | ^~~~~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:253:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  253 | int rand(void) __INTRODUCED_IN(21);
      | ^~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:254:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  254 | void srand(unsigned int __seed) __INTRODUCED_IN(21);
      | ^~~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:255:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  255 | long random(void) __INTRODUCED_IN(21);
      | ^~~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:256:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  256 | void srandom(unsigned int __seed) __INTRODUCED_IN(21);
      | ^~~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:257:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  257 | int grantpt(int __fd) __INTRODUCED_IN(21);
      | ^~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:259:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  259 | long long strtoll_l(const char* __s, char** __end_ptr, int __base, locale_t __l) __INTRODUCED_IN(21);
      | ^~~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:260:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  260 | unsigned long long strtoull_l(const char* __s, char** __end_ptr, int __base, locale_t __l) __INTRODUCED_IN(21);
      | ^~~~~~~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:261:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  261 | long double strtold_l(const char* __s, char** __end_ptr, locale_t __l) __INTRODUCED_IN(21);
      | ^~~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:267:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  267 | double strtod_l(const char* __s, char** __end_ptr, locale_t __l) __INTRODUCED_IN(26);
      | ^~~~~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:268:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  268 | float strtof_l(const char* __s, char** __end_ptr, locale_t __l) __INTRODUCED_IN(26);
      | ^~~~~
/home/aep/Android/Sdk/ndk/21.4.7075529/sysroot/usr/include/stdlib.h:269:1: error: ‘annotate’ attribute directive ignored [-Werror=attributes]
  269 | long strtol_l(const char* __s, char** __end_ptr, int, locale_t __l) __INTRODUCED_IN(26);
      | ^~~~
cc1: all warnings being treated as errors
make: *** [Makefile:47: cmd/carrier3-android-arm64] Error 2


@aclements
Copy link
Member

Are you saying you want to fix the android headers instead of removing -Wall?
That's just a game of whack-a-mole. There's plenty more.

We haven't proposed any fix for this yet. We were just looking for additional information to make sure we understand the problem.

@aep
Copy link
Author

aep commented Mar 24, 2022

eh sorry, that came across wrong.

i'm actually just wondering where the -Wall is even coming from and how i can remove it myself.
i couldn't really figure out where _cgo_export.c is generated since there's no // cgo comment in any of the code.

@aclements
Copy link
Member

If I'm not mistaken, Android builds always use cgo since they have to work with the system libc. That means the build implicitly imports runtime/cgo, and I believe the -Wall comes from runtime/cgo/cgo.go. Try dropping that and see if it works.

I'm surprised these headers aren't -Wall-clean, which makes me wonder if something else is really going on here. Especially since, at a quick skim, it looks like it's all the same error.

@aep
Copy link
Author

aep commented Mar 24, 2022

aha!

#cgo CFLAGS: -Wall -Werror

unfortunately the workaround is much more convenient: an empty log.h file with just __android_log_vprint works just fine.
in my opinion that could just be hardcoded inside gcc_android.c. it's not like logs work anymore anyway since android11

i'm not sure if this bug should stay open. i guess it depends on if go requires system headers to pass -Wall although that isn't the case in pretty much any real world use case where you just get broken vendor source code as a tarball.

@ianlancetaylor
Copy link
Contributor

Modern versions of GCC do not issue warnings for system header files (this is controlled by -Wsystem-headers). I assume that clang is the same. So I'm puzzled by this. Perhaps they are getting confused as to whether the Android headers are system headers; for non-builtin directories this is controlled by using -isystem rather than -I.

@aep
Copy link
Author

aep commented Mar 24, 2022

for non-builtin directories this is controlled by using -isystem rather than -I.

oh no! yes that's the issue. i used -I rather than -isystem.
i couldn't really find any offical docs for android so i'm just guessing from random blog posts.

thanks!

@aep aep closed this as completed Mar 24, 2022
@golang golang locked and limited conversation to collaborators Mar 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Android
Projects
None yet
Development

No branches or pull requests

6 participants