Cross Compiling x86_64 Haiku On Apple Silicon

I’ve been chipping away at cross compiling Haiku x86_64 on Apple Silicon and I’ve run into an issue I’m hoping I can get some help with. Everything seems to build fine except for fs_shell. I’m getting two types of errors:

  1. must use ‘struct’ tag
In file included from ../headers/private/fs_shell/fssh_api_wrapper.h:21:
../headers/private/fs_shell/fssh_stat.h:23:2: error: must use 'struct' tag to refer to type 'fssh_timespec'
   23 |         fssh_timespec           fssh_st_atim;           /* last access time */
      |         ^
      |         struct 
  1. Unkown type name ‘bool’
../headers/private/fs_shell/fssh_byte_order.h:117:8: error: unknown type name 'bool'
  117 | extern bool fssh_is_type_swapped(fssh_type_code type);

I’ve tried to add the struct tag and I’ve added #include <stdbool.h> to fss_defs.h file but that just leads to more errors about overwritten defines and I’m worried I could be breaking things for other architectures.

I’m wondering if something is wrong with the generated build configuration. Here is my generated BuildConfig:

# -- WARNING --
# This file was AUTOMATICALLY GENERATED by configure, and will be completely
# overwritten the next time configure is run.
#
#d /Volumes/haiku/haiku/generated.x86_64
#c ../configure
#e 
#a --cross-tools-source ../../buildtools/ --build-cross-tools x86_64

GIT_DIR						?= ".git" ;

HOST_PLATFORM				?= "darwin" ;
TARGET_PLATFORM 			?= "haiku" ;
HAIKU_PACKAGING_ARCHS		?=  x86_64 ;

HAIKU_NO_DOWNLOADS			?= "0" ;
HAIKU_INCLUDE_SOURCES		?= "0" ;
HAIKU_INCLUDE_3RDPARTY		?= "0" ;
HAIKU_DISTRO_COMPATIBILITY	?= "default" ;

HAIKU_USE_GCC_PIPE			?= "0" ;
HAIKU_HOST_USE_32BIT		?= "0" ;
HAIKU_HOST_USE_XATTR		?= "1" ;
HAIKU_HOST_USE_XATTR_REF	?= "0" ;
HAIKU_HOST_BUILD_ONLY		?= "0" ;

JAMSHELL					?= /bin/dash -e -c ;

HOST_CC						?= gcc ;
HOST_GCC_MACHINE			?= arm64-apple-darwin24.2.0 ;
HOST_LD						?= /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld ;
HOST_OBJCOPY				?= objcopy ;
HOST_EXTENDED_REGEX_SED		?= sed -E ;
HOST_SHA256					?= sha256sum ;
HOST_PYTHON					?= python3 ;
HOST_WGET_RETRY_ON_HOST_ERROR			?= 1 ;
HAIKU_NASM					?= nasm ;

HAIKU_BUILD_ATTRIBUTES_DIR	?= "/Volumes/haiku/haiku/generated.x86_64/attributes" ;

HOST_HAIKU_PORTER			?=  ;
HAIKU_PORTS					?=  ;
HAIKU_PORTS_CROSS			?=  ;
HAIKU_IS_BOOTSTRAP			?= 0 ;

HAIKU_BOOT_EFI_PRIVATE_KEYFILE	?=  ;
HAIKU_CC_x86_64 ?= /Volumes/haiku/haiku/generated.x86_64/cross-tools-x86_64/bin/x86_64-unknown-haiku-gcc ;
HAIKU_CC_IS_LEGACY_GCC_x86_64 ?= 0 ;
HAIKU_CC_IS_CLANG_x86_64 ?= 0 ;
HAIKU_USE_GCC_GRAPHITE_x86_64 ?= 0 ;
HAIKU_CPU_x86_64 ?= x86_64 ;
HAIKU_GCC_MACHINE_x86_64 ?= x86_64-unknown-haiku ;
HAIKU_GCC_LIB_DIR_x86_64 ?= /Volumes/haiku/haiku/generated.x86_64/cross-tools-x86_64/lib/gcc/x86_64-unknown-haiku/13.3.0 ;
HAIKU_BOOT_LIBGCC_x86_64 ?= /Volumes/haiku/haiku/generated.x86_64/cross-tools-x86_64/lib/gcc/x86_64-unknown-haiku/13.3.0/libgcc.a ;
HAIKU_BOOT_LIBSUPC++_x86_64 ?= /Volumes/haiku/haiku/generated.x86_64/cross-tools-x86_64/lib/gcc/x86_64-unknown-haiku/13.3.0/../../../../x86_64-unknown-haiku/lib/libsupc++.a ;
HAIKU_BOOT_32_LIBGCC_x86_64 ?= /Volumes/haiku/haiku/generated.x86_64/cross-tools-x86_64/lib/gcc/x86_64-unknown-haiku/13.3.0/32/libgcc.a ;
HAIKU_BOOT_32_LIBSUPC++_x86_64 ?= /Volumes/haiku/haiku/generated.x86_64/cross-tools-x86_64/lib/gcc/x86_64-unknown-haiku/13.3.0/../../../../x86_64-unknown-haiku/lib/32/libsupc++.a ;
HAIKU_AR_x86_64 ?= /Volumes/haiku/haiku/generated.x86_64/cross-tools-x86_64/bin/x86_64-unknown-haiku-ar ;
HAIKU_LD_x86_64 ?= /Volumes/haiku/haiku/generated.x86_64/cross-tools-x86_64/bin/x86_64-unknown-haiku-ld ;
HAIKU_OBJCOPY_x86_64 ?= /Volumes/haiku/haiku/generated.x86_64/cross-tools-x86_64/bin/x86_64-unknown-haiku-objcopy ;
HAIKU_RANLIB_x86_64 ?= /Volumes/haiku/haiku/generated.x86_64/cross-tools-x86_64/bin/x86_64-unknown-haiku-ranlib ;
HAIKU_ELFEDIT_x86_64 ?= /Volumes/haiku/haiku/generated.x86_64/cross-tools-x86_64/bin/x86_64-unknown-haiku-elfedit ;
HAIKU_STRIP_x86_64 ?= /Volumes/haiku/haiku/generated.x86_64/cross-tools-x86_64/bin/x86_64-unknown-haiku-strip ;
HAIKU_CPPFLAGS_x86_64 ?=  ;
HAIKU_CCFLAGS_x86_64 ?=  ;
HAIKU_C++FLAGS_x86_64 ?=  ;
HAIKU_LINKFLAGS_x86_64 ?=  ;
HAIKU_LDFLAGS_x86_64 ?=  ;
HAIKU_ARFLAGS_x86_64 ?= cru ;
HAIKU_UNARFLAGS_x86_64 ?= x ;
HAIKU_BOOT_C++_HEADERS_DIR_x86_64 ?= 
    /Volumes/haiku/haiku/generated.x86_64/cross-tools-x86_64/lib/gcc/x86_64-unknown-haiku/13.3.0/../../../../x86_64-unknown-haiku/include/c++/13.3.0/x86_64-unknown-haiku
    ;
HAIKU_BOOT_32_C++_HEADERS_DIR_x86_64 ?= 
    /Volumes/haiku/haiku/generated.x86_64/cross-tools-x86_64/lib/gcc/x86_64-unknown-haiku/13.3.0/../../../../x86_64-unknown-haiku/include/c++/13.3.0/x86_64-unknown-haiku/32
    ;

Or maybe something obvious isn’t installed correctly. I’ll keep forging ahead but thought to throw this here incase it was something obvious.

Thanks,
Devin

1 Like

Can you provide a complete build log or at least a copy of the command line of one of the things that failed to build?

These two errors would happen if compiling C++ code with a C compiler, so that would be the first thing to check. I see it is using “gcc” for HOST_CC, whereas usually the C compiler on Mac OS would be clang, and I’m not sure how good their “gcc” wrapper (that makes clang pretend to be gcc) is, or if maybe you’re using some other version of gcc here.

Here is the file that first has issues:

