Skip to content

Commit

Permalink
Merge pull request #467 from biojppm/fix/464_ub_ppc64le
Browse files Browse the repository at this point in the history
Workaround for failures with ppc64le g++14 -O2
  • Loading branch information
biojppm authored Aug 24, 2024
2 parents 5ccf9a2 + 35208be commit 346c0c1
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 30 deletions.
26 changes: 26 additions & 0 deletions .github/toolchains/linux-gnu-powerpc64le.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CROSS_COMPILER_PREFIX /usr)
set(CROSS_COMPILER_TARGET powerpc64le-linux-gnu)
set(CMAKE_SYSTEM_PROCESSOR powerpc64le)
set(CMAKE_CROSSCOMPILING_EMULATOR qemu-ppc64le-static)
set(CMAKE_C_COMPILER ${CROSS_COMPILER_PREFIX}/bin/${CROSS_COMPILER_TARGET}-gcc)
set(CMAKE_CXX_COMPILER ${CROSS_COMPILER_PREFIX}/bin/${CROSS_COMPILER_TARGET}-g++)
set(CMAKE_AR ${CROSS_COMPILER_PREFIX}/bin/${CROSS_COMPILER_TARGET}-ar CACHE FILEPATH "Archiver")
set(CMAKE_MAKE_PROGRAM ${CROSS_COMPILER_PREFIX}/bin/make CACHE FILEPATH "make")

# use -static to avoid having to install the dynamic loader
# see https://mfo.dev.br/2018/03/17/ppc64le-on-x86_64-cross-compilers.html
set(CMAKE_CXX_FLAGS -static)
set(CMAKE_C_FLAGS -static)

set(CMAKE_FIND_ROOT_PATH ${CROSS_COMPILER_PREFIX}/${CROSS_COMPILER_TARGET})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

# needed ubuntu packages:
#
# sudo apt-get install -y \
# gcc-powerpc64le-linux-gnu \
# g++-powerpc64le-linux-gnu \
# qemu-user-system
8 changes: 8 additions & 0 deletions changelog/current.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## Fixes

- Fix [#464](https://github.com/biojppm/rapidyaml/issues/464): test failures with g++14 -O2 in ppc64le ([PR#467](https://github.com/biojppm/rapidyaml/pull/467))


## Thanks

- @musicinmybrain
50 changes: 20 additions & 30 deletions src/c4/yml/parse_engine.def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3511,12 +3511,11 @@ csubstr ParseEngine<EventHandler>::_filter_scalar_folded(substr s, size_t indent
template<class EventHandler>
csubstr ParseEngine<EventHandler>::_maybe_filter_key_scalar_plain(ScannedScalar const& C4_RESTRICT sc, size_t indentation)
{
csubstr maybe_filtered = sc.scalar;
if(sc.needs_filter)
{
if(m_options.scalar_filtering())
{
maybe_filtered = _filter_scalar_plain(sc.scalar, indentation);
return _filter_scalar_plain(sc.scalar, indentation);
}
else
{
Expand All @@ -3528,18 +3527,17 @@ csubstr ParseEngine<EventHandler>::_maybe_filter_key_scalar_plain(ScannedScalar
{
_c4dbgp("plain scalar doesn't need filtering");
}
return maybe_filtered;
return sc.scalar;
}

template<class EventHandler>
csubstr ParseEngine<EventHandler>::_maybe_filter_val_scalar_plain(ScannedScalar const& C4_RESTRICT sc, size_t indentation)
{
csubstr maybe_filtered = sc.scalar;
if(sc.needs_filter)
{
if(m_options.scalar_filtering())
{
maybe_filtered = _filter_scalar_plain(sc.scalar, indentation);
return _filter_scalar_plain(sc.scalar, indentation);
}
else
{
Expand All @@ -3551,7 +3549,7 @@ csubstr ParseEngine<EventHandler>::_maybe_filter_val_scalar_plain(ScannedScalar
{
_c4dbgp("plain scalar doesn't need filtering");
}
return maybe_filtered;
return sc.scalar;
}


Expand All @@ -3560,12 +3558,11 @@ csubstr ParseEngine<EventHandler>::_maybe_filter_val_scalar_plain(ScannedScalar
template<class EventHandler>
csubstr ParseEngine<EventHandler>::_maybe_filter_key_scalar_squot(ScannedScalar const& C4_RESTRICT sc)
{
csubstr maybe_filtered = sc.scalar;
if(sc.needs_filter)
{
if(m_options.scalar_filtering())
{
maybe_filtered = _filter_scalar_squot(sc.scalar);
return _filter_scalar_squot(sc.scalar);
}
else
{
Expand All @@ -3577,18 +3574,17 @@ csubstr ParseEngine<EventHandler>::_maybe_filter_key_scalar_squot(ScannedScalar
{
_c4dbgp("squo key scalar doesn't need filtering");
}
return maybe_filtered;
return sc.scalar;
}

template<class EventHandler>
csubstr ParseEngine<EventHandler>::_maybe_filter_val_scalar_squot(ScannedScalar const& C4_RESTRICT sc)
{
csubstr maybe_filtered = sc.scalar;
if(sc.needs_filter)
{
if(m_options.scalar_filtering())
{
maybe_filtered = _filter_scalar_squot(sc.scalar);
return _filter_scalar_squot(sc.scalar);
}
else
{
Expand All @@ -3600,7 +3596,7 @@ csubstr ParseEngine<EventHandler>::_maybe_filter_val_scalar_squot(ScannedScalar
{
_c4dbgp("squo val scalar doesn't need filtering");
}
return maybe_filtered;
return sc.scalar;
}


Expand All @@ -3609,12 +3605,11 @@ csubstr ParseEngine<EventHandler>::_maybe_filter_val_scalar_squot(ScannedScalar
template<class EventHandler>
csubstr ParseEngine<EventHandler>::_maybe_filter_key_scalar_dquot(ScannedScalar const& C4_RESTRICT sc)
{
csubstr maybe_filtered = sc.scalar;
if(sc.needs_filter)
{
if(m_options.scalar_filtering())
{
maybe_filtered = _filter_scalar_dquot(sc.scalar);
return _filter_scalar_dquot(sc.scalar);
}
else
{
Expand All @@ -3626,18 +3621,17 @@ csubstr ParseEngine<EventHandler>::_maybe_filter_key_scalar_dquot(ScannedScalar
{
_c4dbgp("dquo scalar doesn't need filtering");
}
return maybe_filtered;
return sc.scalar;
}

template<class EventHandler>
csubstr ParseEngine<EventHandler>::_maybe_filter_val_scalar_dquot(ScannedScalar const& C4_RESTRICT sc)
{
csubstr maybe_filtered = sc.scalar;
if(sc.needs_filter)
{
if(m_options.scalar_filtering())
{
maybe_filtered = _filter_scalar_dquot(sc.scalar);
return _filter_scalar_dquot(sc.scalar);
}
else
{
Expand All @@ -3649,7 +3643,7 @@ csubstr ParseEngine<EventHandler>::_maybe_filter_val_scalar_dquot(ScannedScalar
{
_c4dbgp("dquo scalar doesn't need filtering");
}
return maybe_filtered;
return sc.scalar;
}


Expand All @@ -3658,33 +3652,31 @@ csubstr ParseEngine<EventHandler>::_maybe_filter_val_scalar_dquot(ScannedScalar
template<class EventHandler>
csubstr ParseEngine<EventHandler>::_maybe_filter_key_scalar_literal(ScannedBlock const& C4_RESTRICT sb)
{
csubstr maybe_filtered = sb.scalar;
if(m_options.scalar_filtering())
{
maybe_filtered = _filter_scalar_literal(sb.scalar, sb.indentation, sb.chomp);
return _filter_scalar_literal(sb.scalar, sb.indentation, sb.chomp);
}
else
{
_c4dbgp("literal scalar left unfiltered");
m_evt_handler->mark_key_scalar_unfiltered();
}
return maybe_filtered;
return sb.scalar;
}

template<class EventHandler>
csubstr ParseEngine<EventHandler>::_maybe_filter_val_scalar_literal(ScannedBlock const& C4_RESTRICT sb)
{
csubstr maybe_filtered = sb.scalar;
if(m_options.scalar_filtering())
{
maybe_filtered = _filter_scalar_literal(sb.scalar, sb.indentation, sb.chomp);
return _filter_scalar_literal(sb.scalar, sb.indentation, sb.chomp);
}
else
{
_c4dbgp("literal scalar left unfiltered");
m_evt_handler->mark_val_scalar_unfiltered();
}
return maybe_filtered;
return sb.scalar;
}


Expand All @@ -3693,33 +3685,31 @@ csubstr ParseEngine<EventHandler>::_maybe_filter_val_scalar_literal(ScannedBlock
template<class EventHandler>
csubstr ParseEngine<EventHandler>::_maybe_filter_key_scalar_folded(ScannedBlock const& C4_RESTRICT sb)
{
csubstr maybe_filtered = sb.scalar;
if(m_options.scalar_filtering())
{
maybe_filtered = _filter_scalar_folded(sb.scalar, sb.indentation, sb.chomp);
return _filter_scalar_folded(sb.scalar, sb.indentation, sb.chomp);
}
else
{
_c4dbgp("folded scalar left unfiltered");
m_evt_handler->mark_key_scalar_unfiltered();
}
return maybe_filtered;
return sb.scalar;
}

template<class EventHandler>
csubstr ParseEngine<EventHandler>::_maybe_filter_val_scalar_folded(ScannedBlock const& C4_RESTRICT sb)
{
csubstr maybe_filtered = sb.scalar;
if(m_options.scalar_filtering())
{
maybe_filtered = _filter_scalar_folded(sb.scalar, sb.indentation, sb.chomp);
return _filter_scalar_folded(sb.scalar, sb.indentation, sb.chomp);
}
else
{
_c4dbgp("folded scalar left unfiltered");
m_evt_handler->mark_val_scalar_unfiltered();
}
return maybe_filtered;
return sb.scalar;
}


Expand Down

0 comments on commit 346c0c1

Please sign in to comment.