[BUG] DoNotOptimize build break with GCC
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 42/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- cpp
- Área
- testing-qa, tooling
Línea de trabajo
Comienza con sdk/test/trace/sampler_benchmark.cc, especialmente con los benchmarks de los constructores en las líneas 49 y 58, y reproduce la compilación con GCC 7.4.1, 7.5.0 o 12.3.0 y benchmark 1.8.2 o 1.8.3. Inspecciona la implementación específica de GCC de DoNotOptimize en benchmark.h alrededor de la línea 540 y compara su comportamiento con Clang; se considera terminado cuando el benchmark se compila correctamente con ambos compiladores.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
See downstream bug:
When building the following code:
void BM_ParentBasedSamplerConstruction(benchmark::State &state)
{
while (state.KeepRunning())
{
benchmark::DoNotOptimize(ParentBasedSampler(std::make_shared<AlwaysOnSampler>())); // line 49
}
}
and
void BM_TraceIdRatioBasedSamplerConstruction(benchmark::State &state)
{
while (state.KeepRunning())
{
benchmark::DoNotOptimize(TraceIdRatioBasedSampler(0.01)); // line 58
}
}
the build fails with GCC 7.4.1, GCC 7.5.0, GCC 12.3.0.
The error reported is:
[ 56%] Building CXX object sdk/test/trace/CMakeFiles/sampler_benchmark.dir/sampler_benchmark.cc.o
In file included from /home/malff/CODE/MARC_GITHUB/opentelemetry-cpp/sdk/test/trace/sampler_benchmark.cc:17:
/opt/benchmark-1.8.2/include/benchmark/benchmark.h: In instantiation of ‘typename std::enable_if<((! std::is_trivially_copyable<_Tp>::value) || (sizeof (Tp) > sizeof (Tp*)))>::type benchmark::DoNotOptimize(Tp&&) [with Tp = opentelemetry::v1::sdk::trace::ParentBasedSampler; typename std::enable_if<((! std::is_trivially_copyable<_Tp>::value) || (sizeof (Tp) > sizeof (Tp*)))>::type = void]’:
/home/malff/CODE/MARC_GITHUB/opentelemetry-cpp/sdk/test/trace/sampler_benchmark.cc:49:29: required from here
/opt/benchmark-1.8.2/include/benchmark/benchmark.h:540:3: error: read-only reference ‘value’ used as ‘asm’ output
540 | asm volatile("" : "+m"(value) : : "memory");
| ^~~
/opt/benchmark-1.8.2/include/benchmark/benchmark.h: In instantiation of ‘typename std::enable_if<((! std::is_trivially_copyable<_Tp>::value) || (sizeof (Tp) > sizeof (Tp*)))>::type benchmark::DoNotOptimize(Tp&&) [with Tp = opentelemetry::v1::sdk::trace::TraceIdRatioBasedSampler; typename std::enable_if<((! std::is_trivially_copyable<_Tp>::value) || (sizeof (Tp) > sizeof (Tp*)))>::type = void]’:
/home/malff/CODE/MARC_GITHUB/opentelemetry-cpp/sdk/test/trace/sampler_benchmark.cc:58:29: required from here
/opt/benchmark-1.8.2/include/benchmark/benchmark.h:540:3: error: read-only reference ‘value’ used as ‘asm’ output
make[2]: *** [sdk/test/trace/CMakeFiles/sampler_benchmark.dir/build.make:76: sdk/test/trace/CMakeFiles/sampler_benchmark.dir/sampler_benchmark.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:4217: sdk/test/trace/CMakeFiles/sampler_benchmark.dir/all] Error 2
make: *** [Makefile:146: all] Error 2
Verified with benchmark 1.8.2 and 1.8.3.
Note that the same code builds fine with CLang.
If this matters, ParentBasedSampler and TraceIdRatioBasedSampler are classes: what is benchmarked here is a call to the constructor.
Note how the benchmark header file is different for GCC, with:
The build failure occurs in:
template <class Tp>
inline BENCHMARK_ALWAYS_INLINE
typename std::enable_if<!std::is_trivially_copyable<Tp>::value ||
(sizeof(Tp) > sizeof(Tp*))>::type
DoNotOptimize(Tp&& value) {
asm volatile("" : "+m"(value) : : "memory"); // line 540
}
Expected result is a successful build with both GCC and Clang.
- Lenguaje dominante
- C++
- Estrellas
- 10.5k
- Forks
- 1.8k
- Merge medio
- 2 d 2 h
- PR fusionados (30 d)
- 30
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin 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 google/benchmark
-
[BUG] Confusing title in docs/platform_specific_build_instructions.mdPosiblemente ocupada @skryabae la tomó hace 28 días. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
[BUG] Memory manager counts allocations not part of benchmarkQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
google/benchmark#2149 · 5 comentarios ·
Los mantenedores suelen responder en 1 día
-
Three small hardening notes from a security review: CSV formula-prefix neutralization, full C0 escaping in the JSON reporter, and type diagnostics in gbench/compare.pyPosiblemente ocupada @Aryan9891 la tomó hace 7 días. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 64/100
google/benchmark#2299 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
[FR] Add native Zig bindings via top-level `bindings/zig`Quizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 42/100
google/benchmark#2266 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
google/benchmark#2235 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de google/benchmark
Issues similares
-
documentation enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
QuantStack/git2cpp#203 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
BaptisteHudyma/Lamp-Da#588 ·
Los mantenedores suelen responder en 1 día
-
bug macOS networking
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
docling-project/docling-parse#448 ·
Los mantenedores suelen responder en 5 días