Cannot build on Windows for ARM64: error on init_priority attribute.

Đang mở
#1,110 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
cmake, cpp
Lĩnh vực
build-system

Hướng nghiên cứu

Bắt đầu với libs/filesystem/CMakeLists.txt và libs/nowide/CMakeLists.txt, sau đó kiểm tra config/check_attribute_init_priority.cpp cùng cách xử lý CMAKE_REQUIRED_FLAGS hiện có trong libs/atomic/CMakeLists.txt và libs/log/CMakeLists.txt. Tái hiện kiểm tra bằng trình biên dịch aarch64-w64-mingw32 và xác minh rằng bài kiểm tra cấu hình từ chối cảnh báo về thuộc tính bị bỏ qua, đồng thời bản build Windows ARM64 không còn thất bại ở bước sau.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

I tried to compile Boost libraries with aarch64-w64-mingw32 cross compiler.
Unfortunately, the build process failed after a while with this error message:

boost-1.90.0-1.noarch/src/boost-1.90.0/libs/nowide/src/iostream.cpp:148:70: error: 'init_priority' attribute ignored [-Werror=attributes]
  148 | #define BOOST_NOWIDE_INIT_PRIORITY __attribute__((init_priority(101)))
      |                                                                      ^

At the time of writing, the support for init_priority is tested into two CMakeLists.txt files:

  • libs/filesystem/CMakeLists.txt
  • libs/nowide/CMakeLists.txt

Inside these scripts, check_cxx_source_compiles() is used.
These calls check if the test compiles fine and they define BOOST_NOWIDE_HAS_INIT_PRIORITY and BOOST_FILESYSTEM_HAS_INIT_PRIORITY if everything looks ok.
However, these tests do not fail if there is a just warning.
For example, I tried to compile the test source myself and I got this:

$ aarch64-w64-mingw32-g++ boost-1.90.0-1.noarch/src/boost-1.90.0/libs/nowide/config/check_attribute_init_priority.cpp -c -o c.o
boost-1.90.0-1.noarch/src/boost-1.90.0/libs/nowide/config/check_attribute_init_priority.cpp:9:43: warning: 'init_priority' attribute ignored [-Wattributes]
    9 | Foo foo __attribute__((init_priority(101)));
      |                                           ^

So, for CMake the test was good anyways.
The problem comes out because the -Werror option, which makes the build process to fail later.

I have not enough knowledge at the moment, but I can see these two solutions:
Adding -Wno-error=attributes (if supported) when building those libraries, or
Adding -Werror (if supported) when compiling the tests with check_cxx_source_compiles().

This issue happens when building for Windows on ARM64 with GCC.
The i686-w64-mingw32 and x86_64-w64-mingw32 cross compilers also work with that attribute, but they don't emit any warning and that's why this issue was not seen before.

I hope that you will find this report useful.

EDIT: it looks like these scripts already handle CMAKE_REQUIRED_FLAGS before calling check_cxx_source_compiles():

  • libs/atomic/CMakeLists.txt
  • libs/log/CMakeLists.txt

Probably, it would be enough to follow the same way for adding the needed option.

Ngôn ngữ chính
HTML
Star
8.6k
Fork
2k
Merge trung bình
9 giờ 35 phút
Pull request đã merge (30 ngày)
1

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của boostorg/boost

Tất cả issue của boostorg/boost

Issue tương tự

Thêm issue về Build System

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.