devel/arm-none-eabi-newlib headers inconsistencies (not functional) or am I misusing something?
Date: Fri, 26 May 2023 16:53:15 UTC
Hi, a source as simple as this does not compile with devel/arm-none-eabi-newlib installed #include <stdio.h> int main(int argc, char *argv[]) { return 0; } % arm-none-eabi-gcc break_arm.c In file included from break_arm.c:1: /usr/local/lib/gcc/arm-none-eabi/11.3.0/include-fixed/stdio.h:59:26: error: expected ';' before 'typedef' 59 | __NULLABILITY_PRAGMA_PUSH | ^ | ; 60 | 61 | typedef __off_t fpos_t; | ~~~~~~~ /usr/local/lib/gcc/arm-none-eabi/11.3.0/include-fixed/stdio.h:61:9: error: unknown type name '__off_t' 61 | typedef __off_t fpos_t; | ^~~~~~~ /usr/local/lib/gcc/arm-none-eabi/11.3.0/include-fixed/stdio.h:76:9: error: unknown type name '__off_t' 76 | typedef __off_t off_t; | ^~~~~~~ /usr/local/lib/gcc/arm-none-eabi/11.3.0/include-fixed/stdio.h:80:9: error: unknown type name '__ssize_t' 80 | typedef __ssize_t ssize_t; | ^~~~~~~~~ /usr/local/lib/gcc/arm-none-eabi/11.3.0/include-fixed/stdio.h:86:9: error: unknown type name '__off64_t' 86 | typedef __off64_t off64_t; | ^~~~~~~~~ /usr/local/lib/gcc/arm-none-eabi/11.3.0/include-fixed/stdio.h:91:9: error: unknown type name '__va_list' 91 | typedef __va_list __not_va_list__; | ^~~~~~~~~ /usr/local/lib/gcc/arm-none-eabi/11.3.0/include-fixed/stdio.h:149:29: error: expected ')' before '_close' 149 | int (* _Nullable _close)(void *); | ^~~~~~~ | ) /usr/local/lib/gcc/arm-none-eabi/11.3.0/include-fixed/stdio.h:150:29: error: expected ')' before '_read' 150 | int (* _Nullable _read)(void *, char *, int); | ^~~~~~ | ) /usr/local/lib/gcc/arm-none-eabi/11.3.0/include-fixed/stdio.h:151:29: error: expected ')' before '_seek' 151 | fpos_t (* _Nullable _seek)(void *, fpos_t, int); | ^~~~~~ | ) /usr/local/lib/gcc/arm-none-eabi/11.3.0/include-fixed/stdio.h:152:29: error: expected ')' before '_write' 152 | int (* _Nullable _write)(void *, const char *, int); | ^~~~~~~ | ) /usr/local/lib/gcc/arm-none-eabi/11.3.0/include-fixed/stdio.h:174:9: error: unknown type name '__mbstate_t' 174 | __mbstate_t _mbstate; /* multibyte conversion state */ | ^~~~~~~~~~~ /usr/local/lib/gcc/arm-none-eabi/11.3.0/include-fixed/stdio.h:373:25: error: unknown type name '__off_t'; did you mean '_off_t'? 373 | int fseeko(FILE *, __off_t, int); | ^~~~~~~ | _off_t /usr/local/lib/gcc/arm-none-eabi/11.3.0/include-fixed/stdio.h:374:1: error: unknown type name '__off_t'; did you mean '_off_t'? 374 | __off_t ftello(FILE *); | ^~~~~~~ | _off_t /usr/local/lib/gcc/arm-none-eabi/11.3.0/include-fixed/stdio.h:427:20: error: conflicting types for '_Nullable'; have 'int (*)(void *, const char *, int)' 427 | int (* _Nullable)(void *, const char *, int), | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/lib/gcc/arm-none-eabi/11.3.0/include-fixed/stdio.h:426:20: note: previous definition of '_Nullable' with type 'int (*)(void *, char *, int)' 426 | int (* _Nullable)(void *, char *, int), | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/lib/gcc/arm-none-eabi/11.3.0/include-fixed/stdio.h:428:23: error: conflicting types for '_Nullable'; have 'fpos_t (*)(void *, fpos_t, int)' {aka 'int (*)(void *, int, int)'} 428 | fpos_t (* _Nullable)(void *, fpos_t, int), | ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/lib/gcc/arm-none-eabi/11.3.0/include-fixed/stdio.h:427:20: note: previous definition of '_Nullable' with type 'int (*)(void *, const char *, int)' 427 | int (* _Nullable)(void *, const char *, int), | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/lib/gcc/arm-none-eabi/11.3.0/include-fixed/stdio.h:429:20: error: conflicting types for '_Nullable'; have 'int (*)(void *)' 429 | int (* _Nullable)(void *)); | ~~~~~~~^~~~~~~~~~~~~~~~~~ /usr/local/lib/gcc/arm-none-eabi/11.3.0/include-fixed/stdio.h:428:23: note: previous definition of '_Nullable' with type 'fpos_t (*)(void *, fpos_t, int)' {aka 'int (*)(void *, int, int)'} 428 | fpos_t (* _Nullable)(void *, fpos_t, int), | ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/lib/gcc/arm-none-eabi/11.3.0/include-fixed/stdio.h:433:9: error: unknown type name '__ssize_t' 433 | typedef __ssize_t cookie_read_function_t(void *, char *, size_t); | ^~~~~~~~~ /usr/local/lib/gcc/arm-none-eabi/11.3.0/include-fixed/stdio.h:434:9: error: unknown type name '__ssize_t' 434 | typedef __ssize_t cookie_write_function_t(void *, const char *, size_t); | ^~~~~~~~~ /usr/local/lib/gcc/arm-none-eabi/11.3.0/include-fixed/stdio.h:450:25: error: unknown type name '__off_t'; did you mean '_off_t'? 450 | int ftruncate(int, __off_t); | ^~~~~~~ | _off_t /usr/local/lib/gcc/arm-none-eabi/11.3.0/include-fixed/stdio.h:454:1: error: unknown type name '__off_t'; did you mean '_off_t'? 454 | __off_t lseek(int, __off_t, int); | ^~~~~~~ | _off_t /usr/local/lib/gcc/arm-none-eabi/11.3.0/include-fixed/stdio.h:454:21: error: unknown type name '__off_t'; did you mean '_off_t'? 454 | __off_t lseek(int, __off_t, int); | ^~~~~~~ | _off_t /usr/local/lib/gcc/arm-none-eabi/11.3.0/include-fixed/stdio.h:458:46: error: unknown type name '__off_t'; did you mean '_off_t'? 458 | void *mmap(void *, size_t, int, int, int, __off_t); | ^~~~~~~ | _off_t /usr/local/lib/gcc/arm-none-eabi/11.3.0/include-fixed/stdio.h:462:33: error: unknown type name '__off_t'; did you mean '_off_t'? 462 | int truncate(const char *, __off_t); | ^~~~~~~ | _off_t /usr/local/lib/gcc/arm-none-eabi/11.3.0/include-fixed/stdio.h:546:25: error: expected ';' before 'int' 546 | __NULLABILITY_PRAGMA_POP | ^ | ; Regarding the first error it seems that __NULLABILITY_PRAGMA_PUSH is not defined in the headers of devel/arm-none-eabi-*. I managed to work the issue around by copying and pasting this from /usr/include/sys/cdefs.h at the end of /usr/local/arm-none-eabi/include/sys/cdefs.h /* * Nullability qualifiers: currently only supported by Clang. */ #if !(defined(__clang__) && __has_feature(nullability)) #define _Nonnull #define _Nullable #define _Null_unspecified #define __NULLABILITY_PRAGMA_PUSH #define __NULLABILITY_PRAGMA_POP #else #define __NULLABILITY_PRAGMA_PUSH _Pragma("clang diagnostic push") \ _Pragma("clang diagnostic ignored \"-Wnullability-completeness\"") #define __NULLABILITY_PRAGMA_POP _Pragma("clang diagnostic pop") #endif But this workaround looks quite odd to me because, as the comment itself mentions, this is a clang only thing and we are on gcc, so maybe we shall instead remove all the __NULLABILITY_PRAGMA_PUSHes and __NULLABILITY_PRAGMA_POPs from the arm-none-eabi-* ports headers? Regarding the typedef errors, I am unsure on how to proceed: for example __off_t is defined here /usr/local/arm-none-eabi/include/machine/types.h:19 typedef long int __off_t; but this header is not included by stdio.h. If I force the inclusion, i.e. #include <machine/types.h> #include <stdio.h> ... the corresponding error goes away, but the following errors remain: /usr/local/lib/gcc/arm-none-eabi/11.3.0/include-fixed/stdio.h:80:9: error: unknown type name '__ssize_t' 80 | typedef __ssize_t ssize_t; | ^~~~~~~~~ /usr/local/lib/gcc/arm-none-eabi/11.3.0/include-fixed/stdio.h:86:9: error: unknown type name '__off64_t' 86 | typedef __off64_t off64_t; | ^~~~~~~~~ ... (others similar follow) __ssize_t nor __off64_t are not typedef'd anywhere in /usr/local/arm-none-eabi (devel/arm-none-eabi-newlib) nor /usr/local/lib/gcc/arm-none-eabi/11.3.0 (devel/arm-none-eabi-gcc). They are typedef'd in default /usr/include/sys/_types.h which is not in the search path, so it seems that the arm-none-eabi-* ports are not self sufficient. Maybe there is a missing dependency? Any suggestion? BR, -- José Pérez