raspberrypi / usbboot

Raspberry Pi USB booting code, moved from tools repository
Apache License 2.0
878 stars 221 forks source link

AvailabilityInternalLegacy.h not found on macOS Sanoma 14.0 (23A344) #188

Closed Binarytales closed 8 months ago

Binarytales commented 9 months ago

Describe the bug

Following the steps for building on macOS I get the following error when running make:

$ make
cc -Wall -Wextra -g -o bin2c bin2c.c
In file included from bin2c.c:1:
In file included from /usr/local/include/stdio.h:64:
In file included from /usr/local/include/_stdio.h:69:
In file included from /usr/local/include/Availability.h:168:
/usr/local/include/AvailabilityInternal.h:153:10: fatal error: 'AvailabilityInternalLegacy.h' file not found
#include <AvailabilityInternalLegacy.h>
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [bin2c] Error 1

Steps to reproduce the behaviour

Follow macOS build steps exactly: https://github.com/raspberrypi/usbboot?tab=readme-ov-file#macos

I also ran the optional command to set PKG config path: export PKG_CONFIG_PATH="$(brew --prefix libusb)/lib/pkgconfig" which set the path to /usr/local/opt/libusb/lib/pkgconfig


To fix a previous make error:

$ make                                                   
cc -Wall -Wextra -g -o bin2c bin2c.c
ld: library not found for -lSystem
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [bin2c] Error 1

I had to not only update XCode via the AppStore (to version 15.0 (15A240d)) but also open and run XCode to let it install additional packages and libraries. Having only XCode Command Line Tools installed was not enough.

I also had to run sudo xcodebuild -license accept to accept the updated terms and conditions.

-- I am running:

...on a...


Output of brew config

HOMEBREW_VERSION: 4.1.14
ORIGIN: https://github.com/Homebrew/brew
HEAD: affc4c01aada2c973b63e084e7696e896edf2b7b
Last commit: 8 days ago
Core tap JSON: 08 Oct 22:34 UTC
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 16
Homebrew Ruby: 2.6.10 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: 16-core 64-bit kabylake
Clang: 15.0.0 build 1500
Git: 2.23.0 => /usr/local/bin/git
Curl: 8.1.2 => /usr/bin/curl
macOS: 14.0-x86_64
CLT: 15.0.0.0.1.1694021235
Xcode: 15.0

Output of brew leaves | xargs brew info

==> go: stable 1.21.2 (bottled), HEAD
Open source programming language to build simple/reliable/efficient software
https://go.dev/
/usr/local/Cellar/go/1.21.1 (12,527 files, 242.7MB) *
  Poured from bottle using the formulae.brew.sh API on 2023-09-14 at 18:00:56
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/g/go.rb
License: BSD-3-Clause
==> Options
--HEAD
        Install HEAD version
==> Analytics
install: 87,456 (30 days), 264,224 (90 days), 543,350 (365 days)
install-on-request: 63,082 (30 days), 194,614 (90 days), 403,626 (365 days)
build-error: 161 (30 days)

==> libusb: stable 1.0.26 (bottled), HEAD
Library for USB device access
https://libusb.info/
/usr/local/Cellar/libusb/1.0.26 (22 files, 531.7KB) *
  Poured from bottle using the formulae.brew.sh API on 2023-10-08 at 23:37:24
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/lib/libusb.rb
License: LGPL-2.1-or-later
==> Options
--HEAD
        Install HEAD version
==> Analytics
install: 18,732 (30 days), 47,297 (90 days), 136,553 (365 days)
install-on-request: 3,683 (30 days), 9,563 (90 days), 23,956 (365 days)
build-error: 0 (30 days)

==> pkg-config: stable 0.29.2 (bottled)
Manage compile and link flags for libraries
https://freedesktop.org/wiki/Software/pkg-config/
/usr/local/Cellar/pkg-config/0.29.2_3 (11 files, 656.4KB) *
  Poured from bottle using the formulae.brew.sh API on 2023-10-08 at 23:37:44
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/p/pkg-config.rb
License: GPL-2.0-or-later
==> Analytics
install: 47,652 (30 days), 128,023 (90 days), 327,335 (365 days)
install-on-request: 14,113 (30 days), 41,200 (90 days), 101,914 (365 days)
build-error: 227 (30 days)

==> webp: stable 1.3.2 (bottled), HEAD
Image format providing lossless and lossy compression for web images
https://developers.google.com/speed/webp/
/usr/local/Cellar/webp/1.3.2 (63 files, 2.6MB) *
  Poured from bottle using the formulae.brew.sh API on 2023-09-14 at 17:58:14
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/w/webp.rb
License: BSD-3-Clause
==> Dependencies
Build: cmake ✘
Required: giflib ✔, jpeg-turbo ✔, libpng ✔, libtiff ✘
==> Options
--HEAD
        Install HEAD version
==> Analytics
install: 136,812 (30 days), 316,044 (90 days), 728,085 (365 days)
install-on-request: 42,042 (30 days), 116,632 (90 days), 245,923 (365 days)
build-error: 79 (30 days)

An ls of /usr/local/include gives the following:

