AviSynthPlus icon indicating copy to clipboard operation
AviSynthPlus copied to clipboard

Can not build with clang in r2819

Open fuchanghao opened this issue 5 years ago • 40 comments

Seems the MSVC version check didn't work fine with clang.

The C compiler identification is Clang 3.8.0 The CXX compiler identification is Clang 3.8.0 Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/ClangC2/14.10.25903/bin/HostX86/clang.exe Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/ClangC2/14.10.25903/bin/HostX86/clang.exe -- works Detecting C compiler ABI info Detecting C compiler ABI info - done Detecting C compile features Detecting C compile features - done Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/ClangC2/14.10.25903/bin/HostX86/clang.exe Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/ClangC2/14.10.25903/bin/HostX86/clang.exe -- works Detecting CXX compiler ABI info Detecting CXX compiler ABI info - done Detecting CXX compile features Detecting CXX compile features - done CMake Error at CMakeLists.txt:26 (MESSAGE): Visual C++ 2017 or newer required.

fuchanghao avatar Mar 16 '19 15:03 fuchanghao

Which toolset are you using?

Seems like the toolset check is not complete, and this clang version does not report MS compatible versioning, it's not pretending to be an ms cl-compatible compiler. Have you used clang based avisynth compilation previously?

  • Added VS 2017 install option clang_c2 toolset support (optional)
  • (Removed v140 toolset, don't know if it was necessary or not)
  • Fresh installed LLVM 7.0.1
  • replaced toolset.targets and toolset.props (located in c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Platforms\x64\PlatformToolsets\v141_clang_c2) to a special version found here: https://stackoverflow.com/questions/43464856/integrate-llvm-clang-4-x-x-5-x-x-6-x-x-into-visual-studio-2017
  • I'm using from cmake GUI, and choose v141_clang_c2 as the -T optional toolset.
  • I had the following log (see later):
  • had to edit compiler flags and the cmakelists.txt to update or delete some default compiler options, but finally
  • succeeded with compiling an x64 avisynth.dll (no time to try if it really worked)

So the log: The C compiler identification is MSVC 19.16.27027.1 The CXX compiler identification is MSVC 19.16.27027.1 Check for working C compiler: C:/Program Files/LLVM/bin/clang.exe Check for working C compiler: C:/Program Files/LLVM/bin/clang.exe -- works Detecting C compiler ABI info Detecting C compiler ABI info - done Check for working CXX compiler: C:/Program Files/LLVM/bin/clang.exe Check for working CXX compiler: C:/Program Files/LLVM/bin/clang.exe -- works Detecting CXX compiler ABI info Detecting CXX compiler ABI info - done Detecting CXX compile features Detecting CXX compile features - done v141_clang_c2 toolset was specified via -T. Reported MSVC_VERSION is: 1916 Found Git: C:/Program Files/Git/cmd/git.exe (found version "2.17.1.windows.2") Configuring done

pinterf avatar Mar 16 '19 23:03 pinterf

seem there's an easy way.

change Cmakelists.txt "v141_clang_c2" to "llvm"

Install Clang Power Tools & LLVM Compiler Toolchain

https://marketplace.visualstudio.com/items?itemName=caphyon.ClangPowerTools https://marketplace.visualstudio.com/items?itemName=LLVMExtensions.llvm-toolchain

Cmake log

The C compiler identification is Clang 7.0.1 The CXX compiler identification is Clang 7.0.1 Check for working C compiler: C:/Program Files/LLVM/bin/clang-cl.exe Check for working C compiler: C:/Program Files/LLVM/bin/clang-cl.exe -- works Detecting C compiler ABI info Detecting C compiler ABI info - done Detecting C compile features Detecting C compile features - done Check for working CXX compiler: C:/Program Files/LLVM/bin/clang-cl.exe Check for working CXX compiler: C:/Program Files/LLVM/bin/clang-cl.exe -- works Detecting CXX compiler ABI info Detecting CXX compiler ABI info - done Detecting CXX compile features Detecting CXX compile features - done llvm toolset was specified via -T. Reported MSVC_VERSION is: 1916 Found Git: C:/Program Files/Git/cmd/git.exe (found version "2.21.0.windows.1") Configuring done Generating done

fuchanghao avatar Mar 17 '19 02:03 fuchanghao

Yeah, much simpler. But something is still different.

How did you make it built?

When I said that I had successful build with the "hacked" v141_clang_c2, I was wrong. It seems that not the right cl.exe was used, the compilation was still using the original CL.EXE as shown in the build log (Tools|Options|Projects and solutions|MS Build Verbosity: "Detailed":

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\CL.exe .. etc.......

With LLVM toolset chosen, the proper compiler is used as seen from the verbose build log: C:\Program Files\LLVM\bin\clang-cl.exe /c etc....

So with LLVM toolset the project does not compile (undeclared identifier errors on sse 4.1 things like _mm_packus_epi32), because for example convert.cpp requires sse4.1 intrinsic. O.K., I put the include: #include <smmintrin.h>

But after providing that this type of errors appear: always_inline function '_mm_packus_epi32' requires target feature 'sse4.1', but would be inlined into function 'convert_rgb_uint16_to_uint16_sse2' that is compiled without support for 'sse4.1'

Unlike clang-cl (maybe I'm not aware of a magic compiler switch) MSVC allows using SSE4.1 intrinsics (in MSVC there is no specific "-msse41" for that), if I emit that intrinsic it will insert an SSE4.1 instruction even if the project is compiled to SSE2 as general.

pinterf avatar Mar 17 '19 08:03 pinterf

From what I understand of the way Clang works internally, if it's not mimicking MSVC on Windows, it's mimicking GCC. And that intrinsics issue is something that GCC suffers from too.

The solution, ultimately, is to do for every SIMD set what we do for avx and avx2, so that none of the intrinsics alters the way the whole project is optimized; doing so should also allow for building without any intrinsics/asm at all, which will help any possible effort to build for alternate platforms like ARM (which Windows 10 does exist for, and ReactOS may eventually become available for as well, setting aside any Linux effort that would make ARM and PowerPC relevant somewhat immediately).

qyot27 avatar Mar 17 '19 19:03 qyot27

* v141_clang_c2

After using your guide,

I still can't build Shibatch the same as using MSVC and it will crash the Visual Studio 2017.

I also tried v142 in visual studio 2019 RC it showed the same error.

2>byte_order_helper.cpp 2>d:\source code\avisynth\avisynthplus\plugins\shibatch\pfc\ptr_list.h(190): error C2065: “delete_all”: 未声明的标识符 2>d:\source code\avisynth\avisynthplus\plugins\shibatch\pfc\ptr_list.h(190): error C3861: “delete_all”: 找不到标识符 2>d:\source code\avisynth\avisynthplus\plugins\shibatch\pfc\ptr_list.h(190): note: “delete_all”: 函数声明必须可用,因为所有参数都不依赖于模板参数 2>d:\source code\avisynth\avisynthplus\plugins\shibatch\pfc\ptr_list.h(191): note: 参见对正在编译的 类 模板 实例化 "ptr_list_autodel_t<T>" 的引用 2>d:\source code\avisynth\avisynthplus\plugins\shibatch\pfc\ptr_list.h(198): error C2065: “free_all”: 未声明的标识符 2>d:\source code\avisynth\avisynthplus\plugins\shibatch\pfc\ptr_list.h(198): error C3861: “free_all”: 找不到标识符 2>d:\source code\avisynth\avisynthplus\plugins\shibatch\pfc\ptr_list.h(198): note: “free_all”: 函数声明必须可用,因为所有参数都不依赖于模板参数 2>d:\source code\avisynth\avisynthplus\plugins\shibatch\pfc\ptr_list.h(199): note: 参见对正在编译的 类 模板 实例化 "ptr_list_autofree_t<T>" 的引用

Clang-cl won't cause that error.

but it also has the error:

3>D:\Source code\AviSynth\AviSynthPlus\plugins\Shibatch\ssrc.cpp(162): error : expected parentheses around type name in sizeof expression

fuchanghao avatar Mar 18 '19 04:03 fuchanghao

In newer gcc (and clang?) function level attributes exist. https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#Common-Function-Attributes See "target" section. E.g.

int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
int sse3_func (void) __attribute__ ((__target__ ("sse3")));

This is an easy way to go.

Still I think that functions that are compiled with sse2 or sse4.1 chosen purely on a template parameter should be reorganized a bit and should really be separated/moved to an include file. Plus some constexpr will also help which inactivates parts of code on compile time and does not depend on optimizer's choice whether it is included or not (like non-constexpr paths are existing in Debug builds).

Seems I'll have some work on this topic.

pinterf avatar Mar 18 '19 07:03 pinterf

Actually Shibatch source needed a minor fix to compile properly.

pinterf avatar Mar 18 '19 12:03 pinterf

Actually Shibatch source needed a minor fix to compile properly.

It works fine now.

fuchanghao avatar Mar 20 '19 13:03 fuchanghao

Those attributes will work, I'll probably implement them. I've just tried it on RemoveDirt project. So this is the way to go, probably works for gcc as well (contrary to the name of the option: no-gcc-compat) https://github.com/pinterf/RemoveDirt/blob/master/RemoveDirt/RemoveDirt.cpp#L955

pinterf avatar Mar 24 '19 14:03 pinterf

Please check latest commits. I'm using LLVM 8.0. Lots of code changes, mainly in order to let clang (and hopefully gcc) to apply special code generation attributes for CPU extensions (e.g. SSE4.1) for specific functions, without the need for moving those functions in a different source file.

@qyot27: could not try gcc, feel free to modify the #ifdef clang sections for gcc as well, when applying function attributes. I hope it'll work for you. I'll wait for your results.

pinterf avatar Mar 29 '19 15:03 pinterf

Any particular reason to use __clang__ instead of the CLANG define provided by avs/config.h?

Anyway, modifying all the places where #ifdef __clang__ showed up to #if defined(CLANG) || defined(GCC), unsetting -march=native in CMakeLists.txt, and attempting to build, it failed. GCC wants the attributes before the function definition. So I moved the ones that actually were setting attributes to up above the functions they were defined for, and this mostly succeeded. There were build errors in only two spots left: blend_common.cpp and resample.cpp:

[i686:$] ninja
[2/4] Building CXX object avs_core/CMa...r/filters/overlay/blend_common.cpp.obj
FAILED: avs_core/CMakeFiles/AvsCore.dir/filters/overlay/blend_common.cpp.obj 
/usr/bin/x86_64-w64-mingw32-g++  -DAvsCore_EXPORTS -DBUILDING_AVSCORE -I../../avs_core/include -Iavs_core -m32 -std=c++17 -MD -MT avs_core/CMakeFiles/AvsCore.dir/filters/overlay/blend_common.cpp.obj -MF avs_core/CMakeFiles/AvsCore.dir/filters/overlay/blend_common.cpp.obj.d -o avs_core/CMakeFiles/AvsCore.dir/filters/overlay/blend_common.cpp.obj -c ../../avs_core/filters/overlay/blend_common.cpp
../../avs_core/filters/overlay/blend_common.cpp: In function 'void overlay_blend_sse41_plane_masked(BYTE*, const BYTE*, const BYTE*, int, int, int, int, int) [with pixel_t = unsigned char; int bits_per_pixel = 8]':
../../avs_core/filters/overlay/blend_common.cpp:314:30: error: inlining failed in call to always_inline '__m128i simd_blend_epi8_sse41(const __m128i&, const __m128i&, const __m128i&)': target specific option mismatch
 static __forceinline __m128i simd_blend_epi8_sse41(__m128i const &selector, __m128i const &a, __m128i const &b)
                              ^~~~~~~~~~~~~~~~~~~~~
../../avs_core/filters/overlay/blend_common.cpp:443:39: note: called from here
         result = simd_blend_epi8_sse41(mask_00, dst, result); // ensure that zero mask value returns dst
                  ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
../../avs_core/filters/overlay/blend_common.cpp:314:30: error: inlining failed in call to always_inline '__m128i simd_blend_epi8_sse41(const __m128i&, const __m128i&, const __m128i&)': target specific option mismatch
 static __forceinline __m128i simd_blend_epi8_sse41(__m128i const &selector, __m128i const &a, __m128i const &b)
                              ^~~~~~~~~~~~~~~~~~~~~
../../avs_core/filters/overlay/blend_common.cpp:443:39: note: called from here
         result = simd_blend_epi8_sse41(mask_00, dst, result); // ensure that zero mask value returns dst
                  ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
../../avs_core/filters/overlay/blend_common.cpp:314:30: error: inlining failed in call to always_inline '__m128i simd_blend_epi8_sse41(const __m128i&, const __m128i&, const __m128i&)': target specific option mismatch
 static __forceinline __m128i simd_blend_epi8_sse41(__m128i const &selector, __m128i const &a, __m128i const &b)
                              ^~~~~~~~~~~~~~~~~~~~~
../../avs_core/filters/overlay/blend_common.cpp:446:39: note: called from here
         result = simd_blend_epi8_sse41(mask_FF, src, result); // ensure that max mask value returns src
                  ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
../../avs_core/filters/overlay/blend_common.cpp:314:30: error: inlining failed in call to always_inline '__m128i simd_blend_epi8_sse41(const __m128i&, const __m128i&, const __m128i&)': target specific option mismatch
 static __forceinline __m128i simd_blend_epi8_sse41(__m128i const &selector, __m128i const &a, __m128i const &b)
                              ^~~~~~~~~~~~~~~~~~~~~
../../avs_core/filters/overlay/blend_common.cpp:446:39: note: called from here
         result = simd_blend_epi8_sse41(mask_FF, src, result); // ensure that max mask value returns src
                  ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
[3/4] Building CXX object avs_core/CMa...s/AvsCore.dir/filters/resample.cpp.obj
FAILED: avs_core/CMakeFiles/AvsCore.dir/filters/resample.cpp.obj 
/usr/bin/x86_64-w64-mingw32-g++  -DAvsCore_EXPORTS -DBUILDING_AVSCORE -I../../avs_core/include -Iavs_core -m32 -std=c++17 -MD -MT avs_core/CMakeFiles/AvsCore.dir/filters/resample.cpp.obj -MF avs_core/CMakeFiles/AvsCore.dir/filters/resample.cpp.obj.d -o avs_core/CMakeFiles/AvsCore.dir/filters/resample.cpp.obj -c ../../avs_core/filters/resample.cpp
../../avs_core/filters/resample.cpp: In function 'void resize_v_ssse3_planar(BYTE*, const BYTE*, int, int, ResamplingProgram*, int, int, int, const int*, const void*) [with __m128i (* load)(const __m128i*) = simd_load_streaming]':
../../avs_core/filters/resample.cpp:81:23: error: inlining failed in call to always_inline '__m128i simd_load_streaming(const __m128i*)': target specific option mismatch
 __forceinline __m128i simd_load_streaming(const __m128i* adr)
                       ^~~~~~~~~~~~~~~~~~~
../../avs_core/filters/resample.cpp:415:29: note: called from here
         __m128i src_p = load(reinterpret_cast<const __m128i*>(src2_ptr));
                         ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ninja: build stopped: subcommand failed.
[i686:$] 

There were also errors relating to extern/static definitions in field.cpp, stemming from a mismatch in the "Factory methods" section between it and field.h, which has a similar section without the static keywords on the corresponding names.

qyot27 avatar Mar 29 '19 22:03 qyot27

I understood the resampler troubles, giving an SSE4.1 forceinlined function as template parameter for an SSSE3 function, strange clang did not noticed. A similar issue was fixed earlier at an other place which even caused internal compiler error :).

The other sse41 blend issue is probably solved by inserting that single instruction directly.

I have not yet changed the ifdefs for GCC and CLANG And I simply forgot that we have already a CLANG define About placing the attribute after the function: the sample I found and provided previously was using it in such a way.

So next try please, I hope we are getting closer to the final success.

pinterf avatar Mar 30 '19 06:03 pinterf

I understood the resampler troubles, giving an SSE4.1 forceinlined function as template parameter for an SSSE3 function, strange clang did not noticed. A similar issue was fixed earlier at an other place which even caused internal compiler error :).

The other sse41 blend issue is probably solved by inserting that single instruction directly.

I have not yet changed the ifdefs for GCC and CLANG And I simply forgot that we have already a CLANG define About placing the attribute after the function: the sample I found and provided previously was using it in such a way.

So next try please, I hope we are getting closer to the final success.

r2842 build with VS 2019 RC4 & LLVM 8.0 works fine.

Not test LLVM built's WinXP support. (MSVC v142 no longer support WinXP)

fuchanghao avatar Mar 31 '19 09:03 fuchanghao

LLVM dropped XP support 3 years ago.

@qyot27: by this documentation function attributes appear after the function: https://gcc.gnu.org/onlinedocs/gcc-4.9.1/gcc/Function-Attributes.html#Function-Attributes On the other hand, there are situations which feel better with placing them before the function. https://stackoverflow.com/questions/41159934/where-to-place-gcc-function-attribute-in-auto-function. Can you tell me which kind of functions (templated ones?) are those which do not like the 'after' syntax?

pinterf avatar Apr 08 '19 11:04 pinterf

After disabling the use of -march=native:

mkdir -p avisynth-build/i686 avisynth-build/amd64 && \

cd avisynth-build/i686 && \
    cmake ../../ -G "Ninja" -DCMAKE_INSTALL_PREFIX=$HOME/avisynth+_build/32bit \
    -DCMAKE_TOOLCHAIN_FILE="/usr/x86_64-w64-mingw32/toolchain-x86_64-w64-mingw32.cmake" \
    -DCMAKE_C_FLAGS="-m32" -DCMAKE_CXX_FLAGS="-m32" -DCMAKE_RC_FLAGS="-F pe-i386" \
    -DENABLE_PLUGINS:bool=off

-- The C compiler identification is GNU 8.3.0
-- The CXX compiler identification is GNU 8.3.0
-- Check for working C compiler: /usr/bin/x86_64-w64-mingw32-gcc
-- Check for working C compiler: /usr/bin/x86_64-w64-mingw32-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/x86_64-w64-mingw32-g++
-- Check for working CXX compiler: /usr/bin/x86_64-w64-mingw32-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Git: /usr/bin/git (found version "2.19.1") 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/qyot27/AviSynthPlus/avisynth-build/i686
[i686:$] ninja
[3/86] Building CXX object avs_core/CM...vsCore.dir/convert/convert_rgb.cpp.obj
FAILED: avs_core/CMakeFiles/AvsCore.dir/convert/convert_rgb.cpp.obj 
/usr/bin/x86_64-w64-mingw32-g++  -DAvsCore_EXPORTS -DBUILDING_AVSCORE -I../../avs_core/include -Iavs_core -m32 -std=c++17 -MD -MT avs_core/CMakeFiles/AvsCore.dir/convert/convert_rgb.cpp.obj -MF avs_core/CMakeFiles/AvsCore.dir/convert/convert_rgb.cpp.obj.d -o avs_core/CMakeFiles/AvsCore.dir/convert/convert_rgb.cpp.obj -c ../../avs_core/convert/convert_rgb.cpp
In file included from ../../avs_core/convert/convert_rgb.cpp:37:
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/tmmintrin.h: In function 'void convert_rgb48_to_rgb64_ssse3(const BYTE*, BYTE*, size_t, size_t, size_t, size_t)':
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/tmmintrin.h:136:1: error: inlining failed in call to always_inline '__m128i _mm_shuffle_epi8(__m128i, __m128i)': target specific option mismatch
 _mm_shuffle_epi8 (__m128i __X, __m128i __Y)
 ^~~~~~~~~~~~~~~~
../../avs_core/convert/convert_rgb.cpp:71:33: note: called from here
       __m128i dst = _mm_or_si128(alpha, _mm_shuffle_epi8(src0, mask0));
                     ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../../avs_core/convert/convert_rgb.cpp:37:
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/tmmintrin.h:136:1: error: inlining failed in call to always_inline '__m128i _mm_shuffle_epi8(__m128i, __m128i)': target specific option mismatch
 _mm_shuffle_epi8 (__m128i __X, __m128i __Y)
 ^~~~~~~~~~~~~~~~
../../avs_core/convert/convert_rgb.cpp:71:33: note: called from here
       __m128i dst = _mm_or_si128(alpha, _mm_shuffle_epi8(src0, mask0));
                     ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../../avs_core/convert/convert_rgb.cpp:37:
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/tmmintrin.h:136:1: error: inlining failed in call to always_inline '__m128i _mm_shuffle_epi8(__m128i, __m128i)': target specific option mismatch
 _mm_shuffle_epi8 (__m128i __X, __m128i __Y)
 ^~~~~~~~~~~~~~~~
../../avs_core/convert/convert_rgb.cpp:76:25: note: called from here
       dst = _mm_or_si128(alpha, _mm_shuffle_epi8(tmp, mask0));
             ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../../avs_core/convert/convert_rgb.cpp:37:
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/tmmintrin.h:136:1: error: inlining failed in call to always_inline '__m128i _mm_shuffle_epi8(__m128i, __m128i)': target specific option mismatch
 _mm_shuffle_epi8 (__m128i __X, __m128i __Y)
 ^~~~~~~~~~~~~~~~
../../avs_core/convert/convert_rgb.cpp:81:25: note: called from here
       dst = _mm_or_si128(alpha, _mm_shuffle_epi8(tmp, mask0));
             ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../../avs_core/convert/convert_rgb.cpp:37:
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/tmmintrin.h:136:1: error: inlining failed in call to always_inline '__m128i _mm_shuffle_epi8(__m128i, __m128i)': target specific option mismatch
 _mm_shuffle_epi8 (__m128i __X, __m128i __Y)
 ^~~~~~~~~~~~~~~~
../../avs_core/convert/convert_rgb.cpp:84:25: note: called from here
       dst = _mm_or_si128(alpha, _mm_shuffle_epi8(src2, mask1));
             ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[4/86] Building CXX object avs_core/CM...ore.dir/convert/convert_planar.cpp.obj
FAILED: avs_core/CMakeFiles/AvsCore.dir/convert/convert_planar.cpp.obj 
/usr/bin/x86_64-w64-mingw32-g++  -DAvsCore_EXPORTS -DBUILDING_AVSCORE -I../../avs_core/include -Iavs_core -m32 -std=c++17 -MD -MT avs_core/CMakeFiles/AvsCore.dir/convert/convert_planar.cpp.obj -MF avs_core/CMakeFiles/AvsCore.dir/convert/convert_planar.cpp.obj.d -o avs_core/CMakeFiles/AvsCore.dir/convert/convert_planar.cpp.obj -c ../../avs_core/convert/convert_planar.cpp
In file included from ../../avs_core/convert/convert_planar.cpp:47:
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/smmintrin.h: In function 'void convert_planarrgb_to_yuv_uint16_sse41(BYTE* (&)[3], int (&)[3], const BYTE* (&)[3], const int (&)[3], int, int, const ConversionMatrix&) [with int bits_per_pixel = 16]':
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/smmintrin.h:558:1: error: inlining failed in call to always_inline '__m128i _mm_packus_epi32(__m128i, __m128i)': target specific option mismatch
 _mm_packus_epi32 (__m128i __X, __m128i __Y)
 ^~~~~~~~~~~~~~~~
../../avs_core/convert/convert_planar.cpp:1209:28: note: called from here
       vi = _mm_packus_epi32(vi, zero);
            ~~~~~~~~~~~~~~~~^~~~~~~~~~
In file included from ../../avs_core/convert/convert_planar.cpp:47:
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/smmintrin.h:558:1: error: inlining failed in call to always_inline '__m128i _mm_packus_epi32(__m128i, __m128i)': target specific option mismatch
 _mm_packus_epi32 (__m128i __X, __m128i __Y)
 ^~~~~~~~~~~~~~~~
../../avs_core/convert/convert_planar.cpp:1194:28: note: called from here
       ui = _mm_packus_epi32(ui, zero);
            ~~~~~~~~~~~~~~~~^~~~~~~~~~
In file included from ../../avs_core/convert/convert_planar.cpp:47:
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/smmintrin.h:558:1: error: inlining failed in call to always_inline '__m128i _mm_packus_epi32(__m128i, __m128i)': target specific option mismatch
 _mm_packus_epi32 (__m128i __X, __m128i __Y)
 ^~~~~~~~~~~~~~~~
../../avs_core/convert/convert_planar.cpp:1179:28: note: called from here
       yi = _mm_packus_epi32(yi, zero);
            ~~~~~~~~~~~~~~~~^~~~~~~~~~
In file included from ../../avs_core/convert/convert_planar.cpp:47:
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/smmintrin.h:558:1: error: inlining failed in call to always_inline '__m128i _mm_packus_epi32(__m128i, __m128i)': target specific option mismatch
 _mm_packus_epi32 (__m128i __X, __m128i __Y)
 ^~~~~~~~~~~~~~~~
../../avs_core/convert/convert_planar.cpp:1179:28: note: called from here
       yi = _mm_packus_epi32(yi, zero);
            ~~~~~~~~~~~~~~~~^~~~~~~~~~
In file included from ../../avs_core/convert/convert_planar.cpp:47:
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/smmintrin.h:558:1: error: inlining failed in call to always_inline '__m128i _mm_packus_epi32(__m128i, __m128i)': target specific option mismatch
 _mm_packus_epi32 (__m128i __X, __m128i __Y)
 ^~~~~~~~~~~~~~~~
../../avs_core/convert/convert_planar.cpp:1194:28: note: called from here
       ui = _mm_packus_epi32(ui, zero);
            ~~~~~~~~~~~~~~~~^~~~~~~~~~
In file included from ../../avs_core/convert/convert_planar.cpp:47:
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/smmintrin.h:558:1: error: inlining failed in call to always_inline '__m128i _mm_packus_epi32(__m128i, __m128i)': target specific option mismatch
 _mm_packus_epi32 (__m128i __X, __m128i __Y)
 ^~~~~~~~~~~~~~~~
../../avs_core/convert/convert_planar.cpp:1209:28: note: called from here
       vi = _mm_packus_epi32(vi, zero);
            ~~~~~~~~~~~~~~~~^~~~~~~~~~
[8/86] Building CXX object avs_core/CM...es/AvsCore.dir/convert/convert.cpp.obj
FAILED: avs_core/CMakeFiles/AvsCore.dir/convert/convert.cpp.obj 
/usr/bin/x86_64-w64-mingw32-g++  -DAvsCore_EXPORTS -DBUILDING_AVSCORE -I../../avs_core/include -Iavs_core -m32 -std=c++17 -MD -MT avs_core/CMakeFiles/AvsCore.dir/convert/convert.cpp.obj -MF avs_core/CMakeFiles/AvsCore.dir/convert/convert.cpp.obj.d -o avs_core/CMakeFiles/AvsCore.dir/convert/convert.cpp.obj -c ../../avs_core/convert/convert.cpp
In file included from /usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/immintrin.h:37,
                 from ../../avs_core/convert/convert.cpp:45:
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/smmintrin.h: In function 'void convert_32_to_uintN_sse41(const BYTE*, BYTE*, int, int, int, int) [with pixel_t = short unsigned int; unsigned char targetbits = 10; bool chroma = false; bool fulls = true; bool fulld = true]':
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/smmintrin.h:288:1: error: inlining failed in call to always_inline '__m128i _mm_min_epu16(__m128i, __m128i)': target specific option mismatch
 _mm_min_epu16 (__m128i __X, __m128i __Y)
 ^~~~~~~~~~~~~
../../avs_core/convert/convert.cpp:1654:33: note: called from here
           result = _mm_min_epu16(result, max_pixel_value_128); // sse41, extra clamp for 10, 12, 14 bits
                    ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/immintrin.h:37,
                 from ../../avs_core/convert/convert.cpp:45:
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/smmintrin.h:558:1: error: inlining failed in call to always_inline '__m128i _mm_packus_epi32(__m128i, __m128i)': target specific option mismatch
 _mm_packus_epi32 (__m128i __X, __m128i __Y)
 ^~~~~~~~~~~~~~~~
../../avs_core/convert/convert.cpp:1652:34: note: called from here
         result = _mm_packus_epi32(result_0, result_1); // sse41
                  ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/immintrin.h:37,
                 from ../../avs_core/convert/convert.cpp:45:
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/smmintrin.h:288:1: error: inlining failed in call to always_inline '__m128i _mm_min_epu16(__m128i, __m128i)': target specific option mismatch
 _mm_min_epu16 (__m128i __X, __m128i __Y)
 ^~~~~~~~~~~~~
../../avs_core/convert/convert.cpp:1654:33: note: called from here
           result = _mm_min_epu16(result, max_pixel_value_128); // sse41, extra clamp for 10, 12, 14 bits
                    ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/immintrin.h:37,
                 from ../../avs_core/convert/convert.cpp:45:
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/smmintrin.h:558:1: error: inlining failed in call to always_inline '__m128i _mm_packus_epi32(__m128i, __m128i)': target specific option mismatch
 _mm_packus_epi32 (__m128i __X, __m128i __Y)
 ^~~~~~~~~~~~~~~~
../../avs_core/convert/convert.cpp:1652:34: note: called from here
         result = _mm_packus_epi32(result_0, result_1); // sse41
                  ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
ninja: build stopped: subcommand failed.
[i686:$] 

After changing the Clang ifdefs to Clang or GCC ifdefs:

[i686:$] ninja
[3/86] Building CXX object avs_core/CM...vsCore.dir/convert/convert_rgb.cpp.obj
FAILED: avs_core/CMakeFiles/AvsCore.dir/convert/convert_rgb.cpp.obj 
/usr/bin/x86_64-w64-mingw32-g++  -DAvsCore_EXPORTS -DBUILDING_AVSCORE -I../../avs_core/include -Iavs_core -m32 -std=c++17 -MD -MT avs_core/CMakeFiles/AvsCore.dir/convert/convert_rgb.cpp.obj -MF avs_core/CMakeFiles/AvsCore.dir/convert/convert_rgb.cpp.obj.d -o avs_core/CMakeFiles/AvsCore.dir/convert/convert_rgb.cpp.obj -c ../../avs_core/convert/convert_rgb.cpp
../../avs_core/convert/convert_rgb.cpp:53:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("ssse3")))
 ^~~~~~~~~~~~~
