oxidize-rb / cross-gem-action

GitHub action to cross compile a Ruby gem written in Rust
MIT License
17 stars 4 forks source link

Support for removing debuginfo and symbols #112

Closed ankane closed 1 year ago

ankane commented 1 year ago

Hey,

I was wondering if there was a way for the action to support the strip option, which can significantly reduce the binary size.

[profile.release]
strip = true

It currently fails on x86_64-darwin with:

warning: stripping debug info with `strip` failed: exit status: 1
  |
  = note: strip: /home/runner/work/tokenizers-ruby/tokenizers-ruby/tmp/x86_64-darwin/tokenizers/3.1.0/target/x86_64-apple-darwin/release/deps/libtokenizers.dylib: file format not recognized
ankane commented 1 year ago

It looks like strip is hard-coded, but creating a symlink in setup works.

    strategy:
      matrix:
        include:
          - platform: x86_64-darwin
            setup: sudo ln -s /opt/osxcross/target/bin/x86_64-apple-darwin-strip /usr/local/bin/strip
    steps:
      - uses: oxidize-rb/cross-gem-action@v7
        with:
          platform: ${{ matrix.platform }}
          setup: |
            bundle install
            ${{ matrix.setup }}
ankane commented 1 year ago

Path for more platforms:

ankane commented 1 year ago

Correction for future readers: This approach only applies to x86_64-darwin, since it breaks code signing on arm64-darwin (#135) and stripping happens during linking on other supported platforms