Cc objects/darwin/release/tools/fat_shell/subr_clock.o 
In file included from ../src/add-ons/kernel/file_systems/fat/bsd/kern/subr_clock.c:41:
In file included from ../headers/private/fs_shell/fssh_api_wrapper.h:21:
../headers/private/fs_shell/fssh_stat.h:23:2: error: must use 'struct' tag to refer to type 'fssh_timespec'
   23 |         fssh_timespec           fssh_st_atim;           /* last access time */
      |         ^
      |         struct 
../headers/private/fs_shell/fssh_stat.h:24:2: error: must use 'struct' tag to refer to type 'fssh_timespec'
   24 |         fssh_timespec           fssh_st_mtim;           /* last modification time */
      |         ^
      |         struct 
../headers/private/fs_shell/fssh_stat.h:25:2: error: must use 'struct' tag to refer to type 'fssh_timespec'
   25 |         fssh_timespec           fssh_st_ctim;           /* last change time, not creation time */
      |         ^
      |         struct 
../headers/private/fs_shell/fssh_stat.h:26:2: error: must use 'struct' tag to refer to type 'fssh_timespec'
   26 |         fssh_timespec           fssh_st_crtim;          /* creation time */
      |         ^
      |         struct 
In file included from ../src/add-ons/kernel/file_systems/fat/bsd/kern/subr_clock.c:41:
In file included from ../headers/private/fs_shell/fssh_api_wrapper.h:29:
../headers/private/fs_shell/fssh_byte_order.h:117:8: error: unknown type name 'bool'
  117 | extern bool fssh_is_type_swapped(fssh_type_code type);
      |        ^
In file included from ../src/add-ons/kernel/file_systems/fat/bsd/kern/subr_clock.c:41:
In file included from ../headers/private/fs_shell/fssh_api_wrapper.h:32:
In file included from ../headers/private/fs_shell/fssh_disk_device_manager.h:10:
In file included from ../headers/private/fs_shell/fssh_drivers.h:5:
In file included from ../headers/private/fs_shell/fssh_fs_interface.h:12:
In file included from ../headers/private/fs_shell/fssh_module.h:10:
../headers/private/fs_shell/fssh_os.h:174:8: error: unknown type name 'bool'
  174 | extern bool                             fssh_has_data(fssh_thread_id thread);
      |        ^
In file included from ../src/add-ons/kernel/file_systems/fat/bsd/kern/subr_clock.c:41:
In file included from ../headers/private/fs_shell/fssh_api_wrapper.h:32:
In file included from ../headers/private/fs_shell/fssh_disk_device_manager.h:10:
In file included from ../headers/private/fs_shell/fssh_drivers.h:5:
../headers/private/fs_shell/fssh_fs_interface.h:84:5: error: unknown type name 'bool'
   84 |                                 bool reenter);
      |                                 ^
../headers/private/fs_shell/fssh_fs_interface.h:133:5: error: unknown type name 'bool'
  133 |                                 bool reenter);
      |                                 ^
../headers/private/fs_shell/fssh_fs_interface.h:135:5: error: unknown type name 'bool'
  135 |                                 bool reenter);
      |                                 ^
../headers/private/fs_shell/fssh_fs_interface.h:138:2: error: type name requires a specifier or qualifier
  138 |         bool (*can_page)(fssh_fs_volume *volume, fssh_fs_vnode *vnode,
      |         ^
../headers/private/fs_shell/fssh_fs_interface.h:138:9: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
  138 |         bool (*can_page)(fssh_fs_volume *volume, fssh_fs_vnode *vnode,
      |                ^
      |               int
../headers/private/fs_shell/fssh_fs_interface.h:165:43: error: must use 'struct' tag to refer to type 'fssh_selectsync'
  165 |                                 fssh_fs_cookie cookie, uint8_t event, fssh_selectsync *sync);
      |                                                                       ^
      |                                                                       struct 
../headers/private/fs_shell/fssh_fs_interface.h:167:43: error: must use 'struct' tag to refer to type 'fssh_selectsync'
  167 |                                 fssh_fs_cookie cookie, uint8_t event, fssh_selectsync *sync);
      |                                                                       ^
      |                                                                       struct 