../../avs_core/convert/convert_rgb.cpp:102:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("ssse3")))
 ^~~~~~~~~~~~~
../../avs_core/convert/convert_rgb.cpp:249:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("ssse3")))
 ^~~~~~~~~~~~~
../../avs_core/convert/convert_rgb.cpp:292:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("ssse3")))
 ^~~~~~~~~~~~~
../../avs_core/convert/convert_rgb.cpp:452:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("ssse3")))
 ^~~~~~~~~~~~~
../../avs_core/convert/convert_rgb.cpp:550:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("ssse3")))
 ^~~~~~~~~~~~~
[4/86] Building CXX object avs_core/CM...ore.dir/convert/convert_planar.cpp.obj
FAILED: avs_core/CMakeFiles/AvsCore.dir/convert/convert_planar.cpp.obj 
/usr/bin/x86_64-w64-mingw32-g++  -DAvsCore_EXPORTS -DBUILDING_AVSCORE -I../../avs_core/include -Iavs_core -m32 -std=c++17 -MD -MT avs_core/CMakeFiles/AvsCore.dir/convert/convert_planar.cpp.obj -MF avs_core/CMakeFiles/AvsCore.dir/convert/convert_planar.cpp.obj.d -o avs_core/CMakeFiles/AvsCore.dir/convert/convert_planar.cpp.obj -c ../../avs_core/convert/convert_planar.cpp
../../avs_core/convert/convert_planar.cpp:1137:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("sse4.1")))
 ^~~~~~~~~~~~~
