@ledsun blog

無味の味は佳境に入らざればすなわち知れず

gccとclangが生成するアセンブリファイルを比較してみる

もっとCPUの気持ちが知りたいですか? - @ledsun blog で、本の環境と自信の環境で生成されるアセンブリファイルの命令が異なることに気がつきました。

X86アセンブラ/GASでの文法 - Wikibooks によると

GNU ASで使用されているAT&Tアセンブリ構文

というものがあるそうです。

オペレーションサフィックス 「pushl」とか「movl」とか、プッシュ命令やムーブ命令のうしろにエル「l」がサフィックスです。

データサイズなどを指定するためにサフィックスを指定する必要がある。

GASのアセンブリ命令では、一般にオペランドがどのサイズのデータを扱うか指定するために、b、s、w、l、q、tのいずれかの文字をオペランドの最後に付ける。これをサフィックスという。

ということは、もしかしてCPUアーキテクチャの違いではなく、コンパイラの違いなのでしょうか? clangで試してみます。

sudo apt install clangしてclangをインストールします。 つぎにclang -S calc1.cを実行して、アセンブリファイルを作成します。

        .text
        .file   "calc1.c"
        .globl  main                            # -- Begin function main
        .p2align        4, 0x90
        .type   main,@function
main:                                   # @main
        .cfi_startproc
# %bb.0:
        pushq   %rbp
        .cfi_def_cfa_offset 16
        .cfi_offset %rbp, -16
        movq    %rsp, %rbp
        .cfi_def_cfa_register %rbp
        subq    $32, %rsp
        movl    $0, -4(%rbp)
        movl    %edi, -8(%rbp)
        movq    %rsi, -16(%rbp)
        movl    $1, -20(%rbp)
        movl    $2, -24(%rbp)
        movl    -20(%rbp), %eax
        addl    -24(%rbp), %eax
        movl    %eax, -28(%rbp)
        movl    -28(%rbp), %esi
        leaq    .L.str(%rip), %rdi
        movb    $0, %al
        callq   printf@PLT
        xorl    %eax, %eax
        addq    $32, %rsp
        popq    %rbp
        .cfi_def_cfa %rsp, 8
        retq
.Lfunc_end0:
        .size   main, .Lfunc_end0-main
        .cfi_endproc
                                        # -- End function
        .type   .L.str,@object                  # @.str
        .section        .rodata.str1.1,"aMS",@progbits,1
.L.str:
        .asciz  "c = %d\n"
        .size   .L.str, 8

        .ident  "Ubuntu clang version 14.0.0-1ubuntu1"
        .section        ".note.GNU-stack","",@progbits
        .addrsig
        .addrsig_sym printf

movlやmovqが出てきます。 セクション名や行の順番がちがうけど、mainの中身は一緒でしょうか? diffを見てみます。

1,5d0
<       .file   "calc1.c"
<       .text
<       .section        .rodata
< .LC0:
<       .string "c = %d\n"
7,10c2,6
<       .globl  main
<       .type   main, @function
< main:
< .LFB0:
---
>       .file   "calc1.c"
>       .globl  main                            # -- Begin function main
>       .p2align        4, 0x90
>       .type   main,@function
> main:                                   # @main
12c8
<       endbr64
---
> # %bb.0:
15c11
<       .cfi_offset 6, -16
---
>       .cfi_offset %rbp, -16
17c13
<       .cfi_def_cfa_register 6
---
>       .cfi_def_cfa_register %rbp
19,36c15,33
<       movl    %edi, -20(%rbp)
<       movq    %rsi, -32(%rbp)
<       movl    $1, -12(%rbp)
<       movl    $2, -8(%rbp)
<       movl    -12(%rbp), %edx
<       movl    -8(%rbp), %eax
<       addl    %edx, %eax
<       movl    %eax, -4(%rbp)
<       movl    -4(%rbp), %eax
<       movl    %eax, %esi
<       leaq    .LC0(%rip), %rax
<       movq    %rax, %rdi
<       movl    $0, %eax
<       call    printf@PLT
<       movl    $0, %eax
<       leave
<       .cfi_def_cfa 7, 8
<       ret
---
>       movl    $0, -4(%rbp)
>       movl    %edi, -8(%rbp)
>       movq    %rsi, -16(%rbp)
>       movl    $1, -20(%rbp)
>       movl    $2, -24(%rbp)
>       movl    -20(%rbp), %eax
>       addl    -24(%rbp), %eax
>       movl    %eax, -28(%rbp)
>       movl    -28(%rbp), %esi
>       leaq    .L.str(%rip), %rdi
>       movb    $0, %al
>       callq   printf@PLT
>       xorl    %eax, %eax
>       addq    $32, %rsp
>       popq    %rbp
>       .cfi_def_cfa %rsp, 8
>       retq
> .Lfunc_end0:
>       .size   main, .Lfunc_end0-main
38,57c35,45
< .LFE0:
<       .size   main, .-main
<       .ident  "GCC: (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0"
<       .section        .note.GNU-stack,"",@progbits
<       .section        .note.gnu.property,"a"
<       .align 8
<       .long   1f - 0f
<       .long   4f - 1f
<       .long   5
< 0:
<       .string "GNU"
< 1:
<       .align 8
<       .long   0xc0000002
<       .long   3f - 2f
< 2:
<       .long   0x3
< 3:
<       .align 8
< 4:
---
>                                         # -- End function
>       .type   .L.str,@object                  # @.str
>       .section        .rodata.str1.1,"aMS",@progbits,1
> .L.str:
>       .asciz  "c = %d\n"
>       .size   .L.str, 8
>
>       .ident  "Ubuntu clang version 14.0.0-1ubuntu1"
>       .section        ".note.GNU-stack","",@progbits
>       .addrsig
>       .addrsig_sym printf

ああ、パラメーターとかも微妙に違うんですね。

もっとCPUの気持ちが知りたいですか?

peaks.cc

読んでみます。

「第2章 CPUと友達になろう」にC言語のプログラムをアセンブラにする方法が載っていました。 自分の環境でも試してみます。 WSL上のgccで試しました。

#include <stdio.h>

int main(int argc, char** argv)
{
        int a = 1;
        int b = 2;
        int c = a + b;
        printf("c = %d\n", c);
        return 0;
}

これをgcc calc1.cするとa.outファイルが出来ます。 objdumpコマンドを使う方法が載っていました。

ledsun@MSI:~/more_cpu_mind►objdump -d a.out

a.out:     file format elf64-x86-64


Disassembly of section .init:

0000000000001000 <_init>:

おお、書籍ではmach-o-arm64と表示されるところが、elf64-x86-64と表示されます。 CPU依存っぽさがでてます。

Cコンパイラ-Sオプションを使う方法も紹介されています。 gccでもオプションは共通です。 gcc -S calc1.cを実行するとcalc.sファイルができます。

        .file   "calc1.c"
        .text
        .section        .rodata
.LC0:
        .string "c = %d\n"
        .text
        .globl  main
        .type   main, @function
main:
.LFB0:
        .cfi_startproc
        endbr64
        pushq   %rbp
        .cfi_def_cfa_offset 16
        .cfi_offset 6, -16
        movq    %rsp, %rbp
        .cfi_def_cfa_register 6
        subq    $32, %rsp
        movl    %edi, -20(%rbp)
        movq    %rsi, -32(%rbp)
        movl    $1, -12(%rbp)
        movl    $2, -8(%rbp)
        movl    -12(%rbp), %edx
        movl    -8(%rbp), %eax
        addl    %edx, %eax
        movl    %eax, -4(%rbp)
        movl    -4(%rbp), %eax
        movl    %eax, %esi
        leaq    .LC0(%rip), %rax
        movq    %rax, %rdi
        movl    $0, %eax
        call    printf@PLT
        movl    $0, %eax
        leave
        .cfi_def_cfa 7, 8
        ret
        .cfi_endproc
.LFE0:
        .size   main, .-main
        .ident  "GCC: (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0"
        .section        .note.GNU-stack,"",@progbits
        .section        .note.gnu.property,"a"
        .align 8
        .long   1f - 0f
        .long   4f - 1f
        .long   5
0:
        .string "GNU"
1:
        .align 8
        .long   0xc0000002
        .long   3f - 2f
2:
        .long   0x3
3:
        .align 8
4:

大分違います。mov命令はなくてmovlmovq命令があります。 これがARM64とx86の違いなのでしょうか? わくわくしますね。

11月15日にポーランドにミサイルが落ちた事件の顛末

www3.nhk.or.jp

ベラルーシウクライナ軍のミサイルが落ちたみたいです。 11月にもポーランドにミサイルが落ちた事件があったと記憶しています。 ロシアのミサイルという説とウクライナのミサイルという説があったと記憶しています。 どういう結論に落ち着いたのかでしょうか?

en.m.wikipedia.org

Wikipediaに英語の記事がありました。 DeepLを使って読みました。

ウクライナ軍が発射した防空ミサイルであった可能性が高い

以上の情報は無いみたいです。

ポーランドベラルーシも同じS-300ミサイルというものらしいです。 ということは似た事件なのでしょうか?

WSL上の Ubuntu 20.04 LTS を 22.04 LTS へアップグレードする

Ubuntuをアップグレードしようとして22.04を見つけられなかった話 - @ledsun blog を試した時は22.04のLTSがでていませんでした。 8月にLTSがでています。 再度アップグレードに挑戦してみます。

現在のバージョンを確認します。

ledsun@MSI:/m/c/U/led_l►lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.5 LTS
Release:        20.04
Codename:       focal

sudo do-release-upgradeを実行します。 気になったメッセージを確認します。

Third party sources disabled

Some third party entries in your sources.list were disabled. You can
re-enable them after the upgrade with the 'software-properties' tool
or your package manager.

サードパーティーのsources.listが無効になるみたいです。 該当のパッケージが必要になったときに、追加し直せば良さそうです。

1 installed package is no longer supported by Canonical. You can
still get support from the community.

サポートされなくなるパッケージがあります。 なんというパッケージでしょうか? Detailを見てみます。

No longer supported: wslu

wsluって何でしょうか? 特にインストールした記憶がありません。

ASCII.jp:WSLにインストールされているファイルから原因となるパッケージを探す (1/2)

WSL(Windows Subsystem for Linux)のUbuntuディストリビューションにwsluパッケージが含まれるようになっているようだ。

WSL用のUbuntuにデフォルトで入っているみたいです。 今まで使った記憶は無いです。 何か必要な機能があるかもしれません。 一応、機能を確認してみます。

WSL用ユーティリティ「wslu」を使ってみる – ラボラジアン

wslview

概要

WSL側から、Windows側のブラウザでリンクを開くためのコマンドです。 ブラウザの起動処理は、「powershell.exe Start 」コマンドを実行しています。

このコマンドは便利そうです。 まあ、でも基本的に便利コマンドが入っているだけのようです。 ないから困るということはなさそうです。

How To Install wslu on Ubuntu 22.04 | Installati.one を見る限りではアップグレード後にインストールすることも出来そうです。 というわけで、アップグレードしてみましょう。

PostgreSQLが起動しているけど再起動しても良いか聞かれます。

YESと答えました。

サービスを再起動するときにいちいち聞かなくてもいい?と聞かれます。

YESと答えました。

あとでPostgreSQLを12から14にアップグレードしてねとガイダンスが表示されます。

OKを押します。

Remove obsolete packages?


146 packages are going to be removed. 2 new packages are going to be
installed.

Fetching and installing the upgrade can take several hours. Once the
download has finished, the process cannot be canceled.

今更やめられるのだろうか? YESと答えます。

System upgrade is complete.

Action required

Exit all other instances of Ubuntu WSL before continuing.

Unsaved progress may otherwise be lost.

To continue please press [ENTER]

PowerShellからwsl.exe --shutdownを実行して、WSLを一度終了します。 WSLを起動し直します。

ledsun@MSI:/m/c/U/led_l►lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.1 LTS
Release:        22.04
Codename:       jammy

アップグレードできたっぽいです。 30分くらいでできました。

参考

WSL上の Ubuntu 20.04 LTS を 22.04 LTS へアップグレードする - Qiita

Windows 11で日本語入力ON/OFFをCtrl + Spaceで切り替える

Windowsのキーボードレイアウト切り替えショートカットを絶対殺すマン - @ledsun blog でキーボードレイアウト切り替え設定を行いました。

このとき[入力言語の切り替え]を間違って設定しました。 [入力言語の切り替え][割り当てなし]に設定すると、IMEが起動出来なくなります。 日本語を入力できません。 また、OSを再起動するまで設定は反映はされません。 再起動するまで気がつきませんでした。

ちなみに僕は日本語英語の切り替えは[キー シーケンスの変更]から設定出来る

  • Ctrl + Shift
  • 左 Alt + Shift
  • アクサン グラーブ (USキーボードの場合はバッククォートキー)

ではなく、Ctrl + Spaceで行っています。 これは、[設定] > [言語と地域] > [日本語] > [言語のオプション] > [Microsoft IME] > [キーボードオプション] > [キーとタッチのカスタマイズ] で Ctrl + Spaceに「IME-オン/オフ」を設定しています。

Microsoft IME > キーとタッチのカスタマイズ

上の設定画面は階層が深すぎてメニューから探していっても見つかりません。

英語キーボードを日本語環境で使いこなすために必須の設定とは?:マピオンニュース

設定アプリケーションを起動して「IME」で検索を行い、「日本語IMEの設定」を選択する。 「キーとタッチのカスタマイズ」を選択する。

の手順で開くのが正解です。

Windowsのキーボードレイアウト切り替えショートカットを絶対殺すマン

Windows 11にはキーボードレイアウト切り替えのショートカットが存在します。 IMEATOKを使っていると、ふと気がつくとIMEMS-IMEに切り替わっていることがあります。 意図せずにキーボードレイアウト切り替えショートカットを触っているのが原因です。

キーボードレイアウト切り替えショートカットは次の2つがあります。

  1. 左Win + Space
  2. Ctrl + Shifet

これを殺します。

Win + Space

Disable Win+Space keyboard-layout switch in Windows 10 - Super User によるとPowerToysで変更出来るようです。

Micosoft StoreからPowerToysをインストールします。

Microsoft StoreからPowerToysをインストールします。

Keyboard Managerからショートカットの再マップを選びます。
Win (Left) と Space に Undefinedを割り当てます。

OKを押すと無効に出来ます。

Ctrl + Space

これはPowerToysでは設定出来ません。 設定してみると出来そうですがOKボタンの押すと失敗します。

日本語入力が勝手に切り替わるのを防ぐ方法。お気に入りのIMEに固定するには?【Windows Tips】 | できるネット によると [入力言語のホットキー]から設定出来ます。 Windows 11 で[入力言語のホットキー]を開く方法がわかりませんでした。

入力言語の切り替えを行うキーを変更する方法(Windows11、Windows10、Windows8.1、Windows7) | HP®カスタマーサポート によると [設定] > [時刻と言語] > [入力] > [キーボードの詳細設定] > [言語バーオプション] でした。

キーボードレイアウト切り替えを割り当てなしにしたところ

WSL上のUbuntuにrustをインストールする

Ruby 3.2.0がリリースされました。 rbenv + ruby-buildをつかってインストールできます。 Ruby 3.2.0のYJITを有効にするにはrustcがある環境でコンパイルする必要があります。 WSLにrustをインストールしていませんでした。 インストールします。

www.rust-lang.org

をみると、WSL用のガイダンスが大きく掲載されています。

WSL用のガイダンス

これに従って

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

を実行します。 成功します。 が、fish-shellではrustcコマンドが見つかりません。

インストール後の表示にsource "$HOME/.cargo/env"するようにアナウンスがでます。 しかしfish-shellではsource "$HOME/.cargo/env"の実行に失敗します。

source "$HOME/.cargo/env"の実行に失敗します。

検索したら Rustをインストール - macOS & fish-shellの場合 - Qiita が見つかりました。 OSは違いますがfash-shell用の設定が書いてありました。

一時的に設定する場合は

set -gx PATH "$HOME/.cargo/bin" $PATH;

永続的に設定する場合は

 set -U fish_user_paths $fish_user_paths $HOME/.cargo/bin

です。

親切ですね。 よく見ると rust の GitHub issueへのリンクが書いてあります。 年のために見ておきましょう。

https://github.com/rust-lang/rustup/issues/478#issuecomment-1288194464

For fish 3.2.0 or upper, released in March 2021, the easiest way to add rust to path permanently is like that:

fish_add_path $HOME/.cargo/bin

今のfish-shellはfish_add_pathと言うコマンドで環境変数PATHを設定するみたいです。

rustcコマンドが呼び出せるようになったところ

一つ賢くなりました。 Qiitaの記事とか書いておくもんですね。 4年前の自分に助けられました。

WSLgでGitKrakenを使う

現在はFork-gitとwslgitを組み合わせて使っています。 Windows上のリポジトリを見るときはFork-gitの設定を変更してwslgitを外しています。 少し面倒です。 GitのGUIクライアントをWindows用とWSL用でわけてしまえば、面倒な設定が不要になるのではないでしょうか?

snapを使ってインストールしました。

ledsun@MSI:/m/c/U/led_l►sudo snap install gitkraken
error: This revision of snap "gitkraken" was published using classic confinement and thus may
       perform arbitrary system changes outside of the security sandbox that snaps are usually
       confined to, which may put your system at risk.

       If you understand and want to proceed repeat the command including --classic.
ledsun@MSI:/m/c/U/led_l[1]►sudo snap install gitkraken --classic
gitkraken 9.0.0 from gitkraken✓ installed

gitkrakenコマンドで起動出来るようになりました。 GitHubアカウントでサインインしました。 アクセストークンの設定が上手く行かなかったので、手動でコピーして設定しました。 とりあえずローカルにあるリポジトリを開いてみます。

GitKrakenでリポジトリをひらいたところ

フォント小さいですね・・・ちょっとずつカスタマイズしながら日常的に使えるのか試してみたいと思います。

参考:How to install and use Gitkraken on Ubuntu with snap | TechRepublic

仕事で必要なのは技術力ではなく仕事力ではないか

yuheinakasaka.github.io

より

先日「育児など家庭の色々があって自分の時間が確保できなくなった。技術力を高めるための勉強ができなくて不安。」みたいな話を聞いた

それよりも「技術力を高めるための勉強ができなくて不安」という点が個人的には気になった 技術力とは何か?技術力が高くないとなぜ不安なのか?みたいな話

から、僕の脳内で膨らんだポエムです。 決して正しいことではないです。

この場合の技術力は、もしかすると社内での評価の源泉なのかもしれません。 多くの場合、会社内で技術力を評価されているエンジニアって、売上貢献度が低いです。 営利企業の場合、どうしても技術力よりも、売上貢献度の方を評価したくなります。 売上貢献度と技術力が両方高いエンジニアがいた場合、売上貢献度の方を注目します。 技術力って、少なくとも社内的には、あんまり強い武器ではないです。 ですので、技術力で評価されているってことは、売上貢献度で評価されていないってことです。

一方で売上貢献度って個人の努力でどうにもならなかったりします。 たまたま良いお客さんを捕まえたとか、たまたま時流にあった製品を掴んだとか。 割と運の要素が強いです。

「勝ちに不思議の勝ちあり、負けに不思議の負けなし。」

の通りです。

社内マーケティングとしては、自分の土俵を売上貢献度から変えます。 例えば、技術力です。 売上貢献度が低くて、技術力が高いエンジニアはここで、技術力を武器にします。 「最新の技術情報を社内の誰より速く知っています。」とか「社外の技術者に知られています」とか。 とくに後者はめっちゃ効きます。 売上貢献度での順位をひっくり返すに十分な破壊力があります。

さて、技術力で社内評価を築いている状態で「技術力を高めるための勉強」を禁止してみましょう。 めっちゃ不安になりませんか?

この不安は

仕事で必要なのは技術力ではなく仕事力ではないか

と向き合うしかない事への不安、なのかもしれません。

DockerイメージのベースをAlpineからDebianに変えた

ruby:3.0.1-alpine Dockerイメージでsimstring gemがビルドできない - @ledsun blogRuby 3.0.1 はAlpine上でC拡張Gemのビルドに失敗することがあるとわかりました。 では、3.0.5ではどうでしょうか?

config.status: error: in `/simstring':
config.status: error: Something went wrong bootstrapping makefile fragments
    for automatic dependency tracking.  If GNU make was not used, consider
    re-running the configure script with MAKE="gmake" (or whatever is
    necessary).  You can also try re-running configure with the
    '--disable-dependency-tracking' option to at least be able to build
    the package (albeit without support for automatic dependency tracking).
See `config.log' for more details
The command '/bin/sh -c git clone https://github.com/chokkan/simstring.git &&     cd simstring/ &&     autoreconf -i &&     ./configure &&     make &&     cd swig/ruby/ &&     ./prepare.sh &&     ruby extconf.rb &&     make &&     make install' returned a non-zero code: 1

違うエラーがでます。 このあとgithubからのgemのインストールが上手く行かないエラーもでました。 面倒になったので、Alpine Linuxを使うのをやめました。 DebianベースのDockerイメージを使いました。

ruby:3.0.1では次のエラーがでました。 SWIG 3.0.12ででるsimstring gemのコンパイルエラー · GitHub Ruby 2.7 modified 'rb_define_virtual_variable' signature · Issue #1689 · swig/swig · GitHub によるとSWIGのバージョンが古くて起きたエラーのようです。 ruby:3.0.1はDebianがbusterでした。 それでswigのバージョンが古かったようです。 ruby:3.0.5のイメージを使うことで解消できました。

最近はWSL上のUbuntuを使っています。 同じパッケージマネージャーがつかえたり、今回のような環境の違いで困ることがすくないので、DebianベースのDockerイメージを使う方が便利みたいです。 Macの時は、PCの環境がDebianもAlpineとも違っていたので気にしていませんでした。

ruby:3.0.1-alpine Dockerイメージでsimstring gemがビルドできない

simstringとswigの問題の切り分け - @ledsun blog で、simstringのgemをビルドするときはprepare.sh--swigオプションをつける必要があることがわかりました。

simstring gemをDocker上で使いたいです。 Dockerコンテナを小さめにするために、Alpine Linux上でビルドしてみます。 次のエラーがおきます。

bash-5.1# make
compiling export_wrap.cpp
In file included from /usr/local/include/ruby-3.0.0/ruby/ruby.h:39,
                 from /usr/local/include/ruby-3.0.0/ruby.h:38,
                 from export_wrap.cpp:880:
/usr/local/include/ruby-3.0.0/ruby/internal/memory.h:276:16: error: conflicting declaration of 'void* ruby_nonempty_memcpy(void*, const void*, size_t)' with 'C' linkage
  276 | #define memcpy ruby_nonempty_memcpy
      |                ^~~~~~~~~~~~~~~~~~~~
/usr/local/include/ruby-3.0.0/ruby/internal/memory.h:266:1: note: previous declaration with 'C++' linkage
  266 | ruby_nonempty_memcpy(void *dest, const void *src, size_t n)
      | ^~~~~~~~~~~~~~~~~~~~
make: *** [Makefile:237: export_wrap.o] Error 1

error: conflicting declaration of 'void ruby_nonempty_memcpy(void, const void*, size_t)' with 'C' linkage

エラーメッセージでググると次のissueが見つかります。

bugs.ruby-lang.org

解決されています。 ということはベースにしているDockerイメージのバージョンをあげれば?

simstringとswigの問題の切り分け

Rubyからsimstringを使うにはSWIGが必要です。 - @ledsun blog でビルドしたsimstring gemをRubyから実行時に次のエラーが出ていました。

ledsun@MSI:~/pubdictionaries►ruby -e 'require "simstring"'
<internal:/home/ledsun/.rbenv/versions/3.0.1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require': /home/ledsun/.rbenv/versions/3.0.1/lib/ruby/site_ruby/3.0.0/x86_64-linux/simstring.so: undefined symbol: Init_simstring - /home/ledsun/.rbenv/versions/3.0.1/lib/ruby/site_ruby/3.0.0/x86_64-linux/simstring.so (LoadError)

上記エントリではやりなおしたら出来ちゃいました。 もうちょっと原因を絞り込みます。 結論は、--swigオプション付きのprepare.shで生成するexport_wrap.cppコンパイルしないと上記エラーがでます。

https://github.com/chokkan/simstring/blob/d4dca6813cd134819af57bd2340a197dc9e855ec/swig/ruby/prepare.sh

#!/bin/sh
# $Id:$

ln -s ../export.cpp
ln -s ../export.h
ln -s ../export.i

if [ "$1" = "--swig" ];
then
    swig -c++ -ruby -o export_wrap.cpp export.i
fi

prepare.sh--swigオプションをつけると、swigコマンドをつかってexport_wrap.cppを生成します。 export_wrap.cppの中にInit_simstring関数の定義があります。

SWIGEXPORT void Init_simstring(void) {
  size_t i;

  SWIG_InitRuntime();
  mSimstring = rb_define_module("Simstring");

  SWIG_InitializeModule(0);
  for (i = 0; i < swig_module.size; i++) {
    SWIG_define_class(swig_module.types[i]);
  }

Rubyからsimstringを使うにはSWIGが必要です。

GitHub - chokkan/simstring: SimString という文字列を検索するライブラリーがあります。 Rubyから使うことができます。 というわけでインストールしてみたのですが次のエラーが起きました。

ledsun@MSI:~/pubdictionaries►ruby -e 'require "simstring"'
<internal:/home/ledsun/.rbenv/versions/3.0.1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require': /home/ledsun/.rbenv/versions/3.0.1/lib/ruby/site_ruby/3.0.0/x86_64-linux/simstring.so: undefined symbol: Init_simstring - /home/ledsun/.rbenv/versions/3.0.1/lib/ruby/site_ruby/3.0.0/x86_64-linux/simstring.so (LoadError)

undefined symbol: Init_simstringとでているので、Gemのビルドに失敗しているようです。

インストール手順

インストールの仕方がおかしいと思います。 手順を振り返ってみましょう。

類似文字列検索ライブラリSimStringをRubyから使う | EasyRamble を参考にしてインストールしました。 環境はWSL2上のUbuntuです。

最新版を使う為に、GitHubからcloneします。

git clone git@github.com:chokkan/simstring.git

./configureがないので、autoreconfします。

> autoreconf -i
aclocal: warning: autoconf input should be named 'configure.ac', not 'configure.in'
automake: warning: autoconf input should be named 'configure.ac', not 'configure.in'
configure.in:31: warning: AM_INIT_AUTOMAKE: two- and three-arguments forms are deprecated.  For more info, see:
configure.in:31: https://www.gnu.org/software/automake/manual/automake.html#Modernize-AM_005fINIT_005fAUTOMAKE-invocation
configure.in:22: installing './compile'
configure.in:21: installing './config.guess'
configure.in:21: installing './config.sub'
configure.in:31: installing './install-sh'
configure.in:31: installing './missing'
configure.in:110: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
Makefile.am: installing './INSTALL'
frontend/Makefile.am:13: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
frontend/Makefile.am: installing './depcomp'
automake: warning: autoconf input should be named 'configure.ac', not 'configure.in'
configure.in:110: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
sample/Makefile.am:10: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
configure.in:110: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')

warningはよくわからないので、無視します。 実は-iオプションの意味もわかっていません。 ./configureします。

> ./configure
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking for library containing strerror... none required
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports the include directive... yes (GNU style)
checking whether make supports nested variables... yes
checking dependency style of gcc... gcc3
checking whether to enable maintainer-specific portions of Makefiles... no
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking dependency style of g++... gcc3
checking whether ln -s works... yes
checking for ANSI C header files... (cached) yes
checking for stdint.h... (cached) yes
checking sys/mman.h usability... yes
checking sys/mman.h presence... yes
checking for sys/mman.h... yes
checking for an ANSI C-conforming const... yes
checking size of ... 0
checking for size_t... yes
checking whether struct tm is in sys/time.h or time.h... time.h
checking for uint32_t... yes
checking for sqrt in -lm... yes
checking for mmap in -lmmap... no
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating include/Makefile
config.status: creating frontend/Makefile
config.status: creating sample/Makefile
config.status: creating swig/Makefile
config.status: creating swig/python/setup.py
config.status: creating swig/ruby/extconf.rb
config.status: creating swig/perl/Makefile.PL
config.status: creating config.h
config.status: executing depfiles commands

makeします。

> make
make  all-recursive
make[1]: Entering directory '/home/ledsun/pubdictionaries/work/simstring'
Making all in include
make[2]: Entering directory '/home/ledsun/pubdictionaries/work/simstring/include'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/ledsun/pubdictionaries/work/simstring/include'
Making all in frontend
make[2]: Entering directory '/home/ledsun/pubdictionaries/work/simstring/frontend'
g++ -DHAVE_CONFIG_H -I. -I.. -I.. -I../include   -O3  -O3  -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o main.cpp
mv -f .deps/main.Tpo .deps/main.Po
g++ -O3  -O3    -o simstring main.o  -lm
make[2]: Leaving directory '/home/ledsun/pubdictionaries/work/simstring/frontend'
Making all in sample
make[2]: Entering directory '/home/ledsun/pubdictionaries/work/simstring/sample'
g++ -DHAVE_CONFIG_H -I. -I.. -I.. -I../include   -O3  -O3  -MT sample.o -MD -MP -MF .deps/sample.Tpo -c -o sample.o sample.cpp
mv -f .deps/sample.Tpo .deps/sample.Po
g++ -O3  -O3    -o sample sample.o  -lm
g++ -DHAVE_CONFIG_H -I. -I.. -I.. -I../include   -O3  -O3  -MT sample_unicode.o -MD -MP -MF .deps/sample_unicode.Tpo -c -o sample_unicode.o sample_unicode.cpp
mv -f .deps/sample_unicode.Tpo .deps/sample_unicode.Po
g++ -O3  -O3    -o sample_unicode sample_unicode.o  -lm
make[2]: Leaving directory '/home/ledsun/pubdictionaries/work/simstring/sample'
Making all in swig
make[2]: Entering directory '/home/ledsun/pubdictionaries/work/simstring/swig'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/ledsun/pubdictionaries/work/simstring/swig'
make[2]: Entering directory '/home/ledsun/pubdictionaries/work/simstring'
make[2]: Nothing to be done for 'all-am'.
make[2]: Leaving directory '/home/ledsun/pubdictionaries/work/simstring'
make[1]: Leaving directory '/home/ledsun/pubdictionaries/work/simstring'
> frontend/simstring --version
SimString 1.1 Copyright (c) 2009-2011 Naoaki Okazaki

ビルドできているようです。

> swig

Command 'swig' not found, but can be installed with:

sudo apt install swig

SWIGが入っていないみたいです。 sudo apt install swigします。

> swig -version

SWIG Version 4.0.1

Compiled with g++ [x86_64-pc-linux-gnu]

Configured options: +pcre

Please see http://www.swig.org for reporting bugs and further information

入りました。 Gemをビルドします。

> cd swig/ruby/
> ./prepare.sh --swig
export.h:19: Warning 801: Wrong constant name (corrected to `Exact')
export.h:21: Warning 801: Wrong constant name (corrected to `Dice')
export.h:23: Warning 801: Wrong constant name (corrected to `Cosine')
export.h:25: Warning 801: Wrong constant name (corrected to `Jaccard')
export.h:27: Warning 801: Wrong constant name (corrected to `Overlap')
export.h:34: Warning 801: Wrong class name (corrected to `Writer')
export.h:34: Warning 801: Wrong class name (corrected to `Writer')
export.h:88: Warning 801: Wrong class name (corrected to `Reader')
export.h:88: Warning 801: Wrong class name (corrected to `Reader')
> ruby extconf.rb
creating Makefile

makeします。

> make
compiling export.cpp
export.cpp: In destructor ‘virtual writer::~writer()’:
export.cpp:112:41: warning: throw will always call terminate() [-Wterminate]
  112 |         throw std::runtime_error(message);
      |                                         ^
export.cpp:112:41: note: in C++11 destructors default to noexcept
export.cpp:126:41: warning: throw will always call terminate() [-Wterminate]
  126 |         throw std::runtime_error(message);
      |                                         ^
export.cpp:126:41: note: in C++11 destructors default to noexcept
compiling export_wrap.cpp
export_wrap.cpp: In function ‘void SWIG_RubyInitializeTrackings()’:
export_wrap.cpp:1277:82: warning: ‘void ruby::backward::cxxanyargs::rb_define_virtual_variable(const char*, VALUE (*)(...), void (*)(...))’ is deprecated: Use of ANYARGS in this function is deprecated [-Wdeprecated-declarations]
 1277 |                              SWIG_RUBY_VOID_ANYARGS_FUNC((rb_gvar_setter_t*)NULL));
      |                                                                                  ^
In file included from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/internal/anyargs.h:83,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/ruby.h:24,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby.h:38,
                 from export_wrap.cpp:880:
/home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/backward/cxxanyargs.hpp:73:1: note: declared here
   73 | rb_define_virtual_variable(const char *q, type *w, void_type *e)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~
export_wrap.cpp:1277:82: warning: ‘void ruby::backward::cxxanyargs::rb_define_virtual_variable(const char*, VALUE (*)(...), void (*)(...))’ is deprecated: Use of ANYARGS in this function is deprecated [-Wdeprecated-declarations]
 1277 |                              SWIG_RUBY_VOID_ANYARGS_FUNC((rb_gvar_setter_t*)NULL));
      |                                                                                  ^
In file included from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/internal/anyargs.h:83,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/ruby.h:24,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby.h:38,
                 from export_wrap.cpp:880:
/home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/backward/cxxanyargs.hpp:73:1: note: declared here
   73 | rb_define_virtual_variable(const char *q, type *w, void_type *e)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~
export_wrap.cpp: In function ‘void SWIG_RubyIterateTrackings(void (*)(void*, VALUE))’:
export_wrap.cpp:1334:29: warning: ‘int ruby::backward::cxxanyargs::rb_st_foreach(st_table*, int (*)(...), st_data_t)’ is deprecated: Use of ANYARGS in this function is deprecated [-Wdeprecated-declarations]
 1334 |              (st_data_t)meth);
      |                             ^
In file included from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/internal/intern/hash.h:25,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/backward/cxxanyargs.hpp:16,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/internal/anyargs.h:83,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/ruby.h:24,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby.h:38,
                 from export_wrap.cpp:880:
/home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/st.h:142:20: note: declared here
  142 | #define st_foreach rb_st_foreach
      |                    ^~~~~~~~~~~~~
/home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/backward/cxxanyargs.hpp:430:1: note: in expansion of macro ‘st_foreach’
  430 | st_foreach(st_table *q, int_type *w, st_data_t e)
      | ^~~~~~~~~~
export_wrap.cpp:1334:29: warning: ‘int ruby::backward::cxxanyargs::rb_st_foreach(st_table*, int (*)(...), st_data_t)’ is deprecated: Use of ANYARGS in this function is deprecated [-Wdeprecated-declarations]
 1334 |              (st_data_t)meth);
      |                             ^
In file included from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/internal/intern/hash.h:25,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/backward/cxxanyargs.hpp:16,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/internal/anyargs.h:83,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/ruby.h:24,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby.h:38,
                 from export_wrap.cpp:880:
/home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/st.h:142:20: note: declared here
  142 | #define st_foreach rb_st_foreach
      |                    ^~~~~~~~~~~~~
/home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/backward/cxxanyargs.hpp:430:1: note: in expansion of macro ‘st_foreach’
  430 | st_foreach(st_table *q, int_type *w, st_data_t e)
      | ^~~~~~~~~~
export_wrap.cpp: In member function ‘bool swig::GC_VALUE::relational_equal_op(const swig::GC_VALUE&, const ID&, bool (*)(const VALUE&, const VALUE&)) const’:
export_wrap.cpp:2071:62: warning: ‘VALUE ruby::backward::cxxanyargs::rb_rescue(VALUE (*)(...), VALUE, VALUE (*)(...), VALUE)’ is deprecated: Use of ANYARGS in this function is deprecated [-Wdeprecated-declarations]
 2071 |                        (VALUEFUNC(swig_rescue_swallow)), Qnil);
      |                                                              ^
In file included from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/internal/anyargs.h:83,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/ruby.h:24,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby.h:38,
                 from export_wrap.cpp:880:
/home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/backward/cxxanyargs.hpp:258:1: note: declared here
  258 | rb_rescue(type *q, VALUE w, type *e, VALUE r)
      | ^~~~~~~~~
export_wrap.cpp:2071:62: warning: ‘VALUE ruby::backward::cxxanyargs::rb_rescue(VALUE (*)(...), VALUE, VALUE (*)(...), VALUE)’ is deprecated: Use of ANYARGS in this function is deprecated [-Wdeprecated-declarations]
 2071 |                        (VALUEFUNC(swig_rescue_swallow)), Qnil);
      |                                                              ^
In file included from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/internal/anyargs.h:83,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/ruby.h:24,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby.h:38,
                 from export_wrap.cpp:880:
/home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/backward/cxxanyargs.hpp:258:1: note: declared here
  258 | rb_rescue(type *q, VALUE w, type *e, VALUE r)
      | ^~~~~~~~~
export_wrap.cpp: In member function ‘swig::GC_VALUE swig::GC_VALUE::unary_op(const ID&) const’:
export_wrap.cpp:2111:60: warning: ‘VALUE ruby::backward::cxxanyargs::rb_rescue(VALUE (*)(...), VALUE, VALUE (*)(...), VALUE)’ is deprecated: Use of ANYARGS in this function is deprecated [-Wdeprecated-declarations]
 2111 |                      (VALUEFUNC(swig_rescue_swallow)), Qnil);
      |                                                            ^
In file included from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/internal/anyargs.h:83,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/ruby.h:24,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby.h:38,
                 from export_wrap.cpp:880:
/home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/backward/cxxanyargs.hpp:258:1: note: declared here
  258 | rb_rescue(type *q, VALUE w, type *e, VALUE r)
      | ^~~~~~~~~
export_wrap.cpp:2111:60: warning: ‘VALUE ruby::backward::cxxanyargs::rb_rescue(VALUE (*)(...), VALUE, VALUE (*)(...), VALUE)’ is deprecated: Use of ANYARGS in this function is deprecated [-Wdeprecated-declarations]
 2111 |                      (VALUEFUNC(swig_rescue_swallow)), Qnil);
      |                                                            ^
In file included from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/internal/anyargs.h:83,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/ruby.h:24,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby.h:38,
                 from export_wrap.cpp:880:
/home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/backward/cxxanyargs.hpp:258:1: note: declared here
  258 | rb_rescue(type *q, VALUE w, type *e, VALUE r)
      | ^~~~~~~~~
export_wrap.cpp: In member function ‘swig::GC_VALUE swig::GC_VALUE::binary_op(const swig::GC_VALUE&, const ID&) const’:
export_wrap.cpp:2130:60: warning: ‘VALUE ruby::backward::cxxanyargs::rb_rescue(VALUE (*)(...), VALUE, VALUE (*)(...), VALUE)’ is deprecated: Use of ANYARGS in this function is deprecated [-Wdeprecated-declarations]
 2130 |                      (VALUEFUNC(swig_rescue_swallow)), Qnil);
      |                                                            ^
In file included from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/internal/anyargs.h:83,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/ruby.h:24,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby.h:38,
                 from export_wrap.cpp:880:
/home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/backward/cxxanyargs.hpp:258:1: note: declared here
  258 | rb_rescue(type *q, VALUE w, type *e, VALUE r)
      | ^~~~~~~~~
export_wrap.cpp:2130:60: warning: ‘VALUE ruby::backward::cxxanyargs::rb_rescue(VALUE (*)(...), VALUE, VALUE (*)(...), VALUE)’ is deprecated: Use of ANYARGS in this function is deprecated [-Wdeprecated-declarations]
 2130 |                      (VALUEFUNC(swig_rescue_swallow)), Qnil);
      |                                                            ^
In file included from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/internal/anyargs.h:83,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/ruby.h:24,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby.h:38,
                 from export_wrap.cpp:880:
/home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/backward/cxxanyargs.hpp:258:1: note: declared here
  258 | rb_rescue(type *q, VALUE w, type *e, VALUE r)
      | ^~~~~~~~~
export_wrap.cpp: In function ‘int SWIG_AsVal_unsigned_SS_long(VALUE, long unsigned int*)’:
export_wrap.cpp:2471:90: warning: ‘VALUE ruby::backward::cxxanyargs::rb_rescue(VALUE (*)(...), VALUE, VALUE (*)(...), VALUE)’ is deprecated: Use of ANYARGS in this function is deprecated [-Wdeprecated-declarations]
 2471 |     if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2ULONG), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) {
      |                                                                                          ^
In file included from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/internal/anyargs.h:83,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/ruby.h:24,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby.h:38,
                 from export_wrap.cpp:880:
/home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/backward/cxxanyargs.hpp:258:1: note: declared here
  258 | rb_rescue(type *q, VALUE w, type *e, VALUE r)
      | ^~~~~~~~~
export_wrap.cpp:2471:90: warning: ‘VALUE ruby::backward::cxxanyargs::rb_rescue(VALUE (*)(...), VALUE, VALUE (*)(...), VALUE)’ is deprecated: Use of ANYARGS in this function is deprecated [-Wdeprecated-declarations]
 2471 |     if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2ULONG), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) {
      |                                                                                          ^
In file included from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/internal/anyargs.h:83,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/ruby.h:24,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby.h:38,
                 from export_wrap.cpp:880:
/home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/backward/cxxanyargs.hpp:258:1: note: declared here
  258 | rb_rescue(type *q, VALUE w, type *e, VALUE r)
      | ^~~~~~~~~
export_wrap.cpp: In function ‘int SWIG_AsVal_unsigned_SS_long_SS_long(VALUE, long long unsigned int*)’:
export_wrap.cpp:2517:88: warning: ‘VALUE ruby::backward::cxxanyargs::rb_rescue(VALUE (*)(...), VALUE, VALUE (*)(...), VALUE)’ is deprecated: Use of ANYARGS in this function is deprecated [-Wdeprecated-declarations]
 2517 |     if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2ULL), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) {
      |                                                                                        ^
In file included from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/internal/anyargs.h:83,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/ruby.h:24,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby.h:38,
                 from export_wrap.cpp:880:
/home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/backward/cxxanyargs.hpp:258:1: note: declared here
  258 | rb_rescue(type *q, VALUE w, type *e, VALUE r)
      | ^~~~~~~~~
export_wrap.cpp:2517:88: warning: ‘VALUE ruby::backward::cxxanyargs::rb_rescue(VALUE (*)(...), VALUE, VALUE (*)(...), VALUE)’ is deprecated: Use of ANYARGS in this function is deprecated [-Wdeprecated-declarations]
 2517 |     if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2ULL), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) {
      |                                                                                        ^
In file included from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/internal/anyargs.h:83,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/ruby.h:24,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby.h:38,
                 from export_wrap.cpp:880:
/home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/backward/cxxanyargs.hpp:258:1: note: declared here
  258 | rb_rescue(type *q, VALUE w, type *e, VALUE r)
      | ^~~~~~~~~
export_wrap.cpp: In function ‘int SWIG_AsVal_long(VALUE, long int*)’:
export_wrap.cpp:2576:89: warning: ‘VALUE ruby::backward::cxxanyargs::rb_rescue(VALUE (*)(...), VALUE, VALUE (*)(...), VALUE)’ is deprecated: Use of ANYARGS in this function is deprecated [-Wdeprecated-declarations]
 2576 |     if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2LONG), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) {
      |                                                                                         ^
In file included from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/internal/anyargs.h:83,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/ruby.h:24,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby.h:38,
                 from export_wrap.cpp:880:
/home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/backward/cxxanyargs.hpp:258:1: note: declared here
  258 | rb_rescue(type *q, VALUE w, type *e, VALUE r)
      | ^~~~~~~~~
export_wrap.cpp:2576:89: warning: ‘VALUE ruby::backward::cxxanyargs::rb_rescue(VALUE (*)(...), VALUE, VALUE (*)(...), VALUE)’ is deprecated: Use of ANYARGS in this function is deprecated [-Wdeprecated-declarations]
 2576 |     if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2LONG), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) {
      |                                                                                         ^
In file included from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/internal/anyargs.h:83,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/ruby.h:24,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby.h:38,
                 from export_wrap.cpp:880:
/home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/backward/cxxanyargs.hpp:258:1: note: declared here
  258 | rb_rescue(type *q, VALUE w, type *e, VALUE r)
      | ^~~~~~~~~
export_wrap.cpp: In function ‘int SWIG_AsVal_long_SS_long(VALUE, long long int*)’:
export_wrap.cpp:2607:87: warning: ‘VALUE ruby::backward::cxxanyargs::rb_rescue(VALUE (*)(...), VALUE, VALUE (*)(...), VALUE)’ is deprecated: Use of ANYARGS in this function is deprecated [-Wdeprecated-declarations]
 2607 |     if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2LL), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) {
      |                                                                                       ^
In file included from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/internal/anyargs.h:83,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/ruby.h:24,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby.h:38,
                 from export_wrap.cpp:880:
/home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/backward/cxxanyargs.hpp:258:1: note: declared here
  258 | rb_rescue(type *q, VALUE w, type *e, VALUE r)
      | ^~~~~~~~~
export_wrap.cpp:2607:87: warning: ‘VALUE ruby::backward::cxxanyargs::rb_rescue(VALUE (*)(...), VALUE, VALUE (*)(...), VALUE)’ is deprecated: Use of ANYARGS in this function is deprecated [-Wdeprecated-declarations]
 2607 |     if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2LL), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) {
      |                                                                                       ^
In file included from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/internal/anyargs.h:83,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/ruby.h:24,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby.h:38,
                 from export_wrap.cpp:880:
/home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/backward/cxxanyargs.hpp:258:1: note: declared here
  258 | rb_rescue(type *q, VALUE w, type *e, VALUE r)
      | ^~~~~~~~~
export_wrap.cpp: In function ‘int SWIG_AsVal_double(VALUE, double*)’:
export_wrap.cpp:4679:88: warning: ‘VALUE ruby::backward::cxxanyargs::rb_rescue(VALUE (*)(...), VALUE, VALUE (*)(...), VALUE)’ is deprecated: Use of ANYARGS in this function is deprecated [-Wdeprecated-declarations]
 4679 |     if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2DBL), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) {
      |                                                                                        ^
In file included from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/internal/anyargs.h:83,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/ruby.h:24,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby.h:38,
                 from export_wrap.cpp:880:
/home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/backward/cxxanyargs.hpp:258:1: note: declared here
  258 | rb_rescue(type *q, VALUE w, type *e, VALUE r)
      | ^~~~~~~~~
export_wrap.cpp:4679:88: warning: ‘VALUE ruby::backward::cxxanyargs::rb_rescue(VALUE (*)(...), VALUE, VALUE (*)(...), VALUE)’ is deprecated: Use of ANYARGS in this function is deprecated [-Wdeprecated-declarations]
 4679 |     if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2DBL), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) {
      |                                                                                        ^
In file included from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/internal/anyargs.h:83,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/ruby.h:24,
                 from /home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby.h:38,
                 from export_wrap.cpp:880:
/home/ledsun/.rbenv/versions/3.0.1/include/ruby-3.0.0/ruby/backward/cxxanyargs.hpp:258:1: note: declared here
  258 | rb_rescue(type *q, VALUE w, type *e, VALUE r)
      | ^~~~~~~~~
linking shared-object simstring.so

warningはよくわからないので、無視します。 インストールします。

> make install
/usr/bin/install -c -m 0755 simstring.so /home/ledsun/.rbenv/versions/3.0.1/lib/ruby/site_ruby/3.0.0/x86_64-linux
ruby -e 'require "simstring"'

あ!うごきました!SWIGをインストールしてないのがいけなかったみたいです。

参考

Fork-gitが壊れたのかと思ったらwslgitの問題だった

Forkを1.18.0.0にバージョンアップしたら、画面の一部がエラーになりました。

https://user-images.githubusercontent.com/1079508/207527957-1623bd47-77e8-47bb-a5a9-caad0ce8b723.png

GitHubでそれっぽいissueを見つけました。

github.com

Duplicate, closing

て、書いてあります。 何と重複しているのかわからなかったので、コメント書いてみました。 そしたら別のコメントがつきました。

github.com

wslgitの問題だったみたいです。 コメントでリンクされている 1.2.0-alpha3 をいれたら解消しました。