../headers/private/fs_shell/fssh_fs_interface.h:284:38: error: must use 'struct' tag to refer to type 'fssh_partition_data'
  284 |         float (*identify_partition)(int fd, fssh_partition_data *partition,
      |                                             ^
      |                                             struct 
../headers/private/fs_shell/fssh_fs_interface.h:286:42: error: must use 'struct' tag to refer to type 'fssh_partition_data'
  286 |         fssh_status_t (*scan_partition)(int fd, fssh_partition_data *partition,
      |                                                 ^
      |                                                 struct 
../headers/private/fs_shell/fssh_fs_interface.h:288:41: error: must use 'struct' tag to refer to type 'fssh_partition_data'
  288 |         void (*free_identify_partition_cookie)(fssh_partition_data *partition,
      |                                                ^
      |                                                struct 
../headers/private/fs_shell/fssh_fs_interface.h:290:40: error: must use 'struct' tag to refer to type 'fssh_partition_data'
  290 |         void (*free_partition_content_cookie)(fssh_partition_data *partition);
      |                                               ^
      |                                               struct 
../headers/private/fs_shell/fssh_fs_interface.h:297:39: error: must use 'struct' tag to refer to type 'fssh_partition_data'
  297 |         uint32_t (*get_supported_operations)(fssh_partition_data* partition,
      |                                              ^
      |                                              struct 
../headers/private/fs_shell/fssh_fs_interface.h:300:2: error: type name requires a specifier or qualifier
  300 |         bool (*validate_resize)(fssh_partition_data *partition, fssh_off_t *size);
      |         ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

gcc -O2 -Wall -Wno-trigraphs -Wmissing-prototypes -Wpointer-arith -Wcast-align -Wsign-compare -Wno-multichar -DFS_SHELL -D_FSSH_AUTO_LOCKER_H=1 -D_FSSH_STACK_H=1 -c "../src/add-ons/kernel/file_systems/fat/bsd/kern/subr_clock.c" -DHAIKU_BUILD_COMPATIBILITY_H -D_NO_INLINE_ASM -D__NO_INLINE__ -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DHAIKU_HOST_USE_XATTR -DHAIKU_HOST_PLATFORM_DARWIN -DHAIKU_HOST_PLATFORM_64_BIT -DHAIKU_PACKAGING_ARCH=\"x86_64\" -iquote ../build/user_config_headers -iquote ../build/config_headers -iquote ../src/tools/fat_shell -iquote objects/common/tools/fat_shell -iquote objects/darwin/common/tools/fat_shell -iquote objects/haiku/x86_64/common/tools/fat_shell -iquote ../src/add-ons/kernel/file_systems/fat -iquote ../src/add-ons/kernel/file_systems/fat/bsd/fs/msdosfs -iquote ../src/add-ons/kernel/file_systems/fat/bsd/kern -iquote ../src/add-ons/kernel/file_systems/fat/bsd/libkern -iquote ../src/add-ons/kernel/file_systems/fat/bsd/vm -iquote ../src/tools/fs_shell -I ../headers/private/shared -I ../headers/private/storage -I ../headers/private/file_systems -I ../headers/private/fs_shell -I ../src/add-ons/kernel/file_systems/fat/bsd -I ../headers/build/host/darwin -I ../src/build/libgnuregex -I /opt/local/include -I /usr/local/include -I /opt/homebrew/include -o "objects/darwin/release/tools/fat_shell/subr_clock.o"

...failed Cc objects/darwin/release/tools/fat_shell/subr_clock.o ...

So it indeed happens while compiling C code.

For the problem with bool, current versions of gcc default to C23 where bool is a native type as it is in C++, and stdbool.h is not needed. I would guess that your gcc defaults to some older version of the C standard, where that isn’t the case. That may explain why no one noticed that problem since the rewrite of the FAT driver.

https://en.cppreference.com/w/c/language/arithmetic_types#Boolean_type

I’m not sure about the other one, I don’t think anything about that changed in recent C versions and the “struct” keyword (or a typedef) would be needed.

Can you check if setting the CC environment variable to g++ solves the issue?

You meant to say that either struct or a typedef is always needed for structs in C, didn’t you?

What’s more confusing is that typedefs are actually added if no __cplusplus is defined (thus when compiling C code), but then the compiler complains about their absence which should be the case only if __cplusplus is defined, but C++ should not complain about structs at all. Does it mean FS_SHELL is not defined?

Yes, in C++ there is no separate namespace, so if you define a struct, it is also a type.

So this works in C++ but not in C:

struct a { };

a someVariable;

FS_SHELL should be defined at that point (building the fat_shell which is one fs_shell). And we can see it in the gcc command line in the error log.

The more likely explanation is that the sys/types.h from fatfs is not included where it should, and these defines end up not being used.

Typically for other filesystems, we have a global header grouping together fs_shell wrappers, that we can make sure to include everywhere, something like this: system_dependencies.h « xfs « file_systems « kernel « add-ons « src - haiku - Haiku's main repository

The fat filesystem did not do this, and as a result, there can be “leaks” from the host operating system interferring with things. This can probably be fixed by adding a #include “sys/types.h” i nsrc/add-ons/kernel/file_systems/fat/bsd/kern/subr_clock.c just before the include of fssh_api_wrapper.h?

So that seemed to get me a little further and I think you are right, something is leaking through. I had tried switching to g++ but that caused other issues and it was failing earlier in the build process. So the two errors are gone now but I’m getting the following:

/opt/homebrew/Cellar/gcc@13/13.3.0/bin/gcc-13 -O2 -Wall -Wno-trigraphs -Wmissing-prototypes -Wpointer-arith -Wcast-align -Wsign-compare -Wno-multichar -DFS_SHELL -D_FSSH_AUTO_LOCKER_H=1 -D_FSSH_STACK_H=1 -c "../src/add-ons/kernel/file_systems/fat/bsd/kern/subr_clock.c" -DHAIKU_BUILD_COMPATIBILITY_H -D_NO_INLINE_ASM -D__NO_INLINE__ -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DHAIKU_HOST_USE_XATTR -DHAIKU_HOST_PLATFORM_DARWIN -DHAIKU_HOST_PLATFORM_64_BIT -DHAIKU_PACKAGING_ARCH=\"x86_64\" -iquote ../build/user_config_headers -iquote ../build/config_headers -iquote ../src/tools/fat_shell -iquote objects/common/tools/fat_shell -iquote objects/darwin/common/tools/fat_shell -iquote objects/haiku/x86_64/common/tools/fat_shell -iquote ../src/add-ons/kernel/file_systems/fat -iquote ../src/add-ons/kernel/file_systems/fat/bsd/fs/msdosfs -iquote ../src/add-ons/kernel/file_systems/fat/bsd/kern -iquote ../src/add-ons/kernel/file_systems/fat/bsd/libkern -iquote ../src/add-ons/kernel/file_systems/fat/bsd/vm -iquote ../src/tools/fs_shell -I ../headers/private/shared -I ../headers/private/storage -I ../headers/private/file_systems -I ../headers/private/fs_shell -I ../src/add-ons/kernel/file_systems/fat/bsd -I ../headers/build/host/darwin -I ../src/build/libgnuregex -I /opt/local/include -I /usr/local/include -I /opt/homebrew/include -o "objects/darwin/release/tools/fat_shell/subr_clock.o"
In file included from ../src/add-ons/kernel/file_systems/fat/bsd/kern/subr_clock.c:42:
../headers/private/fs_shell/fssh_api_wrapper.h:81: warning: "htonl" redefined
   81 | #define htonl(x)        fssh_htonl(x)
      | 
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/arm/endian.h:61,
                 from /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/machine/endian.h:37,
                 from /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/sys/types.h:81,
                 from ../src/add-ons/kernel/file_systems/fat/bsd/sys/types.h:42,
                 from ../src/add-ons/kernel/file_systems/fat/bsd/kern/subr_clock.c:41:
/Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/sys/_endian.h:137: note: this is the location of the previous definition
  137 | #define htonl(x)        __DARWIN_OSSwapInt32(x)
      | 
../headers/private/fs_shell/fssh_api_wrapper.h:82: warning: "ntohl" redefined
   82 | #define ntohl(x)        fssh_ntohl(x)
      | 
/Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/sys/_endian.h:136: note: this is the location of the previous definition
  136 | #define ntohl(x)        __DARWIN_OSSwapInt32(x)
      | 
../headers/private/fs_shell/fssh_api_wrapper.h:83: warning: "htons" redefined
   83 | #define htons(x)        fssh_htons(x)
      | 
/Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/sys/_endian.h:134: note: this is the location of the previous definition
  134 | #define htons(x)        __DARWIN_OSSwapInt16(x)
      | 
../headers/private/fs_shell/fssh_api_wrapper.h:84: warning: "ntohs" redefined
   84 | #define ntohs(x)        fssh_ntohs(x)
      | 
/Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/sys/_endian.h:133: note: this is the location of the previous definition
  133 | #define ntohs(x)        __DARWIN_OSSwapInt16(x)
      | 
../headers/private/fs_shell/fssh_api_wrapper.h:1364: warning: "memcpy" redefined
 1364 | #define memcpy          fssh_memcpy
      | 
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/_string.h:188,
                 from /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/string.h:58,
                 from ../headers/private/fs_shell/fssh_api_wrapper.h:9:
/Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/secure/_string.h:62: note: this is the location of the previous definition
   62 | #define memcpy(dest, ...) \
      | 
../headers/private/fs_shell/fssh_api_wrapper.h:1366: warning: "memmove" redefined
 1366 | #define memmove         fssh_memmove
      | 
/Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/secure/_string.h:69: note: this is the location of the previous definition
   69 | #define memmove(dest, ...) \
      | 
../headers/private/fs_shell/fssh_api_wrapper.h:1367: warning: "memset" redefined
 1367 | #define memset          fssh_memset
      | 
/Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/secure/_string.h:76: note: this is the location of the previous definition
   76 | #define memset(dest, ...) \
      | 
../headers/private/fs_shell/fssh_api_wrapper.h:1370: warning: "strcpy" redefined
 1370 | #define strcpy          fssh_strcpy
      | 
/Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/secure/_string.h:83: note: this is the location of the previous definition
   83 | #define strcpy(dest, ...) \
      | 
../headers/private/fs_shell/fssh_api_wrapper.h:1371: warning: "strncpy" redefined
 1371 | #define strncpy         fssh_strncpy
      | 
/Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/secure/_string.h:127: note: this is the location of the previous definition
  127 | #define strncpy(dest, ...) \
      | 
../headers/private/fs_shell/fssh_api_wrapper.h:1372: warning: "strcat" redefined
 1372 | #define strcat          fssh_strcat
      | 
/Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/secure/_string.h:134: note: this is the location of the previous definition
  134 | #define strcat(dest, ...) \
      | 
../headers/private/fs_shell/fssh_api_wrapper.h:1373: warning: "strncat" redefined
 1373 | #define strncat         fssh_strncat
      | 
/Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/secure/_string.h:142: note: this is the location of the previous definition
  142 | #define strncat(dest, ...) \
      | 
../headers/private/fs_shell/fssh_api_wrapper.h:1396: warning: "stpcpy" redefined
 1396 | #define stpcpy          fssh_stpcpy
      | 
/Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/secure/_string.h:91: note: this is the location of the previous definition
   91 | #define stpcpy(dest, ...) \
      | 
../headers/private/fs_shell/fssh_api_wrapper.h:1425:25: error: redefinition of 'struct fssh_timespec'
 1425 | #define timespec        fssh_timespec
      |                         ^~~~~~~~~~~~~
In file included from ../headers/private/fs_shell/fssh_stat.h:10,
                 from ../headers/private/fs_shell/fssh_api_wrapper.h:21:
../headers/private/fs_shell/fssh_time.h:28:8: note: originally defined here
   28 | struct fssh_timespec {
      |        ^~~~~~~~~~~~~
../headers/private/fs_shell/fssh_api_wrapper.h:1427:33: error: redefinition of 'struct fssh_tm'
 1427 | #define tm                      fssh_tm
      |                                 ^~~~~~~
../headers/private/fs_shell/fssh_time.h:38:8: note: originally defined here
   38 | struct fssh_tm {
      |        ^~~~~~~
../headers/private/fs_shell/fssh_api_wrapper.h:1438:25: error: conflicting types for 'fssh_asctime'; have 'char *(const struct fssh_tm *)'
 1438 | #define asctime         fssh_asctime
      |                         ^~~~~~~~~~~~
../headers/private/fs_shell/fssh_time.h:66:42: note: previous declaration of 'fssh_asctime' with type 'char *(const struct fssh_tm *)'
   66 | extern char                             *fssh_asctime(const struct fssh_tm *tm);
      |                                          ^~~~~~~~~~~~
../headers/private/fs_shell/fssh_api_wrapper.h:1442:25: error: conflicting types for 'fssh_gmtime'; have 'struct fssh_tm *(const fssh_time_t *)' {aka 'struct fssh_tm *(const long long int *)'}
 1442 | #define gmtime          fssh_gmtime
      |                         ^~~~~~~~~~~
../headers/private/fs_shell/fssh_time.h:71:26: note: previous declaration of 'fssh_gmtime' with type 'struct fssh_tm *(const fssh_time_t *)' {aka 'struct fssh_tm *(const long long int *)'}
   71 | extern struct fssh_tm   *fssh_gmtime(const fssh_time_t *timer);
      |                          ^~~~~~~~~~~
../headers/private/fs_shell/fssh_api_wrapper.h:1444:25: error: conflicting types for 'fssh_localtime'; have 'struct fssh_tm *(const fssh_time_t *)' {aka 'struct fssh_tm *(const long long int *)'}
 1444 | #define localtime       fssh_localtime
      |                         ^~~~~~~~~~~~~~
../headers/private/fs_shell/fssh_time.h:74:26: note: previous declaration of 'fssh_localtime' with type 'struct fssh_tm *(const fssh_time_t *)' {aka 'struct fssh_tm *(const long long int *)'}
   74 | extern struct fssh_tm   *fssh_localtime(const fssh_time_t *timer);
      |                          ^~~~~~~~~~~~~~
../headers/private/fs_shell/fssh_api_wrapper.h:1436:25: error: conflicting types for 'fssh_mktime'; have 'fssh_time_t(struct fssh_tm *)' {aka 'long long int(struct fssh_tm *)'}
 1436 | #define mktime          fssh_mktime
      |                         ^~~~~~~~~~~
../headers/private/fs_shell/fssh_time.h:64:33: note: previous declaration of 'fssh_mktime' with type 'fssh_time_t(struct fssh_tm *)' {aka 'long long int(struct fssh_tm *)'}
   64 | extern fssh_time_t              fssh_mktime(struct fssh_tm *tm);
      |                                 ^~~~~~~~~~~
../headers/private/fs_shell/fssh_api_wrapper.h:1446:25: error: conflicting types for 'fssh_strftime'; have 'fssh_size_t(char * restrict,  fssh_size_t,  const char * restrict,  const struct fssh_tm * restrict)' {aka 'long long unsigned int(char * restrict,  long long unsigned int,  const char * restrict,  const struct fssh_tm * restrict)'}
 1446 | #define strftime        fssh_strftime
      |                         ^~~~~~~~~~~~~
../headers/private/fs_shell/fssh_time.h:77:33: note: previous declaration of 'fssh_strftime' with type 'fssh_size_t(char *, fssh_size_t,  const char *, const struct fssh_tm *)' {aka 'long long unsigned int(char *, long long unsigned int,  const char *, const struct fssh_tm *)'}
   77 | extern fssh_size_t              fssh_strftime(char *buffer, fssh_size_t maxSize,
      |                                 ^~~~~~~~~~~~~
../headers/private/fs_shell/fssh_api_wrapper.h:1447:25: error: conflicting types for 'fssh_strptime'; have 'char *(const char * restrict,  const char * restrict,  struct fssh_tm * restrict)'
 1447 | #define strptime        fssh_strptime
      |                         ^~~~~~~~~~~~~
../headers/private/fs_shell/fssh_time.h:79:34: note: previous declaration of 'fssh_strptime' with type 'char *(const char *, const char *, struct fssh_tm *)'
   79 | extern char                     *fssh_strptime(const char *buf, const char *format,
      |                                  ^~~~~~~~~~~~~
../headers/private/fs_shell/fssh_api_wrapper.h:1439:25: error: conflicting types for 'fssh_asctime_r'; have 'char *(const struct fssh_tm * restrict,  char * restrict)'
 1439 | #define asctime_r       fssh_asctime_r
      |                         ^~~~~~~~~~~~~~
../headers/private/fs_shell/fssh_time.h:67:42: note: previous declaration of 'fssh_asctime_r' with type 'char *(const struct fssh_tm *, char *)'
   67 | extern char                             *fssh_asctime_r(const struct fssh_tm *timep,
      |                                          ^~~~~~~~~~~~~~
../headers/private/fs_shell/fssh_api_wrapper.h:1443:25: error: conflicting types for 'fssh_gmtime_r'; have 'struct fssh_tm *(const fssh_time_t * restrict,  struct fssh_tm * restrict)' {aka 'struct fssh_tm *(const long long int * restrict,  struct fssh_tm * restrict)'}
 1443 | #define gmtime_r        fssh_gmtime_r
      |                         ^~~~~~~~~~~~~
../headers/private/fs_shell/fssh_time.h:72:26: note: previous declaration of 'fssh_gmtime_r' with type 'struct fssh_tm *(const fssh_time_t *, struct fssh_tm *)' {aka 'struct fssh_tm *(const long long int *, struct fssh_tm *)'}
   72 | extern struct fssh_tm   *fssh_gmtime_r(const fssh_time_t *timer,
      |                          ^~~~~~~~~~~~~
../headers/private/fs_shell/fssh_api_wrapper.h:1445:25: error: conflicting types for 'fssh_localtime_r'; have 'struct fssh_tm *(const fssh_time_t * restrict,  struct fssh_tm * restrict)' {aka 'struct fssh_tm *(const long long int * restrict,  struct fssh_tm * restrict)'}
 1445 | #define localtime_r     fssh_localtime_r
      |                         ^~~~~~~~~~~~~~~~
../headers/private/fs_shell/fssh_time.h:75:26: note: previous declaration of 'fssh_localtime_r' with type 'struct fssh_tm *(const fssh_time_t *, struct fssh_tm *)' {aka 'struct fssh_tm *(const long long int *, struct fssh_tm *)'}
   75 | extern struct fssh_tm   *fssh_localtime_r(const fssh_time_t *timer,
      |                          ^~~~~~~~~~~~~~~~
In file included from ../src/add-ons/kernel/file_systems/fat/dosfs.h:11,
                 from ../src/add-ons/kernel/file_systems/fat/bsd/sys/systm.h:51,
                 from ../src/add-ons/kernel/file_systems/fat/bsd/kern/subr_clock.c:50:
../src/add-ons/kernel/file_systems/fat/fssh_defines.h:26: warning: "howmany" redefined
   26 | #define howmany(x, y) (((x) + ((y) - 1)) / (y))
      | 
/Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/sys/types.h:191: note: this is the location of the previous definition
  191 | #define howmany(x, y)   __DARWIN_howmany(x, y)  /* # y's == x bits? */
      | 

Since it mentions MacOSX15.sdk, the headers are not being accessed from the cross-compiler. There are no such headers in the Haiku SDK. Make sure you’re accessing the right G++ executable.

That’s normal at this point in the build. This is building the fat_shell for Mac OS, which can then be used to create the EFI partition in the final image.

The Haiku build system involves building several tools on the host, which of course does not use the Haiku specific compiler. This is the part of the build that is a bit tricky to get working everywhere, because it has to work on very different configurations.

Once issues in that part are resolved, the other parts of the build should be fine.

It looks like the sys/types.h from the FAT filesystem is trying to include the system sys/types.h (with an include_next) even when building in fs_shell mode. In that mode, I think no system ehaders should be included, as the fs_shell infrastructure wraps them all and handles defining macros to have things closer to how they behave in Haiku.

It is a bit tricky here because the FAT code is imported from FreeBSD, and so we end up with the FAT code calling a FreeBSD compatibility layer, that then calls a Haiku compatibility layer in the fs_shell.

I think you can disable the include of the system sys/types.h from fat/bsd/sys/types.h with a #ifndef FS_SHELL, and the defines from fssh_api_wrapper should take over and provide the needed definitions.

1 Like

Hi OP, Did you find a solution ? I am in a similar situation and cannot get Haiku to compile on Mac OS. Getting the same errors as you are.