../../avs_core/convert/convert_planar.cpp:1879:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("sse4.1")))
 ^~~~~~~~~~~~~
../../avs_core/convert/convert_planar.cpp:2062:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("ssse3")))
 ^~~~~~~~~~~~~
[8/86] Building CXX object avs_core/CM...es/AvsCore.dir/convert/convert.cpp.obj
FAILED: avs_core/CMakeFiles/AvsCore.dir/convert/convert.cpp.obj 
/usr/bin/x86_64-w64-mingw32-g++  -DAvsCore_EXPORTS -DBUILDING_AVSCORE -I../../avs_core/include -Iavs_core -m32 -std=c++17 -MD -MT avs_core/CMakeFiles/AvsCore.dir/convert/convert.cpp.obj -MF avs_core/CMakeFiles/AvsCore.dir/convert/convert.cpp.obj.d -o avs_core/CMakeFiles/AvsCore.dir/convert/convert.cpp.obj -c ../../avs_core/convert/convert.cpp
../../avs_core/convert/convert.cpp:1581:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("sse4.1")))
 ^~~~~~~~~~~~~
../../avs_core/convert/convert.cpp:1943:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("sse4.1")))
 ^~~~~~~~~~~~~
ninja: build stopped: subcommand failed.
[i686:$] 

