Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

M1 macでmodernization ブランチをビルド時,memory_resourceが無いと言われビルドに失敗する #329

Open
kyawaway opened this issue Feb 13, 2024 · 13 comments

Comments

@kyawaway
Copy link
Contributor

kyawaway commented Feb 13, 2024

make -j実行時,

In file included from /path/to/slim/src/element/memory_pool.cpp:39:                             
/path/to/slim/src/element/memory_pool.h:49:10: fatal error: 'memory_resource' file not found    
#include <memory_resource>                                                                                             
         ^~~~~~~~~~~~~~~~~   

@kyawaway
Copy link
Contributor Author

@kyawaway kyawaway changed the title M1でmodernization ブランチをビルド時,memory_resourceが無いと言われビルドに失敗する M1 macでmodernization ブランチをビルド時,memory_resourceが無いと言われビルドに失敗する Feb 13, 2024
@kyawaway
Copy link
Contributor Author

関連:#313

@QRWells
Copy link
Contributor

QRWells commented Feb 14, 2024

https://developer.apple.com/xcode/cpp/#c++17 によると、<memory_resource>はC++ 17 Library FeatureとしてXCode 15が必要です。

@kyawaway
Copy link
Contributor Author

XCode15を入れ,<memory_resource>については怒られなくなりました,ありがとうございます.

しかし,<atomic_ref>が無いと言われビルドに失敗しています.

In file included from /path/to/slim/src/verifier/verifier.h:54:
/path/to/slim/src/verifier/mc_explorer.h:77:22: error: no member named 'atomic_ref' in namespace
 'std'
  auto flags2 = std::atomic_ref(s->flags2);

@QRWells
Copy link
Contributor

QRWells commented Feb 15, 2024

cppreferenceによって、AppleClangはまだatomic_refを実装していませんので、commit 511a5festd::atomic_refで引用した変数をstd::atomic<T>に変更しました。

std::atomic_refを使った理由は、Stateflagは局所的にアトミック操作がありますが、std::atomic<T>ではアトミック操作ではない部分を特別な修正が必要なので、便宜上atomic_refを使ってました。

今回すべてアトミック操作にしたから、性能への影響については調査が必要です。(あまりないはず)

@kyawaway
Copy link
Contributor Author

対応ありがとうございます.

まだ数箇所怒られています.エラーログが全て見通せそうな規模になってきたので,エラーが出ている箇所を上から全て添付します.

(まだ自分では全く調べてないです,明日夜に見ます)

/path/to/slim/src/element/variant.hpp:56:33: error: invalid application of 'sizeof' to an incomp
lete type 'il::instr_arg::inst_list'
  static constexpr auto size  = sizeof(Z);
/path/to/slim/src/element/variant.hpp:57:33: error: invalid application of 'alignof' to an incom
plete type 'il::instr_arg::inst_list'
  static constexpr auto align = alignof(Z);
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/v
ector:836:62: error: arithmetic on a pointer to an incomplete type 'Instruction'
        __alloc_traits::destroy(__alloc(), std::__to_address(--__soon_to_be_end));
/path/to/slim/src/element/variant.hpp:56:33: error: invalid application of 'sizeof' to an incomp
lete type 'il::instr_arg::inst_list'
  static constexpr auto size  = sizeof(Z);
/path/to/slim/src/element/variant.hpp:57:33: error: invalid application of 'alignof' to an incom
plete type 'il::instr_arg::inst_list'
  static constexpr auto align = alignof(Z);
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/v
ector:549:52: error: arithmetic on a pointer to an incomplete type 'Instruction'
        {return static_cast<size_type>(__end_cap() - this->__begin_);}
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/v
ector:763:54: error: arithmetic on a pointer to an incomplete type 'const value_type' (aka 'const Instruction')
      __annotate_contiguous_container(data(), data() + capacity(),
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/v
ector:836:62: error: arithmetic on a pointer to an incomplete type 'Instruction'
        __alloc_traits::destroy(__alloc(), std::__to_address(--__soon_to_be_end));
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/_
_memory/allocator.h:131:58: error: invalid application of 'sizeof' to an incomplete type 'Instruction'
            _VSTD::__libcpp_deallocate((void*)__p, __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));
/path/to/slim/src/vm/task.cpp:53:10: fatal error: 'bits/ranges_algo.h' file not found
#include <bits/ranges_algo.h> 
/path/to/slim/src/element/variant.hpp:56:33: error: invalid application of 'sizeof' to an incomp
lete type 'il::instr_arg::inst_list'
  static constexpr auto size  = sizeof(Z);
/path/to/slim/src/element/variant.hpp:57:33: error: invalid application of 'alignof' to an incom
plete type 'il::instr_arg::inst_list'
  static constexpr auto align = alignof(Z);
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/_
_memory/allocator.h:131:58: error: invalid application of 'sizeof' to an incomplete type 'Instruction'
            _VSTD::__libcpp_deallocate((void*)__p, __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));
/path/to/slim/src/verifier/dpor_naive.cpp:41:10: fatal error: 'bits/ranges_algo.h' file not foun
d
#include <bits/ranges_algo.h> 

@QRWells
Copy link
Contributor

QRWells commented Feb 16, 2024

12c21e6で必要ないヘッダを削除しましたが、エラーの中にincomplete typeについてはコンパイルフロントエンドの問題だと考えられます。手元のclang 16.0.6とstiltonのgcc 11.2.0ではそのエラーがありません。

@kyawaway
Copy link
Contributor Author

kyawaway commented Feb 17, 2024

手元のApple clang version 15.0.0 (clang-1500.1.0.2.5)gcc (Homebrew GCC 13.2.0) 13.2.0 でこのエラーが起きることを確認しています.引き続き調査します.

@QRWells
Copy link
Contributor

QRWells commented Feb 18, 2024

原因は大体つかめました。ここで確認できるhttps://godbolt.org/z/a1dMEYPbo

clang 15.0以上はこういう「循環参照」みたいな型はincomplete typeとしてエラーとなる。
(実はill-formedであるかもしれませんからコードの修正は必要だと思います。参照:https://stackoverflow.com/questions/70357084/code-compiles-with-g-but-not-clang-if-incomplete-type-is-used-in-templated-f)

そしてgcc 13.2.0でコンパイルできないのはCMakeLists.txtのバグでもう修正しました。
buildフォルダにある内容を全部削除して、cmake -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++ ..gcc/g++のパスは異なるかもしれません)で試してみてください

@kyawaway
Copy link
Contributor Author

とりあえず手元のgcc 13.2.0でビルドできることが確認できました,ありがとうございます!(そして#281 で問題になっていたbus errorが起きていないように見える!(要調査))

@kyawaway
Copy link
Contributor Author

ついでですが,デフォルトのmake install のインストール先を,/usr/local/bin/ではなく,developブランチと同様にこのプロジェクトフォルダ直下にbinディレクトリを作ってインストールするように変えていただけるとありがたいかもです.

@QRWells
Copy link
Contributor

QRWells commented Feb 18, 2024

8bfc5abの修正でAppleClangでビルドできるかもしれません。

そして実際にインストールを行った結果、現在developブランチのmake installはデフォルトで/usr/local/bin/にインストールしているようです。

@nikosai
Copy link
Contributor

nikosai commented Mar 18, 2024

そして実際にインストールを行った結果、現在developブランチのmake installはデフォルトで/usr/local/bin/にインストールしているようです。

たしかにそうなのですが、実際の運用上は

./configure --prefix=$(pwd)

でプロジェクトルート直下にインストール先を変えていることが多いです。
(複数のバージョンを使い分けたい場面等もあるので……)
また、develop のインストール手順(1つ目)もそのようになっています。

そのため、

  1. プロジェクトルートへのインストールをデフォルトにする or
  2. インストール先の指定方法をREADMEに追記する

のいずれかの対応はお願いしたいです。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants