cmu-db / bustub

The BusTub Relational Database Management System (Educational)
https://15445.courses.cs.cmu.edu/
MIT License
3.92k stars 1.76k forks source link

bug: "ld: library not found for -liberty" on macOS 14.3 apple silicon #700

Closed hiyasame closed 5 months ago

hiyasame commented 6 months ago

branch: 2023fall release

rain@MacBookPro:~/R/p/b/build|master⚡*
➤ make
[  1%] Built target bustub_murmur3
[  8%] Built target duckdb_pg_query
[ 10%] Built target gtest
[ 10%] Built target gmock
[ 11%] Built target gmock_main
[ 11%] Built target gtest_main
[ 13%] Built target fmt
[ 15%] Built target bustub_linenoise
[ 16%] Built target fort
[ 18%] Built target utf8proc
[ 18%] Built target backward_object
[ 20%] Built target backward
[ 26%] Built target bustub_optimizer
[ 33%] Built target bustub_binder
[ 36%] Built target bustub_statement
[ 40%] Built target bustub_buffer
[ 41%] Built target bustub_catalog
[ 43%] Built target bustub_common
[ 45%] Built target bustub_concurrency
[ 46%] Built target bustub_container_disk_hash
[ 61%] Built target bustub_execution
[ 63%] Built target bustub_recovery
[ 65%] Built target bustub_storage_disk
[ 68%] Built target bustub_storage_index
[ 76%] Built target bustub_storage_page
[ 78%] Built target bustub_storage_table
[ 85%] Built target bustub_type
[ 91%] Built target bustub_planner
[ 91%] Built target bustub_primer
[ 91%] Built target bustub
[ 91%] Linking CXX executable ../../bin/bustub-shell
Homebrew clang version 14.0.6
Target: arm64-apple-darwin23.3.0
Thread model: posix
InstalledDir: /opt/homebrew/bin
 "/usr/bin/ld" -demangle -lto_library /opt/homebrew/Cellar/llvm@14/14.0.6/lib/libLTO.dylib -no_deduplicate -dynamic -arch arm64 -platform_version macos 14.0.0 14.0 -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -o ../../bin/bustub-shell -search_paths_first -headerpad_max_install_names CMakeFiles/shell.dir/shell.cpp.o ../../lib/libbustub.a ../../lib/libbustub_linenoise.a ../../lib/libutf8proc.a /usr/local/lib/libbfd.a /Applications/xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/lib/libdl.tbd -liberty -lz ../../lib/libbustub_murmur3.a ../../lib/libduckdb_pg_query.a ../../lib/libfmtd.a ../../lib/libfort.a -lc++ /opt/homebrew/Cellar/llvm@14/14.0.6/lib/clang/14.0.6/lib/darwin/libclang_rt.asan_osx_dynamic.dylib -rpath @executable_path -rpath /opt/homebrew/Cellar/llvm@14/14.0.6/lib/clang/14.0.6/lib/darwin -lSystem /opt/homebrew/Cellar/llvm@14/14.0.6/lib/clang/14.0.6/lib/darwin/libclang_rt.osx.a
ld: library not found for -liberty
clang-14: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [bin/bustub-shell] Error 1
make[1]: *** [tools/shell/CMakeFiles/shell.dir/all] Error 2
make: *** [all] Error 2
hiyasame commented 5 months ago

I've resolved the issue. The binutils installed with brew install binutils does not come with libiberty. I downloaded the source using wget https://ftp.gnu.org/gnu/binutils/binutils-2.41.tar.bz2, compiled libiberty.a, and moved it to the binutils lib directory. This fixed the problem.