From 0fb544f5c9716a649c88935bacc93d200553378d Mon Sep 17 00:00:00 2001 From: Jonathan Poelen Date: Wed, 31 Jul 2024 17:39:10 +0200 Subject: [PATCH] ARM support: disable -msse flag and SSE instruction call with -s TARGET=arm (#173) --- README.md | 11 +++++++++++ jam/cxxflags.jam | 1 - jam/defines.jam | 11 +++++++++-- src/utils/primitives/primitives.cpp | 8 ++++++-- src/utils/primitives/primitives_sse2.cpp | 4 ++++ 5 files changed, 30 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 5d6d2bac90..9be3d64c0e 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ The project also contains 2 RDP clients: 1. [Setting build variables](#setting-build-variables) 1. [Local installation](#local-installation) 2. [Musl libc](#musl-libc) + 3. [ARM](#arm) 6. [Add .cpp file](#add-cpp-file) 2. [Run Redemption](#run-redemption) 3. [Setting Redemption](#setting-redemption) @@ -49,6 +50,8 @@ The project also contains 2 RDP clients: For automatic compilation, a Dockerfile is available. This one is based on Ubuntu, but other linux systems are supported like Debian or Alpine. For the latter, `-s MUSL_LIBC=1` must be added on the line containing `bjam` and the `libgettext` package must be added in the installed package. +For ARM, `-s TARGET=arm` must be added on the line containing `bjam`. + The following is for manual installation. @@ -272,6 +275,14 @@ bjam .... bjam -s MUSL_LIBC=1 .... ``` +#### ARM + +```sh +bjam -s TARGET=arm .... +``` + +`TARGET=arm` involves `NO_HYPERSCAN=1`. + ## Add .cpp file The compiled files are referenced in `targets.jam`. This is a file that is generated via `./tools/bjam/gen_targets.py` and is updated with `bjam targets.jam` or `./tools/bjam/gen_targets.py > targets.jam`. diff --git a/jam/cxxflags.jam b/jam/cxxflags.jam index 4bd0805810..8abf5ac574 100644 --- a/jam/cxxflags.jam +++ b/jam/cxxflags.jam @@ -2,7 +2,6 @@ REDEMPTION_CXXFLAGS += -std=c++2a - -msse3 # clang-12 use -fbracket-depth as fold limit... clang:-fbracket-depth=512 diff --git a/jam/defines.jam b/jam/defines.jam index 25c9a1f80b..a8b81cf709 100644 --- a/jam/defines.jam +++ b/jam/defines.jam @@ -15,6 +15,15 @@ rule setvar ( env : default ) } } +if [ os.environ TARGET ] = "arm" { + REDEMPTION_CXXFLAGS += REDEMPTION_NO_SSE ; + constant NO_HYPERSCAN : 1 ; +} +else { + REDEMPTION_CXXFLAGS += -msse3 ; + constant NO_HYPERSCAN : [ setvar NO_HYPERSCAN : 0 ] ; # disable libhs. /!\ Test of pattern will fails +} + constant MUSL_LIBC : [ setvar MUSL_LIBC : 0 ] ; if $(MUSL_LIBC) != 0 @@ -103,8 +112,6 @@ constant FFMPEG_LIB_PATH : [ setvar FFMPEG_LIB_PATH : $(_FFMPEG_LIB_PATH) ] ; # constant FFMPEG_LINK_MODE : [ setvar FFMPEG_LINK_MODE : $(_FFMPEG_LINK_MODE) ] ; # static or shared constant NO_FFMPEG : [ setvar NO_FFMPEG : 0 ] ; -constant NO_HYPERSCAN : [ setvar NO_HYPERSCAN : 0 ] ; # disable libhs. /!\ Test of pattern will fails - constant BOOST_STACKTRACE : [ setvar BOOST_STACKTRACE : 0 ] ; # `-sBOOST_STACKTRACE=1` (for debug and san mode) require libboost_stacktrace_backtrace (apt install libboost-stacktrace-dev). Other values are addr2line (libboost_stacktrace_addr2line), basic (libboost_stacktrace_basic) and static_backtrace (libbacktrace). Use REDEMPTION_FILTER_ERROR shell variable for disable backtrace of specific error (see `src/core/error.hpp`). example: `export REDEMPTION_FILTER_ERROR=ERR_TRANSPORT_NO_MORE_DATA,ERR_SEC`. constant FAST_CHECK : [ setvar FAST_CHECK : 0 ] ; # fast RED_CHECK(...) and co diff --git a/src/utils/primitives/primitives.cpp b/src/utils/primitives/primitives.cpp index c7ab47ef2d..fcbd715ce3 100644 --- a/src/utils/primitives/primitives.cpp +++ b/src/utils/primitives/primitives.cpp @@ -173,7 +173,11 @@ Primitives::pstatus_t general_yCbCrToRGB_16s8u_P3AC4R( } -#ifndef __EMSCRIPTEN__ +#ifdef __EMSCRIPTEN__ +# define REDEMPTION_NO_SSE +#endif + +#ifndef REDEMPTION_NO_SSE #include @@ -199,7 +203,7 @@ Primitives::Primitives() noexcept : lShiftC_16s(general_lShiftC_16s) , yCbCrToRGB_16s8u_P3AC4R(general_yCbCrToRGB_16s8u_P3AC4R) { -#ifndef __EMSCRIPTEN__ +#ifndef REDEMPTION_NO_SSE if (haveSSSE3()) { init_sse(this); } diff --git a/src/utils/primitives/primitives_sse2.cpp b/src/utils/primitives/primitives_sse2.cpp index e84c663e13..40e5d94292 100644 --- a/src/utils/primitives/primitives_sse2.cpp +++ b/src/utils/primitives/primitives_sse2.cpp @@ -18,6 +18,8 @@ Author(s): David Fort */ +#ifndef REDEMPTION_NO_SSE + #include #include @@ -448,3 +450,5 @@ void init_sse(Primitives *prims) noexcept prims->lShiftC_16s = sse2_lShiftC_16s; prims->yCbCrToRGB_16s8u_P3AC4R = sse2_yCbCrToRGB_16s8u_P3AC4R; } + +#endif