cmake: AddZstdCompilationFlags still depends on C++ after #4357
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 78/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Área
- build-system
Línea de trabajo
Comienza con AddZstdCompilationFlags.cmake, centrándote en EnableCompilerFlag() y ADD_ZSTD_COMPILATION_FLAGS; después, ejecuta el comando de configuración de MinGW del issue. Se considera terminado cuando la configuración se completa correctamente con CMAKE_CXX_COMPILER establecido y las compilaciones nativas conservan sus flags del compilador y de ensamblado sin requerir pruebas.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Since #4357 the cmake build enables C++ only for the tests, but AddZstdCompilationFlags.cmake still depends on it. For MinGW targets configure fails as soon as CMAKE_CXX_COMPILER is set, which is what cross toolchain files usually do.
Tested on 01b7154f1172432f8abe9b3bb9909e14a1176b7d. Works fine on the latest release (v1.5.7).
Steps to reproduce
cmake -S build/cmake -B out \
-DCMAKE_SYSTEM_NAME=Windows \
-DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc \
-DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++
CMake Error at /usr/share/cmake-4.2/Modules/Internal/CheckFlagCommonConfig.cmake:72 (message):
check_compiler_flag: CXX: needs to be enabled before use.
The same command works without -DCMAKE_CXX_COMPILER or with -DZSTD_BUILD_TESTS=ON. The first commit that fails is 769723aee2.
Cause
EnableCompilerFlag() checks C++ flags when CMAKE_CXX_COMPILER is set, which does not tell whether the language is enabled:
if (_CXX AND CMAKE_CXX_COMPILER)
CHECK_CXX_COMPILER_FLAG(${_flag} CXX_FLAG_${varname})
_CXX is always true here. ADD_ZSTD_COMPILATION_FLAGS passes _C _CXX on without ${}, so the function gets the string _CXX and not the value of ZSTD_ENABLE_CXX.
Also affects native compilation
Default build silently loses all flags and the assembly. The block is guarded by CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang", which is empty without C++, and ZSTD_HAS_NOEXECSTACK needs CXX_FLAG_WA_NOEXECSTACK. On x86-64 Linux with gcc 15.2.0:
$ cmake -S build/cmake -B out
$ grep C_FLAGS out/lib/CMakeFiles/libzstd_static.dir/flags.make
C_FLAGS = -O3 -DNDEBUG -fPIC -DZSTD_DISABLE_ASM
$ cmake -S build/cmake -B out2 -DZSTD_BUILD_TESTS=ON
$ grep C_FLAGS out2/lib/CMakeFiles/libzstd_static.dir/flags.make
C_FLAGS = -Wall -Wextra -Wundef -Wshadow -Wcast-align -Wcast-qual -Wstrict-prototypes -Wa,--noexecstack -O3 -DNDEBUG -fPIC
Possible fix
Use CMAKE_C_COMPILER_ID for the guard, check C++ flags only if CMAKE_CXX_COMPILER_LOADED is set, and do not require CXX_FLAG_WA_NOEXECSTACK when C++ is not enabled.
- Lenguaje dominante
- C
- Estrellas
- 28.1k
- Forks
- 2.7k
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de facebook/zstd
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
ZSTD_compressSequencesAndLiterals() does not enforce its documented litCapacity >= litSize + 8 contract — the implemented check is 8 bytes weaker than the API documentation, its own error message, and the introducing commitPosiblemente ocupada @KSAGlory la tomó hace 49 días. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
-
seekable_format warning with -DNDEBUG: potential uninitialised local variable newOffset usedPosiblemente ocupada @i098 la tomó hace 18 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
COVER_selectDict() uses stale customDictContentEnd after ZDICT_finalizeDictionary modifies dictContentSizePosiblemente ocupada @VirajMishra1 la tomó hace 52 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Todos los issues de facebook/zstd
Issues similares
-
vim.filetype.match() prefixes a URL buffer name with the cwd before passing it to filetype functionsAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 73/100
Los mantenedores suelen responder en 1 día
-
stream_curl: retry_count never resets after a successful reconnect, so long sequential streams die after 5 dropsPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
mpv-player/mpv#18728 ·
Los mantenedores suelen responder en 1 día
-
followup Prio 📌
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
cyrusimap/cyrus-imapd#6640 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 60/100
Los mantenedores suelen responder en 1 día