LoginSignup
1
0

More than 1 year has passed since last update.

Macports で Rustのビルドでエラーが出てしまった。さぁ、どうするっ!

Last updated at Posted at 2023-01-18

状況

macportsでとあるソフトウェアをインストールしようとした際に、依存関係(の依存関係(の依存関係...))によりrustがインストールされる途中でエラーが出てビルドが止まってしまって、お目当てのソフトがインストールできない。私自身はいまのところRustを使った開発とかはしていないのでRustのパフォーマンスはベストでなくてもいいが、とりあえずrustのビルドが正常に終わってもらわないと困る。さぁ、バービブ1

テスト環境

  • macOS 12.6.2 Monterey
  • Mac mini (M1, 2020) Apple M1
  • macports-2.8.0
  • rust @1.66.1_0

症状

-vオプションつきでビルドしてみる。

実行結果
% port -v build rust 
--->  Computing dependencies for rust.
--->  Building rust
...
(途中省略)
...
<jemalloc>: Error allocating TSD
rustc exited with signal: 6 (SIGABRT)

command did not execute successfully: "(macportsのディレクトリ名)/var/macports/build/...(途中略).../rust/work/cargo-1.65.0-x86_64-apple-darwin/cargo/bin/cargo" "build" "--target" "x86_64-apple-darwin" "-Zcheck-cfg=names,values,output" "-Zbinary-dep-depinfo" "-j" "8" "-v" "-v" "--release" "--features" "panic-unwind backtrace" "--manifest-path" "(macportsのディレクトリ名)/var/macports/build/...(途中略).../rust/work/rustc-1.66.1-src/library/test/Cargo.toml" "--message-format" "json-render-diagnostics"
expected success, got: exit status: 101

というところで、cargoなるものを実行しようとしてランタイムエラーが出ている模様。jemallocというのがキーワードの様。

対処

Portfileを見ると、なんだか怪しそうな設定がある。Googleで調べてもこのへんで苦労している人がいる模様。

Portfile
if { ${os.platform} eq "darwin" && ${os.major} > 14 } {
    configure.args-append   --set=rust.jemalloc
    if { ${os.arch} eq "arm" } {
        # specify the number of significant virtual address bits in jmalloc
        # the configure script calls cpuid, but it does not work properly on Rosetta 2
        # see https://github.com/jemalloc/jemalloc/issues/1997#issuecomment-1041589117
        build.env.x86_64-append JEMALLOC_SYS_WITH_LG_VADDR=48
    }
}

今のところRustのメモリアロケータにこだわりはないので、ここをざっくりコメントアウトしたら、一応ビルドは正常終了して、依存関係が満たされてお目当てのソフトウェアがインストールできたのだっ2!

Portfile修正前後の差分
--- ${macports_root}/var/macports/sources/rsync.macports.org/macports/release/tarballs/ports/lang/rust/Portfile.orig  2023-01-18 16:26:12.000000000 +0900
+++ ${macports_root}/var/macports/sources/rsync.macports.org/macports/release/tarballs/ports/lang/rust/Portfile       2023-01-18 19:06:01.000000000 +0900
@@ -137,15 +137,15 @@ configure.args-append       --disable-co
 if { ${os.platform} eq "darwin" && ${os.major} < 9 } {
     configure.args-append   --disable-rpath
 }
-if { ${os.platform} eq "darwin" && ${os.major} > 14 } {
-    configure.args-append   --set=rust.jemalloc
-    if { ${os.arch} eq "arm" } {
-        # specify the number of significant virtual address bits in jmalloc
-        # the configure script calls cpuid, but it does not work properly on Rosetta 2
-        # see https://github.com/jemalloc/jemalloc/issues/1997#issuecomment-1041589117
-        build.env.x86_64-append JEMALLOC_SYS_WITH_LG_VADDR=48
-    }
-}
+# if { ${os.platform} eq "darwin" && ${os.major} > 14 } {
+#     configure.args-append   --set=rust.jemalloc
+#     if { ${os.arch} eq "arm" } {
+#         # specify the number of significant virtual address bits in jmalloc
+#         # the configure script calls cpuid, but it does not work properly on Rosetta 2
+#         # see https://github.com/jemalloc/jemalloc/issues/1997#issuecomment-1041589117
+#         build.env.x86_64-append JEMALLOC_SYS_WITH_LG_VADDR=48
+#     }
+# }
 
 foreach arch ${muniversal.architectures} {
     set platform            [option triplet.${arch}]
  1. バービブとは

  2. ...のだっ!

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0