From 805b358bafa47e8bc3c08bf400dd66e164065615 Mon Sep 17 00:00:00 2001 From: liushuyu Date: Mon, 12 Sep 2022 21:40:53 -0600 Subject: [PATCH] CI: workaround an issue with non-amd64 build --- .ci/deps.sh | 3 ++ patches/0002-fix-non-amd64-linkage.patch | 33 +++++++++++++++++++ patches/1001-fix-token-handling.patch | 40 ++++++++++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 patches/0002-fix-non-amd64-linkage.patch create mode 100644 patches/1001-fix-token-handling.patch diff --git a/.ci/deps.sh b/.ci/deps.sh index 1a5c608..9651047 100755 --- a/.ci/deps.sh +++ b/.ci/deps.sh @@ -66,3 +66,6 @@ download_extract "https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VER ./bootstrap.sh --with-libraries=context,container,system,headers ./b2 -j "$(nproc)" install --prefix=/usr/local popd + +# fake xbyak for non-amd64 (workaround a CMakeLists bug in yuzu) +echo '!' > /usr/local/lib/libxbyak.a diff --git a/patches/0002-fix-non-amd64-linkage.patch b/patches/0002-fix-non-amd64-linkage.patch new file mode 100644 index 0000000..46b7445 --- /dev/null +++ b/patches/0002-fix-non-amd64-linkage.patch @@ -0,0 +1,33 @@ +From 7ccb6aa7c216401aea1cf09adeb7d07ce077580b Mon Sep 17 00:00:00 2001 +From: liushuyu +Date: Mon, 12 Sep 2022 23:01:44 -0600 +Subject: [PATCH] common: do not link to xbyak on non-amd64 architectures + +--- + src/common/CMakeLists.txt | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt +index 635fb85c8..b1e0ba6cc 100644 +--- a/src/common/CMakeLists.txt ++++ b/src/common/CMakeLists.txt +@@ -166,6 +166,7 @@ if(ARCHITECTURE_x86_64) + x64/xbyak_abi.h + x64/xbyak_util.h + ) ++ target_link_libraries(common PRIVATE xbyak) + endif() + + if (MSVC) +@@ -189,7 +190,7 @@ endif() + create_target_directory_groups(common) + + target_link_libraries(common PUBLIC ${Boost_LIBRARIES} fmt::fmt microprofile Threads::Threads) +-target_link_libraries(common PRIVATE lz4::lz4 xbyak) ++target_link_libraries(common PRIVATE lz4::lz4) + if (TARGET zstd::zstd) + target_link_libraries(common PRIVATE zstd::zstd) + else() +-- +2.37.3 + diff --git a/patches/1001-fix-token-handling.patch b/patches/1001-fix-token-handling.patch new file mode 100644 index 0000000..2e22c0a --- /dev/null +++ b/patches/1001-fix-token-handling.patch @@ -0,0 +1,40 @@ +From 047c9a2f793cc426e281bb50aa7d073e8f638269 Mon Sep 17 00:00:00 2001 +From: liushuyu +Date: Mon, 12 Sep 2022 23:17:21 -0600 +Subject: [PATCH] dedicated_room: fix token padding ... + +... mebedtls' base64 routine has a strange behavioral issue where if the +input is invalid, it will not report it as invalid, but rather returning +a bunch of garbage data. This new round-tripping padding method should +eliminate such issue. +--- + src/dedicated_room/yuzu_room.cpp | 13 ++++++++++++- + 1 file changed, 12 insertions(+), 1 deletion(-) + +diff --git a/src/dedicated_room/yuzu_room.cpp b/src/dedicated_room/yuzu_room.cpp +index 7b6deba41..359891883 100644 +--- a/src/dedicated_room/yuzu_room.cpp ++++ b/src/dedicated_room/yuzu_room.cpp +@@ -76,7 +76,18 @@ static constexpr char BanListMagic[] = "YuzuRoom-BanList-1"; + static constexpr char token_delimiter{':'}; + + static void PadToken(std::string& token) { +- while (token.size() % 4 != 0) { ++ std::size_t outlen = 0; ++ ++ std::array output{}; ++ std::array roundtrip{}; ++ for (size_t i = 0; i < 3; i++) { ++ mbedtls_base64_decode(output.data(), output.size(), &outlen, ++ reinterpret_cast(token.c_str()), ++ token.length()); ++ mbedtls_base64_encode(roundtrip.data(), roundtrip.size(), &outlen, output.data(), outlen); ++ if (memcmp(roundtrip.data(), token.data(), token.size()) == 0) { ++ break; ++ } + token.push_back('='); + } + } +-- +2.37.3 +