[BUG] DoNotOptimize build break with GCC
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 42/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- cpp
- Ambito
- testing-qa, tooling
Direzione di ricerca
Inizia da sdk/test/trace/sampler_benchmark.cc, in particolare dai benchmark dei costruttori alle righe 49 e 58, e riproduci la build con GCC 7.4.1, 7.5.0 o 12.3.0 e benchmark 1.8.2 o 1.8.3. Esamina l’implementazione specifica per GCC di DoNotOptimize in benchmark.h intorno alla riga 540 e confrontane il comportamento con Clang; il lavoro è completato quando il benchmark viene compilato correttamente con entrambi i compilatori.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- C++
- Stelle
- 10.5k
- Fork
- 1.8k
- Merge medio
- 2g 2h
- PR unite (30g)
- 30
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di google/benchmark
-
[BUG] Confusing title in docs/platform_specific_build_instructions.mdForse già presa @skryabae l’ha presa 29 giorni fa. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
[BUG] Memory manager counts allocations not part of benchmarkForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
google/benchmark#2149 · 5 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
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.pyForse già presa @Aryan9891 l’ha presa 7 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 64/100
google/benchmark#2299 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
[FR] Add native Zig bindings via top-level `bindings/zig`Forse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 42/100
google/benchmark#2266 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
google/benchmark#2235 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di google/benchmark
Issue simili
-
comp-documentation
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 84/100
ClickHouse/ClickHouse#129829 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
OpenMoonRay/openmoonray#332 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
LadybirdBrowser/ladybird#13955 ·
I maintainer di solito rispondono entro 1 giorno
-
`isValidState<FloatType>` cannot be instantiated: `isWithinLimits` is called without `<FloatType>`Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
tesseract-robotics/tesseract_planning#791 · 1 commento ·
-
bug javascript
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno