Skip to content

Commit

Permalink
re #464: smaller test case; cross-compile, qemu; command:
Browse files Browse the repository at this point in the history
set -xe ; cd ~/proj/rapidyaml/samples/add_subdirectory/ ; sys=powerpc64le ; cxxflags="-O2 -flto=auto -ffat-lto-objects  -fexceptions -g -grecord-gcc-switches -pipe -Wall -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -std=c++11 -DNDEBUG" ; bdir=build/$sys ; mkdir -p $bdir ; cmake -S . -B $bdir -D CMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS_RELEASE:STRING="$cxxflags" --toolchain ../../.github/toolchains/linux-gnu-$sys.cmake ; cmake --build $bdir --target run -j --verbose
  • Loading branch information
biojppm committed Aug 20, 2024
1 parent 5e91f35 commit 0b4ce47
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 45 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
92 changes: 51 additions & 41 deletions .github/workflows/rarearchs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,57 +113,67 @@ jobs:
time apt-get install kitware-archive-keyring
time apt-get update -y
fi
time apt-get install -y cmake cmake-data
time apt-get install -y cmake cmake-data python3
cmake --version
echo "install took $((SECONDS - start_time))"
echo "install took $((SECONDS - start_time))s"
run: |
set -xe
start_time=$SECONDS
uname -a
pwd
ls -lFhp .
#
# https://stackoverflow.com/questions/5470257/how-to-see-which-flags-march-native-will-activate
echo | c++ -O0 -Q -E -v - </dev/null 2>&1
echo | c++ -O0 -Q -c --help=optimizers --help=target
echo | c++ -O0 -dM -E - | sort
echo -----
echo | c++ -O1 -Q -E -v - </dev/null 2>&1
echo | c++ -O1 -Q -c --help=optimizers --help=target
echo | c++ -O1 -dM -E - | sort
echo -----
echo | c++ -O2 -Q -E -v - </dev/null 2>&1
echo | c++ -O2 -Q -c --help=optimizers --help=target
echo | c++ -O2 -dM -E - | sort
echo -----
echo | c++ -O3 -Q -E -v - </dev/null 2>&1
echo | c++ -O3 -Q -c --help=optimizers --help=target
echo | c++ -O3 -dM -E - | sort
echo =====
#
##
## https://stackoverflow.com/questions/5470257/how-to-see-which-flags-march-native-will-activate
#echo | c++ -O0 -Q -E -v - </dev/null 2>&1
#echo | c++ -O0 -Q -c --help=optimizers --help=target
#echo | c++ -O0 -dM -E - | sort
#echo -----
#echo | c++ -O1 -Q -E -v - </dev/null 2>&1
#echo | c++ -O1 -Q -c --help=optimizers --help=target
#echo | c++ -O1 -dM -E - | sort
#echo -----
#echo | c++ -O2 -Q -E -v - </dev/null 2>&1
#echo | c++ -O2 -Q -c --help=optimizers --help=target
#echo | c++ -O2 -dM -E - | sort
#echo -----
#echo | c++ -O3 -Q -E -v - </dev/null 2>&1
#echo | c++ -O3 -Q -c --help=optimizers --help=target
#echo | c++ -O3 -dM -E - | sort
#echo =====
##
bdir=build_${{matrix.arch}}_${{matrix.bt}}_${{matrix.std}}
idir=install_${{matrix.arch}}_${{matrix.bt}}_${{matrix.std}}
mkdir -p $bdir
#
cmd="cmake -S . -B $bdir \
-DCMAKE_INSTALL_PREFIX=$idir \
-DCMAKE_BUILD_TYPE=${{matrix.bt}} \
-DC4_CXX_STANDARD=${{matrix.std}} \
-DCXX_STANDARD=${{matrix.std}} \
-DRYML_DEV=ON \
-DRYML_TEST_SUITE=ON \
-DRYML_BUILD_BENCHMARKS=OFF \
-DRYML_SANITIZE=OFF \
-DRYML_LINT=OFF \
-DRYML_VALGRIND=OFF"
echo $cmd
cd samples/singleheader
mkdir -p $bdir
if [ -z "${{matrix.cxxflags}}" ] ; then
time $cmd
time cmake -S . -B $bdir -DCMAKE_BUILD_TYPE=${{matrix.bt}}
else
time $cmd -DCMAKE_CXX_FLAGS_RELEASE:STRING="${{matrix.cxxflags}}"
time cmake -S . -B $bdir -DCMAKE_BUILD_TYPE=${{matrix.bt}} \
-DCMAKE_CXX_FLAGS_RELEASE:STRING="${{matrix.cxxflags}}"
fi
#
time cmake --build $bdir --verbose -j 4 --target ryml-test-build
#
time cmake --build $bdir --target ryml-test-run
echo "run took $((SECONDS - start_time))"
cmake --build $bdir --config ${{matrix.bt}} -j 3 --target run
##
#mkdir -p $bdir
#cmd="cmake -S . -B $bdir \
# -DCMAKE_INSTALL_PREFIX=$idir \
# -DCMAKE_BUILD_TYPE=${{matrix.bt}} \
# -DC4_CXX_STANDARD=${{matrix.std}} \
# -DCXX_STANDARD=${{matrix.std}} \
# -DRYML_DEV=ON \
# -DRYML_TEST_SUITE=ON \
# -DRYML_BUILD_BENCHMARKS=OFF \
# -DRYML_SANITIZE=OFF \
# -DRYML_LINT=OFF \
# -DRYML_VALGRIND=OFF"
#echo $cmd
#if [ -z "${{matrix.cxxflags}}" ] ; then
# time $cmd
#else
# time $cmd -DCMAKE_CXX_FLAGS_RELEASE:STRING="${{matrix.cxxflags}}"
#fi
##
#time cmake --build $bdir --verbose -j 4 --target ryml-test-build
##
#time cmake --build $bdir --target ryml-test-run
echo "run took $((SECONDS - start_time))s"
13 changes: 9 additions & 4 deletions samples/quickstart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ int report_checks();

int main()
{
sample::sample_json();
#ifdef WTF
sample::sample_lightning_overview();
sample::sample_quick_overview();
sample::sample_substr();
Expand Down Expand Up @@ -113,6 +115,7 @@ int main()
sample::sample_per_tree_allocator();
sample::sample_static_trees();
sample::sample_location_tracking();
#endif // WTF
return sample::report_checks();
}

Expand Down Expand Up @@ -229,7 +232,6 @@ struct CheckPredicate
#define CHECK(predicate) assert(predicate)
#endif


// helper functions for sample_parse_file()
template<class CharContainer> CharContainer file_get_contents(const char *filename);
template<class CharContainer> size_t file_get_contents(const char *filename, CharContainer *v);
Expand Down Expand Up @@ -264,6 +266,7 @@ struct ScopedErrorHandlerExample : public ErrorHandlerExample
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------

#ifdef WTF
/** a lightning tour over most features
* see @ref sample_quick_overview */
void sample_lightning_overview()
Expand Down Expand Up @@ -4268,7 +4271,7 @@ void sample_emit_style()

//-----------------------------------------------------------------------------


#endif // WTF
/** shows how to parse and emit JSON. */
void sample_json()
{
Expand All @@ -4286,11 +4289,13 @@ void sample_json()
// has a smaller grammar:
ryml::Tree json_tree = ryml::parse_json_in_arena(json);
// to emit JSON, use the proper overload:
std::cout << "WTF1:\n" << ryml::emitrs_json<std::string>(tree) << "\n";
CHECK(ryml::emitrs_json<std::string>(tree) == R"({"doe": "a deer, a female deer","ray": "a drop of golden sun","me": "a name, I call myself","far": "a long long way to go"})");
CHECK(ryml::emitrs_json<std::string>(json_tree) == R"({"doe": "a deer, a female deer","ray": "a drop of golden sun","me": "a name, I call myself","far": "a long long way to go"})");
// to emit JSON to a stream:
std::stringstream ss;
ss << ryml::as_json(tree); // <- mark it like this
std::cout << "WTF2:\n" << ss.str() << "\n";
CHECK(ss.str() == R"({"doe": "a deer, a female deer","ray": "a drop of golden sun","me": "a name, I call myself","far": "a long long way to go"})");
// Note the following limitations:
//
Expand All @@ -4304,7 +4309,7 @@ void sample_json()
// - anchors and references cannot be emitted as json and
// are not allowed.
}

#ifdef WTF

//-----------------------------------------------------------------------------

Expand Down Expand Up @@ -5185,7 +5190,7 @@ seq with key:
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------


#endif // WTF
/** @addtogroup doc_sample_helpers
* @{ */

Expand Down

0 comments on commit 0b4ce47

Please sign in to comment.