After moving the target declarations above the definitions for only those in convert[_rgb|_planar].cpp:

[i686:$] ninja
[6/82] Building CXX object avs_core/CM...les/AvsCore.dir/core/AviHelper.cpp.obj
FAILED: avs_core/CMakeFiles/AvsCore.dir/core/AviHelper.cpp.obj 
/usr/bin/x86_64-w64-mingw32-g++  -DAvsCore_EXPORTS -DBUILDING_AVSCORE -I../../avs_core/include -Iavs_core -m32 -std=c++17 -MD -MT avs_core/CMakeFiles/AvsCore.dir/core/AviHelper.cpp.obj -MF avs_core/CMakeFiles/AvsCore.dir/core/AviHelper.cpp.obj.d -o avs_core/CMakeFiles/AvsCore.dir/core/AviHelper.cpp.obj -c ../../avs_core/core/AviHelper.cpp
../../avs_core/core/AviHelper.cpp:246:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("ssse3")))
 ^~~~~~~~~~~~~
../../avs_core/core/AviHelper.cpp:297:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("ssse3")))
 ^~~~~~~~~~~~~
../../avs_core/core/AviHelper.cpp:519:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("sse4.1")))
 ^~~~~~~~~~~~~
[11/82] Building CXX object avs_core/C...es/AvsCore.dir/convert/convert.cpp.obj
ninja: build stopped: subcommand failed.
[i686:$] 

After moving the target declarations above the definitions for only those in AviHelper.cpp: The field.cpp static keyword issue I mentioned before:

[27/64] Building CXX object avs_core/C...iles/AvsCore.dir/filters/field.cpp.obj
FAILED: avs_core/CMakeFiles/AvsCore.dir/filters/field.cpp.obj 
/usr/bin/x86_64-w64-mingw32-g++  -DAvsCore_EXPORTS -DBUILDING_AVSCORE -I../../avs_core/include -Iavs_core -m32 -std=c++17 -MD -MT avs_core/CMakeFiles/AvsCore.dir/filters/field.cpp.obj -MF avs_core/CMakeFiles/AvsCore.dir/filters/field.cpp.obj.d -o avs_core/CMakeFiles/AvsCore.dir/filters/field.cpp.obj -c ../../avs_core/filters/field.cpp
../../avs_core/filters/field.cpp:955:25: error: 'AVSValue Create_DoubleWeave(AVSValue, void*, IScriptEnvironment*)' was declared 'extern' and later 'static' [-fpermissive]
 static AVSValue __cdecl Create_DoubleWeave(AVSValue args, void*, IScriptEnvironment* env)
                         ^~~~~~~~~~~~~~~~~~
In file included from ../../avs_core/filters/field.cpp:36:
../../avs_core/filters/field.h:424:18: note: previous declaration of 'AVSValue Create_DoubleWeave(AVSValue, void*, IScriptEnvironment*)'
 AVSValue __cdecl Create_DoubleWeave(AVSValue args, void*, IScriptEnvironment* env);
                  ^~~~~~~~~~~~~~~~~~
../../avs_core/filters/field.cpp:966:25: error: 'AVSValue Create_Weave(AVSValue, void*, IScriptEnvironment*)' was declared 'extern' and later 'static' [-fpermissive]
 static AVSValue __cdecl Create_Weave(AVSValue args, void*, IScriptEnvironment* env)
                         ^~~~~~~~~~~~
In file included from ../../avs_core/filters/field.cpp:36:
../../avs_core/filters/field.h:425:18: note: previous declaration of 'AVSValue Create_Weave(AVSValue, void*, IScriptEnvironment*)'
 AVSValue __cdecl Create_Weave(AVSValue args, void*, IScriptEnvironment* env);
                  ^~~~~~~~~~~~
../../avs_core/filters/field.cpp:975:25: error: 'AVSValue Create_Pulldown(AVSValue, void*, IScriptEnvironment*)' was declared 'extern' and later 'static' [-fpermissive]
 static AVSValue __cdecl Create_Pulldown(AVSValue args, void*, IScriptEnvironment* env)
                         ^~~~~~~~~~~~~~~
In file included from ../../avs_core/filters/field.cpp:36:
../../avs_core/filters/field.h:426:18: note: previous declaration of 'AVSValue Create_Pulldown(AVSValue, void*, IScriptEnvironment*)'
 AVSValue __cdecl Create_Pulldown(AVSValue args, void*, IScriptEnvironment* env);
                  ^~~~~~~~~~~~~~~
../../avs_core/filters/field.cpp:985:25: error: 'AVSValue Create_SwapFields(AVSValue, void*, IScriptEnvironment*)' was declared 'extern' and later 'static' [-fpermissive]
 static AVSValue __cdecl Create_SwapFields(AVSValue args, void*, IScriptEnvironment* env)
                         ^~~~~~~~~~~~~~~~~
In file included from ../../avs_core/filters/field.cpp:36:
../../avs_core/filters/field.h:427:18: note: previous declaration of 'AVSValue Create_SwapFields(AVSValue, void*, IScriptEnvironment*)'
 AVSValue __cdecl Create_SwapFields(AVSValue args, void*, IScriptEnvironment* env);
                  ^~~~~~~~~~~~~~~~~
../../avs_core/filters/field.cpp:992:25: error: 'AVSValue Create_Bob(AVSValue, void*, IScriptEnvironment*)' was declared 'extern' and later 'static' [-fpermissive]
 static AVSValue __cdecl Create_Bob(AVSValue args, void*, IScriptEnvironment* env)
                         ^~~~~~~~~~
In file included from ../../avs_core/filters/field.cpp:36:
../../avs_core/filters/field.h:428:18: note: previous declaration of 'AVSValue Create_Bob(AVSValue, void*, IScriptEnvironment*)'
 AVSValue __cdecl Create_Bob(AVSValue args, void*, IScriptEnvironment* env);
                  ^~~~~~~~~~

[29/64] Building CXX object avs_core/C...iles/AvsCore.dir/filters/focus.cpp.obj
FAILED: avs_core/CMakeFiles/AvsCore.dir/filters/focus.cpp.obj 
/usr/bin/x86_64-w64-mingw32-g++  -DAvsCore_EXPORTS -DBUILDING_AVSCORE -I../../avs_core/include -Iavs_core -m32 -std=c++17 -MD -MT avs_core/CMakeFiles/AvsCore.dir/filters/focus.cpp.obj -MF avs_core/CMakeFiles/AvsCore.dir/filters/focus.cpp.obj.d -o avs_core/CMakeFiles/AvsCore.dir/filters/focus.cpp.obj -c ../../avs_core/filters/focus.cpp
../../avs_core/filters/focus.cpp:195:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("sse4.1")))
 ^~~~~~~~~~~~~
../../avs_core/filters/focus.cpp:244:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("sse4.1")))
 ^~~~~~~~~~~~~
../../avs_core/filters/focus.cpp:314:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("sse4.1")))
 ^~~~~~~~~~~~~
../../avs_core/filters/focus.cpp:758:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("sse4.1")))
 ^~~~~~~~~~~~~
../../avs_core/filters/focus.cpp:1346:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("sse4.1")))
 ^~~~~~~~~~~~~
../../avs_core/filters/focus.cpp:1883:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("sse4.1")))
 ^~~~~~~~~~~~~
../../avs_core/filters/focus.cpp:1954:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("ssse3")))
 ^~~~~~~~~~~~~
../../avs_core/filters/focus.cpp:2071:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("sse4.1")))
 ^~~~~~~~~~~~~

After moving the target declarations above the definitions for only those in focus.cpp and removing the static keywords in field.cpp:

[i686:$] ninja
[2/31] Building CXX object avs_core/CM.../AvsCore.dir/filters/greyscale.cpp.obj
FAILED: avs_core/CMakeFiles/AvsCore.dir/filters/greyscale.cpp.obj 
/usr/bin/x86_64-w64-mingw32-g++  -DAvsCore_EXPORTS -DBUILDING_AVSCORE -I../../avs_core/include -Iavs_core -m32 -std=c++17 -MD -MT avs_core/CMakeFiles/AvsCore.dir/filters/greyscale.cpp.obj -MF avs_core/CMakeFiles/AvsCore.dir/filters/greyscale.cpp.obj.d -o avs_core/CMakeFiles/AvsCore.dir/filters/greyscale.cpp.obj -c ../../avs_core/filters/greyscale.cpp
../../avs_core/filters/greyscale.cpp:136:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("sse4.1")))
 ^~~~~~~~~~~~~
[3/31] Building CXX object avs_core/CM...es/AvsCore.dir/filters/limiter.cpp.obj
FAILED: avs_core/CMakeFiles/AvsCore.dir/filters/limiter.cpp.obj 
/usr/bin/x86_64-w64-mingw32-g++  -DAvsCore_EXPORTS -DBUILDING_AVSCORE -I../../avs_core/include -Iavs_core -m32 -std=c++17 -MD -MT avs_core/CMakeFiles/AvsCore.dir/filters/limiter.cpp.obj -MF avs_core/CMakeFiles/AvsCore.dir/filters/limiter.cpp.obj.d -o avs_core/CMakeFiles/AvsCore.dir/filters/limiter.cpp.obj -c ../../avs_core/filters/limiter.cpp
../../avs_core/filters/limiter.cpp:77:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("sse4.1")))
 ^~~~~~~~~~~~~
[7/31] Building CXX object avs_core/CM...les/AvsCore.dir/filters/levels.cpp.obj
ninja: build stopped: subcommand failed.
[i686:$] 

After moving the target declarations above the definitions for only those in greyscale.cpp and limiter.cpp:

[i686:$] ninja
[11/27] Building CXX object avs_core/C...dir/filters/overlay/444convert.cpp.obj
FAILED: avs_core/CMakeFiles/AvsCore.dir/filters/overlay/444convert.cpp.obj 
/usr/bin/x86_64-w64-mingw32-g++  -DAvsCore_EXPORTS -DBUILDING_AVSCORE -I../../avs_core/include -Iavs_core -m32 -std=c++17 -MD -MT avs_core/CMakeFiles/AvsCore.dir/filters/overlay/444convert.cpp.obj -MF avs_core/CMakeFiles/AvsCore.dir/filters/overlay/444convert.cpp.obj.d -o avs_core/CMakeFiles/AvsCore.dir/filters/overlay/444convert.cpp.obj -c ../../avs_core/filters/overlay/444convert.cpp
../../avs_core/filters/overlay/444convert.cpp:421:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("sse4.1")))
 ^~~~~~~~~~~~~
../../avs_core/filters/overlay/444convert.cpp:507:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("sse4.1")))
 ^~~~~~~~~~~~~
../../avs_core/filters/overlay/444convert.cpp:707:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("sse4.1")))
 ^~~~~~~~~~~~~
../../avs_core/filters/overlay/444convert.cpp:777:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("sse4.1")))
 ^~~~~~~~~~~~~
[16/27] Building CXX object avs_core/C...r/filters/overlay/blend_common.cpp.obj
FAILED: avs_core/CMakeFiles/AvsCore.dir/filters/overlay/blend_common.cpp.obj 
/usr/bin/x86_64-w64-mingw32-g++  -DAvsCore_EXPORTS -DBUILDING_AVSCORE -I../../avs_core/include -Iavs_core -m32 -std=c++17 -MD -MT avs_core/CMakeFiles/AvsCore.dir/filters/overlay/blend_common.cpp.obj -MF avs_core/CMakeFiles/AvsCore.dir/filters/overlay/blend_common.cpp.obj.d -o avs_core/CMakeFiles/AvsCore.dir/filters/overlay/blend_common.cpp.obj -c ../../avs_core/filters/overlay/blend_common.cpp
../../avs_core/filters/overlay/blend_common.cpp:105:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("sse4.1")))
 ^~~~~~~~~~~~~
../../avs_core/filters/overlay/blend_common.cpp:149:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("sse4.1")))
 ^~~~~~~~~~~~~
../../avs_core/filters/overlay/blend_common.cpp:388:3: error: attributes are not allowed on a function-definition
   __attribute__((__target__("sse4.1")))
   ^~~~~~~~~~~~~
../../avs_core/filters/overlay/blend_common.cpp:719:3: error: attributes are not allowed on a function-definition
   __attribute__((__target__("sse4.1")))
   ^~~~~~~~~~~~~
../../avs_core/filters/overlay/blend_common.cpp:1061:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("sse4.1")))
 ^~~~~~~~~~~~~
../../avs_core/filters/overlay/blend_common.cpp:1381:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("sse4.1")))
 ^~~~~~~~~~~~~
ninja: build stopped: subcommand failed.
[i686:$] 

After moving the target declarations above the definitions for only those in 444convert.cpp and blend_common.cpp:

[i686:$] ninja
[2/14] Building CXX object avs_core/CM...r/filters/overlay/blend_common.cpp.obj
FAILED: avs_core/CMakeFiles/AvsCore.dir/filters/overlay/blend_common.cpp.obj 
/usr/bin/x86_64-w64-mingw32-g++  -DAvsCore_EXPORTS -DBUILDING_AVSCORE -I../../avs_core/include -Iavs_core -m32 -std=c++17 -MD -MT avs_core/CMakeFiles/AvsCore.dir/filters/overlay/blend_common.cpp.obj -MF avs_core/CMakeFiles/AvsCore.dir/filters/overlay/blend_common.cpp.obj.d -o avs_core/CMakeFiles/AvsCore.dir/filters/overlay/blend_common.cpp.obj -c ../../avs_core/filters/overlay/blend_common.cpp
In file included from ../../avs_core/filters/overlay/blend_common.cpp:44:
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/smmintrin.h: In function 'void overlay_blend_sse41_plane_masked(BYTE*, const BYTE*, const BYTE*, int, int, int, int, int) [with pixel_t = unsigned char; int bits_per_pixel = 8]':
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/smmintrin.h:179:1: error: inlining failed in call to always_inline '__m128i _mm_blendv_epi8(__m128i, __m128i, __m128i)': target specific option mismatch
 _mm_blendv_epi8 (__m128i __X, __m128i __Y, __m128i __M)
 ^~~~~~~~~~~~~~~
../../avs_core/filters/overlay/blend_common.cpp:436:33: note: called from here
         result = _mm_blendv_epi8(result, dst, mask_00); // ensure that zero mask value returns dst
                  ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from ../../avs_core/filters/overlay/blend_common.cpp:44:
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/smmintrin.h:179:1: error: inlining failed in call to always_inline '__m128i _mm_blendv_epi8(__m128i, __m128i, __m128i)': target specific option mismatch
 _mm_blendv_epi8 (__m128i __X, __m128i __Y, __m128i __M)
 ^~~~~~~~~~~~~~~
../../avs_core/filters/overlay/blend_common.cpp:436:33: note: called from here
         result = _mm_blendv_epi8(result, dst, mask_00); // ensure that zero mask value returns dst
                  ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from ../../avs_core/filters/overlay/blend_common.cpp:44:
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/smmintrin.h:179:1: error: inlining failed in call to always_inline '__m128i _mm_blendv_epi8(__m128i, __m128i, __m128i)': target specific option mismatch
 _mm_blendv_epi8 (__m128i __X, __m128i __Y, __m128i __M)
 ^~~~~~~~~~~~~~~
../../avs_core/filters/overlay/blend_common.cpp:439:33: note: called from here
         result = _mm_blendv_epi8(result, src, mask_FF); // ensure that max mask value returns src
                  ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from ../../avs_core/filters/overlay/blend_common.cpp:44:
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/smmintrin.h:179:1: error: inlining failed in call to always_inline '__m128i _mm_blendv_epi8(__m128i, __m128i, __m128i)': target specific option mismatch
 _mm_blendv_epi8 (__m128i __X, __m128i __Y, __m128i __M)
 ^~~~~~~~~~~~~~~
../../avs_core/filters/overlay/blend_common.cpp:439:33: note: called from here
         result = _mm_blendv_epi8(result, src, mask_FF); // ensure that max mask value returns src
                  ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
[3/14] Building CXX object avs_core/CM.../AvsCore.dir/filters/planeswap.cpp.obj
FAILED: avs_core/CMakeFiles/AvsCore.dir/filters/planeswap.cpp.obj 
/usr/bin/x86_64-w64-mingw32-g++  -DAvsCore_EXPORTS -DBUILDING_AVSCORE -I../../avs_core/include -Iavs_core -m32 -std=c++17 -MD -MT avs_core/CMakeFiles/AvsCore.dir/filters/planeswap.cpp.obj -MF avs_core/CMakeFiles/AvsCore.dir/filters/planeswap.cpp.obj.d -o avs_core/CMakeFiles/AvsCore.dir/filters/planeswap.cpp.obj -c ../../avs_core/filters/planeswap.cpp
../../avs_core/filters/planeswap.cpp:106:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("ssse3")))
 ^~~~~~~~~~~~~
[5/14] Building CXX object avs_core/CM...s/AvsCore.dir/filters/resample.cpp.obj
FAILED: avs_core/CMakeFiles/AvsCore.dir/filters/resample.cpp.obj 
/usr/bin/x86_64-w64-mingw32-g++  -DAvsCore_EXPORTS -DBUILDING_AVSCORE -I../../avs_core/include -Iavs_core -m32 -std=c++17 -MD -MT avs_core/CMakeFiles/AvsCore.dir/filters/resample.cpp.obj -MF avs_core/CMakeFiles/AvsCore.dir/filters/resample.cpp.obj.d -o avs_core/CMakeFiles/AvsCore.dir/filters/resample.cpp.obj -c ../../avs_core/filters/resample.cpp
../../avs_core/filters/resample.cpp: In function 'void resize_v_sse41_planar(BYTE*, const BYTE*, int, int, ResamplingProgram*, int, int, int, const int*, const void*)':
../../avs_core/filters/resample.cpp:413:47: error: invalid conversion from 'const __m128i*' {aka 'const __vector(2) long long int*'} to '__m128i*' {aka '__vector(2) long long int*'} [-fpermissive]
         __m128i src_p = _mm_stream_load_si128(reinterpret_cast<const __m128i*>(src2_ptr));
                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../../avs_core/filters/resample.cpp:50:
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/smmintrin.h:582:33: note:   initializing argument 1 of '__m128i _mm_stream_load_si128(__m128i*)'
 _mm_stream_load_si128 (__m128i *__X)
                        ~~~~~~~~~^~~
../../avs_core/filters/resample.cpp: At global scope:
../../avs_core/filters/resample.cpp:461:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("ssse3")))
 ^~~~~~~~~~~~~
../../avs_core/filters/resample.cpp:709:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("ssse3")))
 ^~~~~~~~~~~~~
../../avs_core/filters/resample.cpp:903:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("ssse3")))
 ^~~~~~~~~~~~~
../../avs_core/filters/resample.cpp:979:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("sse4.1")))
 ^~~~~~~~~~~~~
../../avs_core/filters/resample.cpp:1055:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("ssse3")))
 ^~~~~~~~~~~~~
../../avs_core/filters/resample.cpp:1071:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("sse4.1")))
 ^~~~~~~~~~~~~
../../avs_core/filters/resample.cpp:1219:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("sse4.1")))
 ^~~~~~~~~~~~~
../../avs_core/filters/resample.cpp:1420:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("sse4.1")))
 ^~~~~~~~~~~~~
../../avs_core/filters/resample.cpp:1643:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("ssse3")))
 ^~~~~~~~~~~~~
../../avs_core/filters/resample.cpp:1727:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("ssse3")))
 ^~~~~~~~~~~~~
[7/14] Building CXX object avs_core/CM...Core.dir/filters/resample_avx2.cpp.obj
ninja: build stopped: subcommand failed.
[2]+  Done                    leafpad ../../avs_core/filters/overlay/blend_common.cpp
[i686:$] 

After moving the target declarations above the definitions for only those in planeswap.cpp and resample.cpp:

[i686:$] ninja
[2/11] Building CXX object avs_core/CM...r/filters/overlay/blend_common.cpp.obj
FAILED: avs_core/CMakeFiles/AvsCore.dir/filters/overlay/blend_common.cpp.obj 
/usr/bin/x86_64-w64-mingw32-g++  -DAvsCore_EXPORTS -DBUILDING_AVSCORE -I../../avs_core/include -Iavs_core -m32 -std=c++17 -MD -MT avs_core/CMakeFiles/AvsCore.dir/filters/overlay/blend_common.cpp.obj -MF avs_core/CMakeFiles/AvsCore.dir/filters/overlay/blend_common.cpp.obj.d -o avs_core/CMakeFiles/AvsCore.dir/filters/overlay/blend_common.cpp.obj -c ../../avs_core/filters/overlay/blend_common.cpp
In file included from ../../avs_core/filters/overlay/blend_common.cpp:44:
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/smmintrin.h: In function 'void overlay_blend_sse41_plane_masked(BYTE*, const BYTE*, const BYTE*, int, int, int, int, int) [with pixel_t = unsigned char; int bits_per_pixel = 8]':
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/smmintrin.h:179:1: error: inlining failed in call to always_inline '__m128i _mm_blendv_epi8(__m128i, __m128i, __m128i)': target specific option mismatch
 _mm_blendv_epi8 (__m128i __X, __m128i __Y, __m128i __M)
 ^~~~~~~~~~~~~~~
