Skip to content

Conversation

@keimatch
Copy link

@keimatch keimatch commented Jul 3, 2025

概要

macosで環境構築した際にクレートのバージョン、プラットフォーム間のバイナリ差分があり起動に失敗したため対応したPE

Issue

  • 関連する issue

詳細

発生した問題

  1. 依存関係の互換性エラー
  • tmtc-c2a v1.1.1 が古い gaia-ccsds-c2a v1.0.0 を使用
  • Telemetry 型に entries フィールドが存在しないコンパイルエラー
  1. プラットフォーム固有バイナリの問題
  • jrsonnet がLinux用バイナリをダウンロードしていたが、macOS ARM64環境で実行しており、「Not Found」エラーで実行できない
  1. クロスコンパイル設定の問題
  • .cargo/config.toml で i686-unknown-linux-gnu が固定で設定されていた
  • macOSに i686-linux-gnu-gcc クロスコンパイラが未インストール
  • CMakeが存在しないコンパイラを要求

実施した解決策

  1. 依存関係の更新
    boom-tools/install.sh
    前: tmtc-c2a --version 1.1.1
    後: tmtc-c2a --version 1.2.0

  2. プラットフォーム自動判定機能
    boom-tools/install.sh に下記を追加

  if [ "$os" = "darwin" ]; then
    curl -L "...jrsonnet-darwin-${arch}" -o ./bin/jrsonnet
  else
    curl -L "...jrsonnet-linux-${arch}" -o ./bin/jrsonnet
  fi
  1. 自動ターゲット検出
  // package.json
  "run:c2a": "cargo run --target $(rustc -vV | grep host | cut -d' ' -f2)"

  // build.rs
  if cfg!(target_os = "macos") {
      c2a_cmake.define("CMAKE_C_COMPILER", "clang");
      c2a_cmake.define("CMAKE_CXX_COMPILER", "clang++");
  }

  # .cargo/config.toml
  [build]
  # 固定ターゲットをコメントアウトし、自動検出に変更

検証結果

test へのリンクや,検証結果へのリンク

影響範囲

XX系の動作がガラッと変わる,とか.

補足

何かあれば

…ection

- Update tmtc-c2a version from 1.1.1 to 1.2.0 to fix compatibility issues
- Add platform detection for jrsonnet binary downloads (macOS/Linux support)
- Implement automatic target detection in package.json using rustc host info
- Add macOS compiler configuration in build.rs for proper CMake builds
- Remove fixed i686 target config to enable native platform builds
- Add architecture detection for proper 32bit/64bit build flags

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Comment on lines +3 to +7
let target_arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_else(|_| "x86_64".to_string());
let build_for_32bit = match target_arch.as_str() {
"i686" | "i586" | "arm" => "ON",
_ => "OFF",
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rust target から BUILD_FOR_32BIT 生やすのかなり妥当だ

Comment on lines +12 to +16
// Use system default compiler for macOS
if cfg!(target_os = "macos") {
c2a_cmake.define("CMAKE_C_COMPILER", "clang");
c2a_cmake.define("CMAKE_CXX_COMPILER", "clang++");
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これは悩ましい。SILS としてのビルドなら動けばいいぐらいなのでそんなに困らない気もしつつ、Apple clang は gcc とも clang ともビミョ~~~に違うので、デフォルトの選択肢として使いたい気はあまりしない。

"scripts": {
"build:tlmcmddb": "tlmcmddb-cli bundle --pretty tlm-cmd-db/TLM_DB/calced_data tlm-cmd-db/CMD_DB tlmcmddb.json",
"run:c2a": "cargo run",
"run:c2a": "cargo run --target $(rustc -vV | grep host | cut -d' ' -f2)",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

npm run run:c2a で target を指定するようにする + .cargo/config.toml で指定しない、のは、cargo run を基本的に npm 経由でしかしないのであれば妥当なんですが、現状はあんまりそうなってないのでちょっと違うかなあとなっています。ここらへんは実機・SILS両方にビルドしないといけない実際の C2A user プロジェクトでも毎回悩むところなんですが、ある程度のやり方は見えてきてはいるので、c2a-core をそれに合わせるのがよいだろうな。(なので、このパッチを入れる、というよりはちょっと違うことになりそう)

curl -L --proto '=https' --tlsv1.2 -sSf "https://raw.githubusercontent.com/cargo-bins/cargo-binstall/${BINSTALL_VERSION}/install-from-binstall-release.sh" | env BINSTALL_VERSION=${BINSTALL_VERSION} CARGO_HOME=$(pwd) bash

./bin/cargo-binstall --root . tmtc-c2a --version 1.1.1 --no-confirm
./bin/cargo-binstall --root . tmtc-c2a --version 1.2.0 --no-confirm
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これは更新忘れ。Renovate で更新するようにした気がしていたけど、動いてないな。そっちのデバッグのためにも別 PR でやりたいかも。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants