[MacPorts] #64146: rust on Mac OS 10.6.8?

MacPorts noreply at macports.org
Tue Dec 7 19:59:24 UTC 2021


#64146: rust on Mac OS 10.6.8?
--------------------------+----------------------
  Reporter:  catap        |      Owner:  catap
      Type:  enhancement  |     Status:  assigned
  Priority:  Normal       |  Milestone:
 Component:  ports        |    Version:  2.7.1
Resolution:               |   Keywords:
      Port:  rust         |
--------------------------+----------------------

Comment (by catap):

 Ok, I've successfully build rustc for `MACOSX_DEPLOYMENT_TARGET=10.6`.

 It was a tricky and I'd love to keep here how I did it.

 The first things that I need is LLVM from this brnach:
 https://github.com/catap/llvm-project/tree/macOS-emulated-tlv it contains
 the master branch plus one commit. Which one? Enabling emulation of TLV
 before macOS 10.7. I've also reported this patch to upstream
 https://reviews.llvm.org/D115250.

 From my point of view we may enable it branch for all clang/llvm versions
 on all platforms. Anyway, until it is done I need LLVM/clang from this
 branch.

 I've configured this LLVM/clang as:
 {{{
 cmake -S llvm -B build -G Ninja \
       -DCMAKE_BUILD_TYPE=Release \
       -DCMAKE_INSTALL_PREFIX=/Users/catap/src/llvm-project/dist \
       -DCOMPILER_RT_BUILD_SANITIZERS=OFF \
       -DLLVM_TARGETS_TO_BUILD=X86 \
       -DLLVM_ENABLE_PROJECTS="clang;lld;compiler-rt"
 }}}
 and build it as
 {{{
 cmake --build build
 }}}
 and finally install it as
 {{{
 cmake --install build
 }}}

 So, now I have a folder `/Users/catap/src/llvm-project/dist` which
 contains LLVM/Clang which supports `_thread` on macOS before 10.7 on my
 laptop under 12.

 I've used rust from git repo with local root
 f1edd0429582dd29cccacaf50fd134b05593bd9c which is `tag:1.57.0`.

 The first step is incorporate a patch which to LLVM inside rust, like
 this:
 ```
 cd src/llvm-project
 git remote add catap https://github.com/catap/llvm-project
 git remote update
 git cherry-pick catap/macOS-emulated-tlv
 cd ../../
 git add src/llvm-project
 git commit -S -m 'Includes catap/llvm-project:macOS-emulated-tlv'
 ```

 I must create a commit to be protected from `git submodule update` which
 may dissmiss my cherry-pick ;)

 Now, let's configure rust:
 ```
 env MACOSX_DEPLOYMENT_TARGET=10.6 \
     PATH=/Users/catap/src/llvm-project/dist/bin:$PATH \
     LD_LIBRARY_PATH=/Users/catap/src/llvm-project/dist/lib \
     DYLD_LIBRARY_PATH=/Users/catap/src/llvm-project/dist/lib \
     PKG_CONFIG_PATH=/Users/catap/src/llvm-project/pkgconfig
     CC=clang CXX=clang++ \
     ./configure \
     --default-linker=clang \
     --build=x86_64-apple-darwin \
     --enable-extended \
     --tools=rustfmt,clippy,rls \
     --set=target.x86_64-apple-darwin.linker=clang \
     --set=target.x86_64-apple-darwin.ar=/Users/catap/src/llvm-
 project/dist/bin/llvm-ar \
     --set=target.x86_64-apple-darwin.ranlib=/Users/catap/src/llvm-
 project/dist/bin/ranlib
 ```
 and build it:
 ```
 env MACOSX_DEPLOYMENT_TARGET=10.6 \
     PATH=/Users/catap/src/llvm-project/dist/bin:$PATH \
     LD_LIBRARY_PATH=/Users/catap/src/llvm-project/dist/lib \
     DYLD_LIBRARY_PATH=/Users/catap/src/llvm-project/dist/lib \
     PKG_CONFIG_PATH=/Users/catap/src/llvm-project/pkgconfig
     CC=clang CXX=clang++ \
     make dist
 ```

 after a while I'll have distributive which I can run on macOS 10.6.

 I have no idea how to bootstrap rustc on the first place without repeating
 all this step inside upstream, and if anyone has an idea, I'd love to hear
 it.

 Because right now it is chicken and the eggs sort of issue.

-- 
Ticket URL: <https://trac.macports.org/ticket/64146#comment:4>
MacPorts <https://www.macports.org/>
Ports system for macOS


More information about the macports-tickets mailing list