$ ls /usr/local/include 
AppleTextureEncoder.h  arpa                   dns_sd.h               iconv.h                localcharset.h         nfs                    readline               stringlist.h           turbojpeg.h
AssertMacros.h         asl.h                  dns_util.h             ifaddrs.h              locale.h               nl_types.h             readpassphrase.h       strings.h              tzfile.h
Availability.h         assert.h               dtrace.h               inttypes.h             lz4.h                  nlist.h                regex.h                struct.h               ucontext.h
AvailabilityInternal.h atm                    editline               iso646.h               lz4frame.h             node                   removefile.h           sys                    ulimit.h
AvailabilityMacros.h   bank                   err.h                  jconfig.h              lz4frame_static.h      notify.h               resolv.h               sysdir.h               unctrl.h
AvailabilityVersions.h bitstring.h            errno.h                jerror.h               lz4hc.h                notify_keys.h          rpc                    sysexits.h             unistd.h
Block.h                bootparams.h           eti.h                  jmorecfg.h             lzma                   ntsid.h                rpcsvc                 syslog.h               unwind.h
CommonCrypto           bootstrap.h            execinfo.h             jpeglib.h              lzma.h                 objc                   rune.h                 tar.h                  util.h
ConditionalMacros.h    bsm                    expat.h                kern                   mach                   odmodule               runetype.h             tcl.h                  utime.h
Darwin.apinotes        bzlib.h                expat_external.h       krb5                   mach-o                 os                     sandbox.h              tclDecls.h             utmp.h
EndpointSecurity       cache.h                fcntl.h                krb5.h                 mach_debug             panel.h                sasl                   tclPlatDecls.h         utmpx.h
MacTypes.h             cache_callbacks.h      fenv.h                 langinfo.h             machine                paths.h                sched.h                tclTomMath.h           uuid
NSSystemDirectories.h  checkint.h             ffi                    launch.h               malloc                 pcap                   search.h               tclTomMathDecls.h      vfs
TargetConditionals.h   com_err.h              float.h                lber.h                 math.h                 pcap-bpf.h             secure                 term.h                 vis.h
Xplugin.h              complex.h              fmtmsg.h               lber_types.h           membership.h           pcap-namedb.h          security               term_entry.h           voucher
__cxxabi_config.h      compression.h          fnmatch.h              ldap.h                 memory.h               pcap.h                 semaphore.h            termcap.h              vproc.h
__wctype.h             copyfile.h             form.h                 ldap_cdefs.h           menu.h                 pexpert                servers                termios.h              wchar.h
_ctermid.h             corpses                fsproperties.h         ldap_features.h        miscfs                 php                    setjmp.h               tgmath.h               wctype.h
_ctype.h               cpio.h                 fstab.h                ldap_schema.h          module.modulemap       png.h                  sgtty.h                tic.h                  webp
_locale.h              crt_externs.h          fts.h                  ldap_utf8.h            monetary.h             pngconf.h              signal.h               tidy                   wordexp.h
_regex.h               ctype.h                ftw.h                  ldif.h                 monitor.h              pnglibconf.h           simd                   tiff.h                 xar
_stdio.h               cups                   get_compat.h           libc.h                 mpool.h                poll.h                 slapi-plugin.h         tiffconf.h             xattr_flags.h
_types                 curl                   gethostuuid.h          libcharset.h           nameser.h              printerdb.h            spawn.h                tiffio.h               xcselect.h
_types.h               curses.h               getopt.h               libexslt               nc_tparm.h             printf.h               sqlite3.h              tiffio.hxx             xlocale
_wctype.h              cxxabi.h               gif_lib.h              libgen.h               ncurses.h              profile.h              sqlite3ext.h           tiffvers.h             xlocale.h
_xlocale.h             db.h                   glob.h                 libkern                ncurses_dll.h          protocols              stab.h                 time.h                 xpc
aio.h                  default_pager          grp.h                  libpng16               ndbm.h                 pthread                standards.h            timeconv.h             zconf.h
aliasdb.h              device                 gssapi                 libproc.h              net                    pthread.h              stddef.h               tk.h                   zdict.h
alloca.h               dirent.h               gssapi.h               libunwind.h            net-snmp               pthread_impl.h         stdint.h               tkDecls.h              zlib.h
apache2                disktab.h              hfs                    libusb-1.0             netdb.h                pthread_spis.h         stdio.h                tkIntXlibDecls.h       zstd.h
apr-1                  dispatch               hid                    libxml2                netinet                pwd.h                  stdlib.h               tkMacOSX.h             zstd_errors.h
ar.h                   dlfcn.h                histedit.h             libxslt                netinet6               python2.7              strhash.h              tkPlatDecls.h
architecture           dns.h                  i386                   limits.h               netkey                 ranlib.h               string.h               ttyent.h

Device(s)

Other

Compute Module IO board.

No response

RPIBOOT logs

No response

Kernel logs

No response

Device UART logs

No response

pelwell commented 9 months ago

bin2c.c is POSIX-compatible c. If that doesn't build on Sonoma then there's not a lot we can do about it.

pelwell commented 9 months ago

See https://discourse.nixos.org/t/fatal-error-os-availability-h-file-not-found/5331

Binarytales commented 8 months ago

@pelwell Thanks for your messages. That set me off on a new tangent that lead to me doing the following:

export CPATH=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/

Which fixed the error in my initial bug report. But then I was getting a ld: library 'System' not found. A bit more reading and I did:

export LIBRARY_PATH="$LIBRARY_PATH:/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib"

I got 193 warnings about pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) but these were all from the MacOSX.sdk path so not an issue with usbboot.