../../avs_core/filters/overlay/blend_common.cpp:436:33: note: called from here
         result = _mm_blendv_epi8(result, dst, mask_00); // ensure that zero mask value returns dst
                  ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from ../../avs_core/filters/overlay/blend_common.cpp:44:
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/smmintrin.h:179:1: error: inlining failed in call to always_inline '__m128i _mm_blendv_epi8(__m128i, __m128i, __m128i)': target specific option mismatch
 _mm_blendv_epi8 (__m128i __X, __m128i __Y, __m128i __M)
 ^~~~~~~~~~~~~~~
../../avs_core/filters/overlay/blend_common.cpp:436:33: note: called from here
         result = _mm_blendv_epi8(result, dst, mask_00); // ensure that zero mask value returns dst
                  ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from ../../avs_core/filters/overlay/blend_common.cpp:44:
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/smmintrin.h:179:1: error: inlining failed in call to always_inline '__m128i _mm_blendv_epi8(__m128i, __m128i, __m128i)': target specific option mismatch
 _mm_blendv_epi8 (__m128i __X, __m128i __Y, __m128i __M)
 ^~~~~~~~~~~~~~~
../../avs_core/filters/overlay/blend_common.cpp:439:33: note: called from here
         result = _mm_blendv_epi8(result, src, mask_FF); // ensure that max mask value returns src
                  ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from ../../avs_core/filters/overlay/blend_common.cpp:44:
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/smmintrin.h:179:1: error: inlining failed in call to always_inline '__m128i _mm_blendv_epi8(__m128i, __m128i, __m128i)': target specific option mismatch
 _mm_blendv_epi8 (__m128i __X, __m128i __Y, __m128i __M)
 ^~~~~~~~~~~~~~~
../../avs_core/filters/overlay/blend_common.cpp:439:33: note: called from here
         result = _mm_blendv_epi8(result, src, mask_FF); // ensure that max mask value returns src
                  ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
[6/11] Building CXX object avs_core/CM...s/AvsCore.dir/filters/resample.cpp.obj
FAILED: avs_core/CMakeFiles/AvsCore.dir/filters/resample.cpp.obj 
/usr/bin/x86_64-w64-mingw32-g++  -DAvsCore_EXPORTS -DBUILDING_AVSCORE -I../../avs_core/include -Iavs_core -m32 -std=c++17 -MD -MT avs_core/CMakeFiles/AvsCore.dir/filters/resample.cpp.obj -MF avs_core/CMakeFiles/AvsCore.dir/filters/resample.cpp.obj.d -o avs_core/CMakeFiles/AvsCore.dir/filters/resample.cpp.obj -c ../../avs_core/filters/resample.cpp
../../avs_core/filters/resample.cpp: In function 'void resize_v_sse41_planar(BYTE*, const BYTE*, int, int, ResamplingProgram*, int, int, int, const int*, const void*)':
../../avs_core/filters/resample.cpp:413:47: error: invalid conversion from 'const __m128i*' {aka 'const __vector(2) long long int*'} to '__m128i*' {aka '__vector(2) long long int*'} [-fpermissive]
         __m128i src_p = _mm_stream_load_si128(reinterpret_cast<const __m128i*>(src2_ptr));
                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../../avs_core/filters/resample.cpp:50:
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/smmintrin.h:582:33: note:   initializing argument 1 of '__m128i _mm_stream_load_si128(__m128i*)'
 _mm_stream_load_si128 (__m128i *__X)
                        ~~~~~~~~~^~~
[7/11] Building CXX object avs_core/CM...les/AvsCore.dir/filters/source.cpp.obj
ninja: build stopped: subcommand failed.
[2]+  Done                    leafpad ../../avs_core/filters/resample.cpp
[i686:$] 

Successive runs of ninja will continue building other files while still erroring on unfixed sources:

[i686:$] ninja
[2/7] Building CXX object avs_core/CMa...r/filters/overlay/blend_common.cpp.obj
FAILED: avs_core/CMakeFiles/AvsCore.dir/filters/overlay/blend_common.cpp.obj 
/usr/bin/x86_64-w64-mingw32-g++  -DAvsCore_EXPORTS -DBUILDING_AVSCORE -I../../avs_core/include -Iavs_core -m32 -std=c++17 -MD -MT avs_core/CMakeFiles/AvsCore.dir/filters/overlay/blend_common.cpp.obj -MF avs_core/CMakeFiles/AvsCore.dir/filters/overlay/blend_common.cpp.obj.d -o avs_core/CMakeFiles/AvsCore.dir/filters/overlay/blend_common.cpp.obj -c ../../avs_core/filters/overlay/blend_common.cpp
In file included from ../../avs_core/filters/overlay/blend_common.cpp:44:
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/smmintrin.h: In function 'void overlay_blend_sse41_plane_masked(BYTE*, const BYTE*, const BYTE*, int, int, int, int, int) [with pixel_t = unsigned char; int bits_per_pixel = 8]':
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/smmintrin.h:179:1: error: inlining failed in call to always_inline '__m128i _mm_blendv_epi8(__m128i, __m128i, __m128i)': target specific option mismatch
 _mm_blendv_epi8 (__m128i __X, __m128i __Y, __m128i __M)
 ^~~~~~~~~~~~~~~
../../avs_core/filters/overlay/blend_common.cpp:436:33: note: called from here
         result = _mm_blendv_epi8(result, dst, mask_00); // ensure that zero mask value returns dst
                  ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from ../../avs_core/filters/overlay/blend_common.cpp:44:
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/smmintrin.h:179:1: error: inlining failed in call to always_inline '__m128i _mm_blendv_epi8(__m128i, __m128i, __m128i)': target specific option mismatch
 _mm_blendv_epi8 (__m128i __X, __m128i __Y, __m128i __M)
 ^~~~~~~~~~~~~~~
../../avs_core/filters/overlay/blend_common.cpp:436:33: note: called from here
         result = _mm_blendv_epi8(result, dst, mask_00); // ensure that zero mask value returns dst
                  ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from ../../avs_core/filters/overlay/blend_common.cpp:44:
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/smmintrin.h:179:1: error: inlining failed in call to always_inline '__m128i _mm_blendv_epi8(__m128i, __m128i, __m128i)': target specific option mismatch
 _mm_blendv_epi8 (__m128i __X, __m128i __Y, __m128i __M)
 ^~~~~~~~~~~~~~~
../../avs_core/filters/overlay/blend_common.cpp:439:33: note: called from here
         result = _mm_blendv_epi8(result, src, mask_FF); // ensure that max mask value returns src
                  ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from ../../avs_core/filters/overlay/blend_common.cpp:44:
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/smmintrin.h:179:1: error: inlining failed in call to always_inline '__m128i _mm_blendv_epi8(__m128i, __m128i, __m128i)': target specific option mismatch
 _mm_blendv_epi8 (__m128i __X, __m128i __Y, __m128i __M)
 ^~~~~~~~~~~~~~~
../../avs_core/filters/overlay/blend_common.cpp:439:33: note: called from here
         result = _mm_blendv_epi8(result, src, mask_FF); // ensure that max mask value returns src
                  ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
[3/7] Building CXX object avs_core/CMa...Files/AvsCore.dir/filters/turn.cpp.obj
FAILED: avs_core/CMakeFiles/AvsCore.dir/filters/turn.cpp.obj 
/usr/bin/x86_64-w64-mingw32-g++  -DAvsCore_EXPORTS -DBUILDING_AVSCORE -I../../avs_core/include -Iavs_core -m32 -std=c++17 -MD -MT avs_core/CMakeFiles/AvsCore.dir/filters/turn.cpp.obj -MF avs_core/CMakeFiles/AvsCore.dir/filters/turn.cpp.obj.d -o avs_core/CMakeFiles/AvsCore.dir/filters/turn.cpp.obj -c ../../avs_core/filters/turn.cpp
../../avs_core/filters/turn.cpp:540:1: error: attributes are not allowed on a function-definition
 __attribute__((__target__("ssse3")))
 ^~~~~~~~~~~~~
[5/7] Building CXX object avs_core/CMa...s/AvsCore.dir/filters/resample.cpp.obj
FAILED: avs_core/CMakeFiles/AvsCore.dir/filters/resample.cpp.obj 
/usr/bin/x86_64-w64-mingw32-g++  -DAvsCore_EXPORTS -DBUILDING_AVSCORE -I../../avs_core/include -Iavs_core -m32 -std=c++17 -MD -MT avs_core/CMakeFiles/AvsCore.dir/filters/resample.cpp.obj -MF avs_core/CMakeFiles/AvsCore.dir/filters/resample.cpp.obj.d -o avs_core/CMakeFiles/AvsCore.dir/filters/resample.cpp.obj -c ../../avs_core/filters/resample.cpp
../../avs_core/filters/resample.cpp: In function 'void resize_v_sse41_planar(BYTE*, const BYTE*, int, int, ResamplingProgram*, int, int, int, const int*, const void*)':
../../avs_core/filters/resample.cpp:413:47: error: invalid conversion from 'const __m128i*' {aka 'const __vector(2) long long int*'} to '__m128i*' {aka '__vector(2) long long int*'} [-fpermissive]
         __m128i src_p = _mm_stream_load_si128(reinterpret_cast<const __m128i*>(src2_ptr));
                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../../avs_core/filters/resample.cpp:50:
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/smmintrin.h:582:33: note:   initializing argument 1 of '__m128i _mm_stream_load_si128(__m128i*)'
 _mm_stream_load_si128 (__m128i *__X)
                        ~~~~~~~~~^~~
[6/7] Building CXX object avs_core/CMa...sCore.dir/filters/text-overlay.cpp.obj
ninja: build stopped: subcommand failed.
[i686:$] 

After moving the target declarations above the definitions for only those in turn.cpp:

[i686:$] ninja
[2/5] Building CXX object avs_core/CMa...r/filters/overlay/blend_common.cpp.obj
FAILED: avs_core/CMakeFiles/AvsCore.dir/filters/overlay/blend_common.cpp.obj 
/usr/bin/x86_64-w64-mingw32-g++  -DAvsCore_EXPORTS -DBUILDING_AVSCORE -I../../avs_core/include -Iavs_core -m32 -std=c++17 -MD -MT avs_core/CMakeFiles/AvsCore.dir/filters/overlay/blend_common.cpp.obj -MF avs_core/CMakeFiles/AvsCore.dir/filters/overlay/blend_common.cpp.obj.d -o avs_core/CMakeFiles/AvsCore.dir/filters/overlay/blend_common.cpp.obj -c ../../avs_core/filters/overlay/blend_common.cpp
In file included from ../../avs_core/filters/overlay/blend_common.cpp:44:
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/smmintrin.h: In function 'void overlay_blend_sse41_plane_masked(BYTE*, const BYTE*, const BYTE*, int, int, int, int, int) [with pixel_t = unsigned char; int bits_per_pixel = 8]':
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/smmintrin.h:179:1: error: inlining failed in call to always_inline '__m128i _mm_blendv_epi8(__m128i, __m128i, __m128i)': target specific option mismatch
 _mm_blendv_epi8 (__m128i __X, __m128i __Y, __m128i __M)
 ^~~~~~~~~~~~~~~
../../avs_core/filters/overlay/blend_common.cpp:436:33: note: called from here
         result = _mm_blendv_epi8(result, dst, mask_00); // ensure that zero mask value returns dst
                  ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from ../../avs_core/filters/overlay/blend_common.cpp:44:
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/smmintrin.h:179:1: error: inlining failed in call to always_inline '__m128i _mm_blendv_epi8(__m128i, __m128i, __m128i)': target specific option mismatch
 _mm_blendv_epi8 (__m128i __X, __m128i __Y, __m128i __M)
 ^~~~~~~~~~~~~~~
../../avs_core/filters/overlay/blend_common.cpp:436:33: note: called from here
         result = _mm_blendv_epi8(result, dst, mask_00); // ensure that zero mask value returns dst
                  ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from ../../avs_core/filters/overlay/blend_common.cpp:44:
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/smmintrin.h:179:1: error: inlining failed in call to always_inline '__m128i _mm_blendv_epi8(__m128i, __m128i, __m128i)': target specific option mismatch
 _mm_blendv_epi8 (__m128i __X, __m128i __Y, __m128i __M)
 ^~~~~~~~~~~~~~~
../../avs_core/filters/overlay/blend_common.cpp:439:33: note: called from here
         result = _mm_blendv_epi8(result, src, mask_FF); // ensure that max mask value returns src
                  ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from ../../avs_core/filters/overlay/blend_common.cpp:44:
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/smmintrin.h:179:1: error: inlining failed in call to always_inline '__m128i _mm_blendv_epi8(__m128i, __m128i, __m128i)': target specific option mismatch
 _mm_blendv_epi8 (__m128i __X, __m128i __Y, __m128i __M)
 ^~~~~~~~~~~~~~~
../../avs_core/filters/overlay/blend_common.cpp:439:33: note: called from here
         result = _mm_blendv_epi8(result, src, mask_FF); // ensure that max mask value returns src
                  ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
[4/5] Building CXX object avs_core/CMa...s/AvsCore.dir/filters/resample.cpp.obj
FAILED: avs_core/CMakeFiles/AvsCore.dir/filters/resample.cpp.obj 
/usr/bin/x86_64-w64-mingw32-g++  -DAvsCore_EXPORTS -DBUILDING_AVSCORE -I../../avs_core/include -Iavs_core -m32 -std=c++17 -MD -MT avs_core/CMakeFiles/AvsCore.dir/filters/resample.cpp.obj -MF avs_core/CMakeFiles/AvsCore.dir/filters/resample.cpp.obj.d -o avs_core/CMakeFiles/AvsCore.dir/filters/resample.cpp.obj -c ../../avs_core/filters/resample.cpp
../../avs_core/filters/resample.cpp: In function 'void resize_v_sse41_planar(BYTE*, const BYTE*, int, int, ResamplingProgram*, int, int, int, const int*, const void*)':
../../avs_core/filters/resample.cpp:413:47: error: invalid conversion from 'const __m128i*' {aka 'const __vector(2) long long int*'} to '__m128i*' {aka '__vector(2) long long int*'} [-fpermissive]
         __m128i src_p = _mm_stream_load_si128(reinterpret_cast<const __m128i*>(src2_ptr));
                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../../avs_core/filters/resample.cpp:50:
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/smmintrin.h:582:33: note:   initializing argument 1 of '__m128i _mm_stream_load_si128(__m128i*)'
 _mm_stream_load_si128 (__m128i *__X)
                        ~~~~~~~~~^~~
ninja: build stopped: subcommand failed.
[i686:$] 

Successive runs:

[i686:$] ninja
[2/4] Building CXX object avs_core/CMa...r/filters/overlay/blend_common.cpp.obj
FAILED: avs_core/CMakeFiles/AvsCore.dir/filters/overlay/blend_common.cpp.obj 
/usr/bin/x86_64-w64-mingw32-g++  -DAvsCore_EXPORTS -DBUILDING_AVSCORE -I../../avs_core/include -Iavs_core -m32 -std=c++17 -MD -MT avs_core/CMakeFiles/AvsCore.dir/filters/overlay/blend_common.cpp.obj -MF avs_core/CMakeFiles/AvsCore.dir/filters/overlay/blend_common.cpp.obj.d -o avs_core/CMakeFiles/AvsCore.dir/filters/overlay/blend_common.cpp.obj -c ../../avs_core/filters/overlay/blend_common.cpp
In file included from ../../avs_core/filters/overlay/blend_common.cpp:44:
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/smmintrin.h: In function 'void overlay_blend_sse41_plane_masked(BYTE*, const BYTE*, const BYTE*, int, int, int, int, int) [with pixel_t = unsigned char; int bits_per_pixel = 8]':
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/smmintrin.h:179:1: error: inlining failed in call to always_inline '__m128i _mm_blendv_epi8(__m128i, __m128i, __m128i)': target specific option mismatch
 _mm_blendv_epi8 (__m128i __X, __m128i __Y, __m128i __M)
 ^~~~~~~~~~~~~~~
../../avs_core/filters/overlay/blend_common.cpp:436:33: note: called from here
         result = _mm_blendv_epi8(result, dst, mask_00); // ensure that zero mask value returns dst
                  ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from ../../avs_core/filters/overlay/blend_common.cpp:44:
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/smmintrin.h:179:1: error: inlining failed in call to always_inline '__m128i _mm_blendv_epi8(__m128i, __m128i, __m128i)': target specific option mismatch
 _mm_blendv_epi8 (__m128i __X, __m128i __Y, __m128i __M)
 ^~~~~~~~~~~~~~~
../../avs_core/filters/overlay/blend_common.cpp:436:33: note: called from here
         result = _mm_blendv_epi8(result, dst, mask_00); // ensure that zero mask value returns dst
                  ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from ../../avs_core/filters/overlay/blend_common.cpp:44:
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/smmintrin.h:179:1: error: inlining failed in call to always_inline '__m128i _mm_blendv_epi8(__m128i, __m128i, __m128i)': target specific option mismatch
 _mm_blendv_epi8 (__m128i __X, __m128i __Y, __m128i __M)
 ^~~~~~~~~~~~~~~
../../avs_core/filters/overlay/blend_common.cpp:439:33: note: called from here
         result = _mm_blendv_epi8(result, src, mask_FF); // ensure that max mask value returns src
                  ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from ../../avs_core/filters/overlay/blend_common.cpp:44:
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/smmintrin.h:179:1: error: inlining failed in call to always_inline '__m128i _mm_blendv_epi8(__m128i, __m128i, __m128i)': target specific option mismatch
 _mm_blendv_epi8 (__m128i __X, __m128i __Y, __m128i __M)
 ^~~~~~~~~~~~~~~
../../avs_core/filters/overlay/blend_common.cpp:439:33: note: called from here
         result = _mm_blendv_epi8(result, src, mask_FF); // ensure that max mask value returns src
                  ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
[3/4] Building CXX object avs_core/CMa...s/AvsCore.dir/filters/resample.cpp.obj
FAILED: avs_core/CMakeFiles/AvsCore.dir/filters/resample.cpp.obj 
/usr/bin/x86_64-w64-mingw32-g++  -DAvsCore_EXPORTS -DBUILDING_AVSCORE -I../../avs_core/include -Iavs_core -m32 -std=c++17 -MD -MT avs_core/CMakeFiles/AvsCore.dir/filters/resample.cpp.obj -MF avs_core/CMakeFiles/AvsCore.dir/filters/resample.cpp.obj.d -o avs_core/CMakeFiles/AvsCore.dir/filters/resample.cpp.obj -c ../../avs_core/filters/resample.cpp
../../avs_core/filters/resample.cpp: In function 'void resize_v_sse41_planar(BYTE*, const BYTE*, int, int, ResamplingProgram*, int, int, int, const int*, const void*)':
../../avs_core/filters/resample.cpp:413:47: error: invalid conversion from 'const __m128i*' {aka 'const __vector(2) long long int*'} to '__m128i*' {aka '__vector(2) long long int*'} [-fpermissive]
         __m128i src_p = _mm_stream_load_si128(reinterpret_cast<const __m128i*>(src2_ptr));
                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../../avs_core/filters/resample.cpp:50:
/usr/lib/gcc/x86_64-w64-mingw32/8.3.0/include/smmintrin.h:582:33: note:   initializing argument 1 of '__m128i _mm_stream_load_si128(__m128i*)'
 _mm_stream_load_si128 (__m128i *__X)
                        ~~~~~~~~~^~~
ninja: build stopped: subcommand failed.
[i686:$] 

And that's it.

qyot27 avatar Apr 08 '19 16:04 qyot27

There was a forgotten local commit for the "blend" issue which I have finally sync'd today, maybe that is missing? I hope that is the only problem.

pinterf avatar Apr 08 '19 16:04 pinterf

All of that was with the three commits that were pushed today.

qyot27 avatar Apr 08 '19 16:04 qyot27

That last one is strange, the problem with the stream_load: In old headers: __m128i _mm_stream_load_si128(__m128i *p);

In latest smmintrin.h versions:

#if defined(_CRT_WINDOWS) || defined(BUILD_WINDOWS)
        extern __m128i _mm_stream_load_si128(__m128i*);
#else /* defined(_CRT_WINDOWS) || defined(BUILD_WINDOWS) */
        extern __m128i _mm_stream_load_si128(const __m128i*);
#endif /* defined(_CRT_WINDOWS) || defined(BUILD_WINDOWS) */

The latter is the enabled live definition.

I wonder, what's in GCC's smmintrin.h

Still don't understand why it is hectic just on the _mm_blendv_epi8 function.

pinterf avatar Apr 08 '19 19:04 pinterf

In GCC's 8.3 release (and in the master branch): https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/config/i386/smmintrin.h;h=b7257a562eae4958538733c3b092457525f94c31;hb=refs/heads/gcc-8-branch#l580

No ifdef at all, defined as

 580 /* Load double quadword using non-temporal aligned hint.  */
 581 extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
 582 _mm_stream_load_si128 (__m128i *__X)
 583 {
 584   return (__m128i) __builtin_ia32_movntdqa ((__v2di *) __X);
 585 }
 586 

