sold: Cannot build sold on MacOS by following build instructions

Following the build instructions at https://github.com/rui314/mold#how-to-build:

git clone git@github.com:bluewhalesystems/sold.git
mkdir sold/build
cd sold/build
git checkout v1.10.1
../install-build-deps.sh
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=c++
cmake --build . -j $(nproc)
sudo cmake --install .

Fails at various points:

%  git checkout v1.10.1         
error: pathspec 'v1.10.1' did not match any file(s) known to git
% ../install-build-deps.sh 
../install-build-deps.sh: line 3: /etc/os-release: No such file or directory
% sw_vers
ProductName:	macOS
ProductVersion:	12.6.1
BuildVersion:	21G217

Xcode Version 14.2 (14C18)

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 18 (8 by maintainers)

Most upvoted comments

Maybe we could add this to the README:


Install

git clone git@github.com:bluewhalesystems/sold.git
mkdir sold/build
cd ./sold/build
# if you don't have cmake, please run:
# brew install cmake
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=c++ ..
cmake --build . -j $(sysctl -n hw.ncpu)
sudo cmake --build . --target install

Note: the command to use sold is, by default, mold

 

Rust

To use sold with Rust, create .cargo/config.toml at the root of your project with the following:

[target.<platform>]
linker = "clang"
rustflags = ["-C", "link-arg=-fuse-ld=/path/to/ld64.mold"]

Change /path/to/mold to the absolute path of the mold executable (usually /usr/local/bin/ld64.mold)

Then find out what your platform is:

rustc -vV | sed -n 's|host: ||p'

…and replace the <platform> in your config.toml with it.

 

Checking whether mold was used to link a binary

To find out whether mold was used to link your binary, run

otool -l <your-binary> | grep 'tool '

When mold was used, the output should contain tool 54321