|
| 1 | +# MacOS Build Common Errors |
| 2 | + |
| 3 | +## fdopen macro redefinition error |
| 4 | + |
| 5 | +During `make check-binutils`, you may see an error like this: |
| 6 | +```bash |
| 7 | +In file included from /Volumes/case-sensitive/riscv-gnu-toolchain/binutils/zlib/zlib/zutil.c:10: |
| 8 | +In file included from /Volumes/case-sensitive/riscv-gnu-toolchain/binutils/zlib/zlib/gzguts.h:21: |
| 9 | +In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdio.h:61: |
| 10 | +/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/_stdio.h:322:7: error: expected identifier or '(' |
| 11 | + 322 | FILE *fdopen(int, const char *) __DARWIN_ALIAS_STARTING(__MAC_10_6, __IPHONE_2_0, __DARWIN_ALIAS(fdopen)); |
| 12 | + | ^ |
| 13 | +/Volumes/case-sensitive/riscv-gnu-toolchain/binutils/zlib/zlib/zutil.h:147:33: note: expanded from macro 'fdopen' |
| 14 | + 147 | # define fdopen(fd,mode) NULL /* No fdopen() */ |
| 15 | + | ^ |
| 16 | +/Library/Developer/CommandLineTools/usr/lib/clang/17/include/__stddef_null.h:26:16: note: expanded from macro 'NULL' |
| 17 | + 26 | #define NULL ((void*)0) |
| 18 | + | ^ |
| 19 | +``` |
| 20 | + |
| 21 | +Then, upate the `binutils` repository to the latest commit on the `gdb-17-branch`. The easiest way to do this is (in the `riscv-gnu-toolchain` folder): |
| 22 | + |
| 23 | +```bash |
| 24 | +rm -rf binutils |
| 25 | +git clone https://github.com/bminor/binutils-gdb binutils |
| 26 | +cd binutils |
| 27 | +git checkout gdb-17-branch |
| 28 | +cd .. |
| 29 | +``` |
| 30 | +(The gdb-17-branch was last tested to be working on MacOS Tahoe 26.2 (25C56) on an M2 Max machine model A2779) |
| 31 | + |
| 32 | + |
| 33 | +## Bison/YACC related errors |
| 34 | +There may be missing files errors like this during `make`: |
| 35 | +```bash |
| 36 | +clang: error: no such file or directory: '/Volumes/case-sensitive/riscv-gnu-toolchain/binutils/binutils/sysinfo.c' |
| 37 | +clang: error: no input files |
| 38 | +gmake[3]: *** [Makefile:1897: sysinfo.o] Error 1 |
| 39 | +gmake[3]: Leaving directory '/Volumes/case-sensitive/riscv-gnu-toolchain/build-binutils-newlib/binutils' |
| 40 | +``` |
| 41 | +To fix this, you need to run some files manually through Bison in YACC mode: |
| 42 | +```bash |
| 43 | +cd binutils/binutils |
| 44 | +bison -y -o sysinfo.c sysinfo.y |
| 45 | +bison -y -d --defines=sysinfo.h -o sysinfo.c sysinfo.y |
| 46 | +bison -d --defines=arparse.h -o arparse.c arparse.y |
| 47 | + |
| 48 | +cd binutils/ld |
| 49 | +bison -d --defines=ldgram.h -o ldgram.c ldgram.y |
| 50 | +``` |
0 commit comments