qyot27 avatar Apr 08 '19 20:04 qyot27

Can I theoretically repeat your process on Windows? I'm trying gcc (8.2 - but I don't think it's that big difference) installed following the instructions from here: https://www.youtube.com/watch?v=sXW2VLrQ3Bs

Run cmake

del CMakeCache.txt
"c:\Program Files\CMake\bin\cmake.exe" -G "MinGW Makefiles" .

Got output like this

-- The C compiler identification is GNU 8.2.0
-- The CXX compiler identification is GNU 8.2.0
-- Check for working C compiler: C:/MinGW/bin/gcc.exe
-- Check for working C compiler: C:/MinGW/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/MinGW/bin/g++.exe
-- Check for working CXX compiler: C:/MinGW/bin/g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Git: C:/Program Files/Git/cmd/git.exe (found version "2.17.1.windows.2")
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Github/AviSynthPlusPf

Then mingw32-make -f makefile clean mingw32-make -f makefile

I have totally different stoppers

[  1%] Building CXX object avs_core/CMakeFiles/AvsCore.dir/core/AviHelper.cpp.obj
C:\Github\AviSynthPlusPf\avs_core\core\AviHelper.cpp:38:10: fatal error: intrin.h: No such file or directory
 #include <intrin.h>
          ^~~~~~~~~~

?! No intrin.h indeed in my gcc. O.K., commented out. Then it has problems with mutex class, std::mutex basically. Works or not: articles say pthreads support, maybe there should exist a special build with https://stackoverflow.com/questions/24009821/mingw-4-8-1-c11-thread-support

So it seems I am using a MinGW toolset which is old?

This article says that they use MSYS2 and install MinGW-w64 compilers from there, which do support the required functionality. https://stackoverflow.com/questions/27939393/getting-error-mutex-in-namespace-std-does-not-name-a-type-in-mingw-mysys-pr?noredirect=1&lq=1 At the moment it's beyond my actual knowledge, I have installed mingw-w64 but having zero overview how it should work, I have an MSYS console and was able to do nothing, perhaps I even need to compile my own gcc?

These are the errors which I could not even get past.

[  2%] Building CXX object avs_core/CMakeFiles/AvsCore.dir/core/MTGuard.cpp.obj
C:\Github\AviSynthPlusPf\avs_core\core\MTGuard.cpp: In destructor 'virtual MTGuard::~MTGuard()':
C:\Github\AviSynthPlusPf\avs_core\core\MTGuard.cpp:65:10: warning: possible problem detected in invocation of delete operator: [-Wdelete-incomplete]
   delete FilterMutex;
          ^~~~~~~~~~~
C:\Github\AviSynthPlusPf\avs_core\core\MTGuard.cpp:65:10: warning: invalid use of incomplete type 'class std::mutex'
In file included from C:\Github\AviSynthPlusPf\avs_core\core\MTGuard.cpp:35:
C:\Github\AviSynthPlusPf\avs_core\core\MTGuard.h:12:9: note: forward declaration of 'class std::mutex'
   class mutex;
         ^~~~~
C:\Github\AviSynthPlusPf\avs_core\core\MTGuard.cpp:65:10: note: neither the destructor nor the class-specific operator delete will be called, even if they are declared when the class is defined
   delete FilterMutex;
          ^~~~~~~~~~~
C:\Github\AviSynthPlusPf\avs_core\core\MTGuard.cpp: In member function 'void MTGuard::EnableMT(size_t)':
C:\Github\AviSynthPlusPf\avs_core\core\MTGuard.cpp:99:44: error: invalid use of incomplete type 'class std::mutex'
         this->FilterMutex = new std::mutex();
                                            ^
In file included from C:\Github\AviSynthPlusPf\avs_core\core\MTGuard.cpp:35:
C:\Github\AviSynthPlusPf\avs_core\core\MTGuard.h:12:9: note: forward declaration of 'class std::mutex'
   class mutex;
         ^~~~~
In file included from c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\mutex:43,
                 from C:\Github\AviSynthPlusPf\avs_core\core\MTGuard.cpp:41:
c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\bits\std_mutex.h: In instantiation of 'std::lock_guard<_Mutex>::lock_guard(std::lock_guard<_Mutex>::mutex_type&) [with _Mutex = std::mutex; std::lock_guard<_Mutex>::mutex_type = std::mutex]':
C:\Github\AviSynthPlusPf\avs_core\core\MTGuard.cpp:139:52:   required from here
c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\bits\std_mutex.h:162:19: error: invalid use of incomplete type 'std::lock_guard<std::mutex>::mutex_type' {aka 'class std::mutex'}
       { _M_device.lock(); }
         ~~~~~~~~~~^~~~
In file included from C:\Github\AviSynthPlusPf\avs_core\core\MTGuard.cpp:35:
C:\Github\AviSynthPlusPf\avs_core\core\MTGuard.h:12:9: note: forward declaration of 'std::lock_guard<std::mutex>::mutex_type' {aka 'class std::mutex'}
   class mutex;
         ^~~~~
In file included from c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\mutex:43,
                 from C:\Github\AviSynthPlusPf\avs_core\core\MTGuard.cpp:41:
c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\bits\std_mutex.h: In instantiation of 'std::lock_guard<_Mutex>::~lock_guard() [with _Mutex = std::mutex]':
C:\Github\AviSynthPlusPf\avs_core\core\MTGuard.cpp:139:52:   required from here
c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\bits\std_mutex.h:168:19: error: invalid use of incomplete type 'std::lock_guard<std::mutex>::mutex_type' {aka 'class std::mutex'}
       { _M_device.unlock(); }
         ~~~~~~~~~~^~~~~~
In file included from C:\Github\AviSynthPlusPf\avs_core\core\MTGuard.cpp:35:
C:\Github\AviSynthPlusPf\avs_core\core\MTGuard.h:12:9: note: forward declaration of 'std::lock_guard<std::mutex>::mutex_type' {aka 'class std::mutex'}
   class mutex;
         ^~~~~
avs_core\CMakeFiles\AvsCore.dir\build.make:216: recipe for target 'avs_core/CMakeFiles/AvsCore.dir/core/MTGuard.cpp.obj' failed
mingw32-make[2]: *** [avs_core/CMakeFiles/AvsCore.dir/core/MTGuard.cpp.obj] Error 1
CMakeFiles\Makefile2:122: recipe for target 'avs_core/CMakeFiles/AvsCore.dir/all' failed
mingw32-make[1]: *** [avs_core/CMakeFiles/AvsCore.dir/all] Error 2
makefile:128: recipe for target 'all' failed
mingw32-make: *** [all] Error 2

pinterf avatar Apr 09 '19 12:04 pinterf

Yeah, that's definitely not correct. The video is instructing for the old pre-w64 MinGW, although I only skimmed it. You'll want to use the MSys2 installer to set up the environment, and then you can enter the MSys2 shell (or rather, the MinGW alternate shell installed alongside it) and while inside the shell, use the pacman package manager to install all the dependencies. Unfortunately, I don't have a complete list of the dependencies as they're provided by MSys2.

I've been toying with the idea of adapting my crosscompile guide to a Cygwin environment, just to have a ready-to-use solution (and because Cygwin is closer to a native Linux crosscompiler than MSys2 is). That should be more of a 1:1 equal guide, apart from getting the basic stuff to get GCC compiled.

qyot27 avatar Apr 09 '19 13:04 qyot27

Thanks, MSYS2 was the keyword for me. Installation is on the way.

pinterf avatar Apr 09 '19 13:04 pinterf

Ok, msys2 and gcc8.3 is working, built all module but Shibatch with a single -msse2. Let me have some more time this week since I have to clean up the mess of source movements I've done around blend_common. I also got an 'alignas(32) too much"-like warning in ExprFilter I have to look at. The build output is also a mess for my first trial, I found modules in arbitrary folders, e.g. libConvertStacked.dll and libConvertStacked.dll.a generated in the same folder as ConvertStacked.cpp.

pinterf avatar Apr 09 '19 16:04 pinterf

The build output is also a mess for my first trial, I found modules in arbitrary folders, e.g. libConvertStacked.dll and libConvertStacked.dll.a generated in the same folder as ConvertStacked.cpp.

That sounds normal if you were doing an in-tree build? make install (or ninja install) takes care of the installation of the generated stuff into the correct directory structure. Unless you mean that make install wasn't installing the plugins (and based on that comment, I guess the plugins also need to have the same ifdef that omits the lib- prefix if building on/for Windows) - I always disable the plugins when testing GCC because I wasn't aware they'd been fixed up enough to build under GCC.

qyot27 avatar Apr 10 '19 00:04 qyot27

Huh, next try, please. Updated the small readme as well with gcc things and todos. Build instructions and environment for VS, CLANG and GCC now deserve a separate documentation I think.

pinterf avatar Apr 10 '19 13:04 pinterf

r2855 did not work with LLVM-Clang 8.0.0 again. I tried both /std:c++17 & /std:c++latest it won't solve the problem like you wrote in the comment.

Tools: LLVM 8.0.0 Visual Studio 2019 16.0.1 / Visual studio 2017 15.9.11 Cmake 3.14.1 NASM 2.14.02

Seems the commit 3be8306618fda9bfeb82f1630f6e4e1b9e1970e7 makes the problem.

error message:

Clang

9>D:\Source code\AviSynth\AviSynthPlus\avs_core\filters\exprfilter\exprfilter.cpp(3403): error : reinterpret_cast from 'int' to 'intptr_t' (aka 'long long') is not allowed

fuchanghao avatar Apr 11 '19 06:04 fuchanghao

Failed for 64bit builds. I checked the mods for all three compilers but have not switched to x64.

pinterf avatar Apr 11 '19 07:04 pinterf

Failed for 64bit builds. I checked the mods for all three compilers but have not switched to x64.

r2856 works fine in both Clang & MSVC 142 (GCC with msys2 MINGW-W64 not tested.)

fuchanghao avatar Apr 11 '19 08:04 fuchanghao

Builds with GCC given some of the changes in pull #31 (it also fixes a couple things that cropped up during testing the plugins).

Is the v14*_xp toolset gone from VS2019? Just wondering for the documentation, since VS2017 still has it.

qyot27 avatar Apr 11 '19 22:04 qyot27

Builds with GCC given some of the changes in pull #31 (it also fixes a couple things that cropped up during testing the plugins).

Is the v14*_xp toolset gone from VS2019? Just wondering for the documentation, since VS2017 still has it.

VS2019 only have v141_xp with Deprecated tag. v142 no longer support WinXP.

From the road map, Visual Studio 2017 no longer support Any new features after 2018 Q4. https://docs.microsoft.com/visualstudio/productinfo/vs-roadmap

fuchanghao avatar Apr 12 '19 01:04 fuchanghao