Skip to content

Commit

Permalink
ARM support: disable -msse flag and SSE instruction call with -s TARG…
Browse files Browse the repository at this point in the history
…ET=arm (#173)
  • Loading branch information
jonathanpoelen committed Jul 31, 2024
1 parent 1753417 commit 0fb544f
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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.


Expand Down Expand Up @@ -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`.
Expand Down
1 change: 0 additions & 1 deletion jam/cxxflags.jam
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

REDEMPTION_CXXFLAGS +=
<cxxflags>-std=c++2a
<cxxflags>-msse3

# clang-12 use -fbracket-depth as fold limit...
<toolset>clang:<cxxflags>-fbracket-depth=512
Expand Down
11 changes: 9 additions & 2 deletions jam/defines.jam
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ rule setvar ( env : default )
}
}

if [ os.environ TARGET ] = "arm" {
REDEMPTION_CXXFLAGS += <define>REDEMPTION_NO_SSE ;
constant NO_HYPERSCAN : 1 ;
}
else {
REDEMPTION_CXXFLAGS += <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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions src/utils/primitives/primitives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <cpuid.h>

Expand All @@ -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);
}
Expand Down
4 changes: 4 additions & 0 deletions src/utils/primitives/primitives_sse2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
Author(s): David Fort
*/

#ifndef REDEMPTION_NO_SSE

#include <emmintrin.h>
#include <pmmintrin.h>

Expand Down Expand Up @@ -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

0 comments on commit 0fb544f

Please sign in to comment.