Open ppannuto opened 2 years ago
Update: mixing toolchains (i.e. using the GNU ar
while otherwise using mac-native tools via AR=/usr/local/opt/binutils/bin/ar ./build.sh
) results in more errors:
ld: warning: ignoring file libjim.a, building for macOS-x86_64 but attempting to link with file built for macOS-x86_64
Undefined symbols for architecture x86_64:
"_Jim_CreateInterp", referenced from:
_main in jimsh.o
"_Jim_Eval", referenced from:
_main in jimsh.o
"_Jim_EvalFile", referenced from:
_main in jimsh.o
"_Jim_EvalSource", referenced from:
_Jim_initjimshInit in initjimsh.o
"_Jim_FreeInterp", referenced from:
_main in jimsh.o
"_Jim_GetExitCode", referenced from:
_main in jimsh.o
"_Jim_InitStaticExtensions", referenced from:
_main in jimsh.o
"_Jim_InteractivePrompt", referenced from:
_main in jimsh.o
"_Jim_ListAppendElement", referenced from:
_JimSetArgv in jimsh.o
"_Jim_MakeErrorMessage", referenced from:
_main in jimsh.o
"_Jim_NewIntObj", referenced from:
_main in jimsh.o
_JimSetArgv in jimsh.o
"_Jim_NewListObj", referenced from:
_main in jimsh.o
_JimSetArgv in jimsh.o
"_Jim_NewStringObj", referenced from:
_main in jimsh.o
_JimSetArgv in jimsh.o
"_Jim_PackageProvide", referenced from:
_Jim_initjimshInit in initjimsh.o
"_Jim_RegisterCoreCommands", referenced from:
_main in jimsh.o
"_Jim_SetVariableStr", referenced from:
_main in jimsh.o
_JimSetArgv in jimsh.o
"_Jim_SetVariableStrWithStr", referenced from:
_main in jimsh.o
"_Jim_String", referenced from:
_main in jimsh.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [jimsh] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
Some light googling supports that the 'building for macOS-x86_64 but linking for macOS-x86_64' is indeed a symptom of trying to mix toolchains.
The GNU toolchain has a lot of assumptions that it will be used with gnu tools, and riscv-gnu-toolchain can't fix this. So yes, you need to use gnu tools as much as possible when building it. Using homebrew is recommended. I don't have access to a Mac, so I've never tested builds on Mac OS X. You might try asking someplace like the FSF GCC gcc-help mailing list.
The SiFive freedom-tools github repo has support for building on Mac OS X. But it only supports building a cross compiler for embedded elf so I don't know if that is helpful or not. https://github.com/sifive/freedom-tools
Trying to build on OS X fails around
make: *** [libfesvr.a] Error 1
. Digging into this a bit, it is because the build relies on GNU-onlyar
options:Where
/usr/bin/ar
, the defaultar
is the version installed natively on Mac, while:is the GNU version installed via
brew install binutils
.