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

Abierto
#1,110 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
45/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
cmake, cpp
Área
build-system

Línea de trabajo

Comienza con libs/filesystem/CMakeLists.txt y libs/nowide/CMakeLists.txt; después inspecciona config/check_attribute_init_priority.cpp y el manejo existente de CMAKE_REQUIRED_FLAGS en libs/atomic/CMakeLists.txt y libs/log/CMakeLists.txt. Reproduce la comprobación con el compilador aarch64-w64-mingw32 y verifica que la prueba de configuración rechace la advertencia de atributo ignorado y que la compilación de Windows ARM64 ya no falle más adelante.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
HTML
Estrellas
8.6k
Forks
2k
Merge medio
9 h 35 min
PR fusionados (30 d)
1

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de boostorg/boost

Todos los issues de boostorg/boost

Issues similares

Más issues de Build System

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.