Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Illegal HW instructions on x86-64 Linux while HW is not available #5

Open
TheRadioGuy opened this issue Jul 2, 2020 · 36 comments · Fixed by #6
Open

Illegal HW instructions on x86-64 Linux while HW is not available #5

TheRadioGuy opened this issue Jul 2, 2020 · 36 comments · Fixed by #6

Comments

@TheRadioGuy
Copy link

Hi there, my code is:

pub fn main(){
    unsafe {
        let mut err = 0;
        opusic_sys::opus_encoder_create(48000, 1, 2048, &mut err);
    }
}

image

(Illegal instruction, Core dumped)

@TheRadioGuy
Copy link
Author

image
Hmm..

@TheRadioGuy
Copy link
Author

image
Debugger says there's a problem

@DoumanAsh
Copy link
Owner

Just to be sure do you cross compile?

About pragma (release mode is used only when you build in release mode)

@DoumanAsh
Copy link
Owner

This is probably opus bug then.
Can you try to build C program that uses the same function and see?

@TheRadioGuy
Copy link
Author

Nope. I compile for my host OS.

@TheRadioGuy
Copy link
Author

I'm not famillar with C, but I'll try

@DoumanAsh
Copy link
Owner

DoumanAsh commented Jul 2, 2020

Just in case please make sure to use enums from doxygen https://github.com/xiph/opus/blob/c1c247d7e715100a50ca185948c7336bdd4dfdba/include/opus.h#L176-L207

I'll try to take a look at opus code, but as it is, I currently do not see why that instruction may cause segfault (especially in debug mode)

@TheRadioGuy
Copy link
Author

Uhm, I use defined value for mode set.

@DoumanAsh
Copy link
Owner

DoumanAsh commented Jul 2, 2020

Just out of curiosity can you list supported HW instructions on your CPU?
I think opus uses some HW instructions for QCONST16 macro.

Also check if same happens in release mode

@TheRadioGuy
Copy link
Author

image
With release

image
Instructions

@TheRadioGuy
Copy link
Author

Hm, isn't vmovdqa AVX2 instruction?

@DoumanAsh
Copy link
Owner

It is AVX afaik.
Hm I wonder if somewhere it detects that AVX is available...

@TheRadioGuy
Copy link
Author

Yep, it's pretty weird

@DoumanAsh
Copy link
Owner

Just out of curiosity check if Linux detects avx itself? via grep avx /proc/cpuinfo
I know avx is pretty old by now so I'm not sure if cmake just assumes that it is present

@TheRadioGuy
Copy link
Author

image
Nah.

@DoumanAsh
Copy link
Owner

Hmmm ok, let me try to think what could be wrong with configuration

@DoumanAsh DoumanAsh changed the title Illegal instructions on x86-64 Linux Illegal AVX instructions on x86-64 Linux while AVX is not available Jul 2, 2020
@TheRadioGuy
Copy link
Author

image
CMake thinks there's AVX, but there's no any AVX

@TheRadioGuy
Copy link
Author

image
Alright, even GCC thinks I have AVX.

@TheRadioGuy
Copy link
Author

image
My bad, forgot to add native. Nah, it doesn't support AVX.

@DoumanAsh
Copy link
Owner

Hmm should I maybe add native for gcc/clang...

Can you make sure that you use latest cmake/gcc/clang?

@DoumanAsh
Copy link
Owner

DoumanAsh commented Jul 3, 2020

On side note we can try to switch to master branch of opus, but I'm not sure how stable it is
There are also some suspicious AVX detection functions in opus cmake and I suspect they are kinda broken

@TheRadioGuy
Copy link
Author

image
Yes, they're all the latest. It's really weird that only CMAKE think my CPU supports AVX

@DoumanAsh
Copy link
Owner

DoumanAsh commented Jul 3, 2020

There can be bug in opus CMake files too...
Out of curiosity you can try to use master branch of opus to see if they fixed it yet?
I don't really have PC without AVX sadly

@TheRadioGuy
Copy link
Author

Got it, will check.

@TheRadioGuy
Copy link
Author

[duckerman@duck opus]$ ./autogen.sh
Updating build configuration files, please wait....
libtoolize: putting auxiliary files in '.'.
libtoolize: linking file './ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'm4'.
libtoolize: linking file 'm4/libtool.m4'
libtoolize: linking file 'm4/ltoptions.m4'
libtoolize: linking file 'm4/ltsugar.m4'
libtoolize: linking file 'm4/ltversion.m4'
libtoolize: linking file 'm4/lt~obsolete.m4'
configure.ac:38: installing './compile'
configure.ac:36: installing './config.guess'
configure.ac:36: installing './config.sub'
configure.ac:33: installing './install-sh'
configure.ac:33: installing './missing'
Makefile.am:323: warning: '%'-style pattern rules are a GNU make extension
Makefile.am:326: warning: '%'-style pattern rules are a GNU make extension
Makefile.am: installing './INSTALL'
Makefile.am: installing './depcomp'
parallel-tests: installing './test-driver'
[duckerman@duck opus]$  ./configure
checking whether make supports nested variables... yes
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether to enable maintainer-specific portions of Makefiles... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking how to print strings... printf
checking whether make supports the include directive... yes (GNU style)
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking how to convert x86_64-pc-linux-gnu file names to x86_64-pc-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-pc-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for a working dd... /usr/bin/dd
checking how to truncate binary pipes... /usr/bin/dd bs=4096 count=1
checking for mt... no
checking if : is a manifest tool... no
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for gcc option to accept ISO C99... none needed
checking for an ANSI C-conforming const... yes
checking for inline... inline
checking dependency style of gcc... gcc3
checking for C/C++ restrict keyword... __restrict
checking for C99 variable-size arrays... yes
checking for cos in -lm... yes
checking if compiler supports SSE intrinsics... yes
checking if compiler supports SSE2 intrinsics... yes
checking if compiler supports SSE4.1 intrinsics... no
checking if compiler supports SSE4.1 intrinsics with -msse4.1... yes
checking if compiler supports AVX intrinsics... no
checking if compiler supports AVX intrinsics with -mavx... yes
checking How to get X86 CPU Info... Inline Assembly
checking for doxygen... no
checking for dot... yes
checking if gcc supports -fvisibility=hidden... yes
checking if gcc supports -fstack-protector-strong... yes
checking whether to add -D_FORTIFY_SOURCE=2 to CFLAGS... yes
checking if gcc supports -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes... yes
checking for lrintf... yes
checking for lrint... yes
checking for __malloc_hook... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating opus.pc
config.status: creating opus-uninstalled.pc
config.status: creating celt/arm/armopts.s
config.status: creating doc/Makefile
config.status: creating doc/Doxyfile
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands
configure:
------------------------------------------------------------------------
  opus 1.3.1-63-gf8ed894b:  Automatic configuration OK.

    Compiler support:

      C99 var arrays: ................ yes
      C99 lrintf: .................... yes
      Use alloca: .................... no (using var arrays)

    General configuration:

      Floating point support: ........ yes
      Fast float approximations: ..... no
      Fixed point debugging: ......... no
      Inline Assembly Optimizations: . No inline ASM for your platform, please send patches
      External Assembly Optimizations: 
      Intrinsics Optimizations: ...... x86 SSE SSE2 SSE4.1 AVX
      Run-time CPU detection: ........ x86 SSE4.1 AVX
      Custom modes: .................. no
      Assertion checking: ............ no
      Hardening: ..................... yes
      Fuzzing: ....................... no
      Check ASM: ..................... no

      API documentation: ............. yes
      Extra programs: ................ yes
------------------------------------------------------------------------

There's AVX, again.

@DoumanAsh
Copy link
Owner

Damn... that's just weird.
We probably need to find a way to disable avx for user then since there are still some CPUs that lacks it

@DoumanAsh
Copy link
Owner

@DuckerMan It seems opus uses headers to provide detections for HW instructions https://github.com/xiph/opus/blob/87cdaae249cf44e3c0b772f3388d72539c6794b5/cmake/OpusFunctions.cmake#L165-L166

I honestly have no idea if there is a better way to do it in cmake.
I imagine it is common for C/C++ world, but if I'd want to fix it somehow there I would need to come up with alternative and there seem to be none for cmake/c/c++

@DoumanAsh
Copy link
Owner

@DuckerMan I made AVX a runtime check in 0.3.2, do let me know if it works as expected.
For some reason compile time detection didn't detect AVX on my CPU despite having support for AVX

@TheRadioGuy
Copy link
Author

Yep, it works with both debug and release now. Thank you!

@TheRadioGuy
Copy link
Author

TheRadioGuy commented Jul 4, 2020

Huh. Another problem with unavailable instuction. It happens when I'm trying to encode something.

image
image

Seems it's SSE 4_1 (because AVX is turned off) instructions, which my CPU doesn't support too. What's wrong with Opus?

@DoumanAsh DoumanAsh changed the title Illegal AVX instructions on x86-64 Linux while AVX is not available Illegal HW instructions on x86-64 Linux while HW is not available Jul 4, 2020
@DoumanAsh DoumanAsh reopened this Jul 4, 2020
@DoumanAsh
Copy link
Owner

DoumanAsh commented Jul 4, 2020

Ok, all HW instructions are detected using header xmmintrin.h in opus and checking availability of compiler flag
I have feeling that it doesn't work as expected

I'll make all HW instructions optionally disabled

@DoumanAsh
Copy link
Owner

DoumanAsh commented Jul 4, 2020

@DuckerMan I released 0.3.3 that performs runtime checks in build script for all used SSE instructions

@TheRadioGuy
Copy link
Author

Do you mean 0.3.4?

@TheRadioGuy
Copy link
Author

If so, it doesn't compile:

   Compiling opusic-sys v0.3.4 (/home/duckerman/Games_64/Rust/opusic-sys)
error: failed to run custom build command for `opusic-sys v0.3.4 (/home/duckerman/Games_64/Rust/opusic-sys)`

Caused by:
  process didn't exit successfully: `/home/duckerman/Games_64/Rust/opusic-sys/target/debug/build/opusic-sys-d6a052b88e54ba56/build-script-build` (exit code: 101)
--- stdout
running: "cmake" "/home/duckerman/Games_64/Rust/opusic-sys/opus" "-DOPUS_INSTALL_PKG_CONFIG_MODULE=OFF" "-DOPUS_INSTALL_CMAKE_CONFIG_MODULE=OFF" "-DOPUS_X86_MAY_HAVE_AVX=OFF" "-DOPUS_X86_PRESUME_AVX=OFF" "-DAVX_SUPPORTED=OFF" "-DOPUS_X86_MAY_HAVE_SSE4_1=OFF" "-DOPUS_X86_PRESUME_SSE4_1=OFF" "-DSSE4_1_SUPPORTED=OFF" "-DCMAKE_INSTALL_PREFIX=/home/duckerman/Games_64/Rust/opusic-sys/target/debug/build/opusic-sys-bc35a4e1d27e75d6/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_C_COMPILER=/usr/bin/cc" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_CXX_COMPILER=/usr/bin/c++" "-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_ASM_COMPILER=/usr/bin/cc" "-DCMAKE_BUILD_TYPE=Debug"
-- Opus library version: 0.8.0
-- Opus package version: 0
-- Opus project version: 0
-- Check SIMD support by compiler
-- The following features have been enabled:

 * STACK_PROTECTOR, Use stack protection
 * FLOAT_API, compile with the floating point API (for machines with float library)
 * X86_MAY_HAVE_SSE, does runtime check for SSE1 support
 * X86_MAY_HAVE_SSE2, does runtime check for SSE2 support
 * X86_PRESUME_SSE, assume target CPU has SSE1 support
 * X86_PRESUME_SSE2, assume target CPU has SSE2 support

-- The following REQUIRED packages have been found:

 * Git, fast, scalable, distributed revision control system, <https://git-scm.com/>
   required to set up package version

-- The following features have been disabled:

 * USE_ALLOCA, Use alloca for stack arrays (on non-C99 compilers)
 * CUSTOM_MODES, Enable non-Opus modes, e.g. 44.1 kHz & 2^n frames
 * BUILD_PROGRAMS, Build programs
 * FIXED_POINT, compile as fixed-point (for machines without a fast enough FPU)
 * INSTALL_PKG_CONFIG_MODULE, install PkgConfig module
 * INSTALL_CMAKE_CONFIG_MODULE, install CMake package config module
 * X86_MAY_HAVE_SSE4_1, does runtime check for SSE4_1 support
 * X86_MAY_HAVE_AVX, does runtime check for AVX support
 * X86_PRESUME_SSE4_1, assume target CPU has SSE4_1 support
 * X86_PRESUME_AVX, assume target CPU has AVX support

-- Configuring done
-- Generating done
-- Build files have been written to: /home/duckerman/Games_64/Rust/opusic-sys/target/debug/build/opusic-sys-bc35a4e1d27e75d6/out/build
running: "cmake" "--build" "." "--target" "install" "--config" "Debug" "--"
[  1%] Building C object CMakeFiles/opus.dir/silk/x86/VAD_sse4_1.c.o
[  2%] Building C object CMakeFiles/opus.dir/silk/x86/NSQ_sse4_1.c.o
[  3%] Building C object CMakeFiles/opus.dir/silk/x86/NSQ_del_dec_sse4_1.c.o

--- stderr
fatal: Имена не найдены, не могу ничего описать.
In file included from /home/duckerman/Games_64/Rust/opusic-sys/opus/silk/x86/NSQ_sse4_1.c:34:
/home/duckerman/Games_64/Rust/opusic-sys/opus/silk/x86/NSQ_sse4_1.c: В функции «silk_nsq_scale_states_sse4_1»:
/usr/lib/gcc/x86_64-pc-linux-gnu/10.1.0/include/smmintrin.h:334:1: ошибка: inlining failed in call to «always_inline» «_mm_mul_epi32»: target specific option mismatch
  334 | _mm_mul_epi32 (__m128i __X, __m128i __Y)
      | ^~~~~~~~~~~~~
/home/duckerman/Games_64/Rust/opusic-sys/opus/silk/x86/NSQ_sse4_1.c:644:25: замечание: которая вызвана здесь
  644 |         xmm_x_Q3_x3x1 = _mm_mul_epi32( xmm_x_Q3_x3x1, xmm_inv_gain_Q23 );
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/duckerman/Games_64/Rust/opusic-sys/opus/silk/x86/NSQ_sse4_1.c:34:
/usr/lib/gcc/x86_64-pc-linux-gnu/10.1.0/include/smmintrin.h:334:1: ошибка: inlining failed in call to «always_inline» «_mm_mul_epi32»: target specific option mismatch
  334 | _mm_mul_epi32 (__m128i __X, __m128i __Y)
      | ^~~~~~~~~~~~~
/home/duckerman/Games_64/Rust/opusic-sys/opus/silk/x86/NSQ_sse4_1.c:643:25: замечание: которая вызвана здесь
  643 |         xmm_x_Q3_x2x0 = _mm_mul_epi32( xmm_x_Q3_x2x0, xmm_inv_gain_Q23 );
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/duckerman/Games_64/Rust/opusic-sys/opus/silk/x86/NSQ_sse4_1.c:34:
/usr/lib/gcc/x86_64-pc-linux-gnu/10.1.0/include/smmintrin.h:334:1: ошибка: inlining failed in call to «always_inline» «_mm_mul_epi32»: target specific option mismatch
  334 | _mm_mul_epi32 (__m128i __X, __m128i __Y)
      | ^~~~~~~~~~~~~
/home/duckerman/Games_64/Rust/opusic-sys/opus/silk/x86/NSQ_sse4_1.c:644:25: замечание: которая вызвана здесь
  644 |         xmm_x_Q3_x3x1 = _mm_mul_epi32( xmm_x_Q3_x3x1, xmm_inv_gain_Q23 );
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/duckerman/Games_64/Rust/opusic-sys/opus/silk/x86/NSQ_sse4_1.c:34:
/usr/lib/gcc/x86_64-pc-linux-gnu/10.1.0/include/smmintrin.h:334:1: ошибка: inlining failed in call to «always_inline» «_mm_mul_epi32»: target specific option mismatch
  334 | _mm_mul_epi32 (__m128i __X, __m128i __Y)
      | ^~~~~~~~~~~~~
/home/duckerman/Games_64/Rust/opusic-sys/opus/silk/x86/NSQ_sse4_1.c:643:25: замечание: которая вызвана здесь
  643 |         xmm_x_Q3_x2x0 = _mm_mul_epi32( xmm_x_Q3_x2x0, xmm_inv_gain_Q23 );
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/duckerman/Games_64/Rust/opusic-sys/opus/silk/x86/NSQ_sse4_1.c:34:
/usr/lib/gcc/x86_64-pc-linux-gnu/10.1.0/include/smmintrin.h:334:1: ошибка: inlining failed in call to «always_inline» «_mm_mul_epi32»: target specific option mismatch
  334 | _mm_mul_epi32 (__m128i __X, __m128i __Y)
      | ^~~~~~~~~~~~~
/home/duckerman/Games_64/Rust/opusic-sys/opus/silk/x86/NSQ_sse4_1.c:688:37: замечание: которая вызвана здесь
  688 |             xmm_sLTP_shp_Q14_x3x1 = _mm_mul_epi32( xmm_sLTP_shp_Q14_x3x1, xmm_gain_adj_Q16 );
      |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/duckerman/Games_64/Rust/opusic-sys/opus/silk/x86/NSQ_sse4_1.c:34:
/usr/lib/gcc/x86_64-pc-linux-gnu/10.1.0/include/smmintrin.h:334:1: ошибка: inlining failed in call to «always_inline» «_mm_mul_epi32»: target specific option mismatch
  334 | _mm_mul_epi32 (__m128i __X, __m128i __Y)
      | ^~~~~~~~~~~~~
/home/duckerman/Games_64/Rust/opusic-sys/opus/silk/x86/NSQ_sse4_1.c:687:37: замечание: которая вызвана здесь
  687 |             xmm_sLTP_shp_Q14_x2x0 = _mm_mul_epi32( xmm_sLTP_shp_Q14_x2x0, xmm_gain_adj_Q16 );
      |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/duckerman/Games_64/Rust/opusic-sys/opus/silk/x86/NSQ_sse4_1.c:34:
/usr/lib/gcc/x86_64-pc-linux-gnu/10.1.0/include/smmintrin.h:334:1: ошибка: inlining failed in call to «always_inline» «_mm_mul_epi32»: target specific option mismatch
  334 | _mm_mul_epi32 (__m128i __X, __m128i __Y)
      | ^~~~~~~~~~~~~
/home/duckerman/Games_64/Rust/opusic-sys/opus/silk/x86/NSQ_sse4_1.c:688:37: замечание: которая вызвана здесь
  688 |             xmm_sLTP_shp_Q14_x3x1 = _mm_mul_epi32( xmm_sLTP_shp_Q14_x3x1, xmm_gain_adj_Q16 );
      |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/duckerman/Games_64/Rust/opusic-sys/opus/silk/x86/NSQ_sse4_1.c:34:
/usr/lib/gcc/x86_64-pc-linux-gnu/10.1.0/include/smmintrin.h:334:1: ошибка: inlining failed in call to «always_inline» «_mm_mul_epi32»: target specific option mismatch
  334 | _mm_mul_epi32 (__m128i __X, __m128i __Y)
      | ^~~~~~~~~~~~~
/home/duckerman/Games_64/Rust/opusic-sys/opus/silk/x86/NSQ_sse4_1.c:687:37: замечание: которая вызвана здесь
  687 |             xmm_sLTP_shp_Q14_x2x0 = _mm_mul_epi32( xmm_sLTP_shp_Q14_x2x0, xmm_gain_adj_Q16 );
      |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/duckerman/Games_64/Rust/opusic-sys/opus/silk/x86/NSQ_del_dec_sse4_1.c:34:
/home/duckerman/Games_64/Rust/opusic-sys/opus/silk/x86/NSQ_del_dec_sse4_1.c: В функции «silk_nsq_del_dec_scale_states_sse4_1»:
/usr/lib/gcc/x86_64-pc-linux-gnu/10.1.0/include/smmintrin.h:334:1: ошибка: inlining failed in call to «always_inline» «_mm_mul_epi32»: target specific option mismatch
  334 | _mm_mul_epi32 (__m128i __X, __m128i __Y)
      | ^~~~~~~~~~~~~
/home/duckerman/Games_64/Rust/opusic-sys/opus/silk/x86/NSQ_del_dec_sse4_1.c:773:25: замечание: которая вызвана здесь
  773 |         xmm_x_Q3_x3x1 = _mm_mul_epi32( xmm_x_Q3_x3x1, xmm_inv_gain_Q23 );
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/duckerman/Games_64/Rust/opusic-sys/opus/silk/x86/NSQ_del_dec_sse4_1.c:34:
/usr/lib/gcc/x86_64-pc-linux-gnu/10.1.0/include/smmintrin.h:334:1: ошибка: inlining failed in call to «always_inline» «_mm_mul_epi32»: target specific option mismatch
  334 | _mm_mul_epi32 (__m128i __X, __m128i __Y)
      | ^~~~~~~~~~~~~
/home/duckerman/Games_64/Rust/opusic-sys/opus/silk/x86/NSQ_del_dec_sse4_1.c:772:25: замечание: которая вызвана здесь
  772 |         xmm_x_Q3_x2x0 = _mm_mul_epi32( xmm_x_Q3_x2x0, xmm_inv_gain_Q23 );
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/duckerman/Games_64/Rust/opusic-sys/opus/silk/x86/NSQ_del_dec_sse4_1.c:34:
/usr/lib/gcc/x86_64-pc-linux-gnu/10.1.0/include/smmintrin.h:334:1: ошибка: inlining failed in call to «always_inline» «_mm_mul_epi32»: target specific option mismatch
  334 | _mm_mul_epi32 (__m128i __X, __m128i __Y)
      | ^~~~~~~~~~~~~
/home/duckerman/Games_64/Rust/opusic-sys/opus/silk/x86/NSQ_del_dec_sse4_1.c:773:25: замечание: которая вызвана здесь
  773 |         xmm_x_Q3_x3x1 = _mm_mul_epi32( xmm_x_Q3_x3x1, xmm_inv_gain_Q23 );
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/duckerman/Games_64/Rust/opusic-sys/opus/silk/x86/NSQ_del_dec_sse4_1.c:34:
/usr/lib/gcc/x86_64-pc-linux-gnu/10.1.0/include/smmintrin.h:334:1: ошибка: inlining failed in call to «always_inline» «_mm_mul_epi32»: target specific option mismatch
  334 | _mm_mul_epi32 (__m128i __X, __m128i __Y)
      | ^~~~~~~~~~~~~
/home/duckerman/Games_64/Rust/opusic-sys/opus/silk/x86/NSQ_del_dec_sse4_1.c:772:25: замечание: которая вызвана здесь
  772 |         xmm_x_Q3_x2x0 = _mm_mul_epi32( xmm_x_Q3_x2x0, xmm_inv_gain_Q23 );
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/duckerman/Games_64/Rust/opusic-sys/opus/silk/x86/NSQ_del_dec_sse4_1.c:34:
/usr/lib/gcc/x86_64-pc-linux-gnu/10.1.0/include/smmintrin.h:334:1: ошибка: inlining failed in call to «always_inline» «_mm_mul_epi32»: target specific option mismatch
  334 | _mm_mul_epi32 (__m128i __X, __m128i __Y)
      | ^~~~~~~~~~~~~
/home/duckerman/Games_64/Rust/opusic-sys/opus/silk/x86/NSQ_del_dec_sse4_1.c:818:41: замечание: которая вызвана здесь
  818 |                 xmm_sLTP_shp_Q14_x3x1 = _mm_mul_epi32( xmm_sLTP_shp_Q14_x3x1, xmm_gain_adj_Q16 );
      |                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/duckerman/Games_64/Rust/opusic-sys/opus/silk/x86/NSQ_del_dec_sse4_1.c:34:
/usr/lib/gcc/x86_64-pc-linux-gnu/10.1.0/include/smmintrin.h:334:1: ошибка: inlining failed in call to «always_inline» «_mm_mul_epi32»: target specific option mismatch
  334 | _mm_mul_epi32 (__m128i __X, __m128i __Y)
      | ^~~~~~~~~~~~~
/home/duckerman/Games_64/Rust/opusic-sys/opus/silk/x86/NSQ_del_dec_sse4_1.c:817:41: замечание: которая вызвана здесь
  817 |                 xmm_sLTP_shp_Q14_x2x0 = _mm_mul_epi32( xmm_sLTP_shp_Q14_x2x0, xmm_gain_adj_Q16 );
      |                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/opus.dir/build.make:1942: CMakeFiles/opus.dir/silk/x86/NSQ_sse4_1.c.o] Ошибка 1
In file included from /home/duckerman/Games_64/Rust/opusic-sys/opus/silk/x86/NSQ_del_dec_sse4_1.c:34:
/usr/lib/gcc/x86_64-pc-linux-gnu/10.1.0/include/smmintrin.h:334:1: ошибка: inlining failed in call to «always_inline» «_mm_mul_epi32»: target specific option mismatch
  334 | _mm_mul_epi32 (__m128i __X, __m128i __Y)
      | ^~~~~~~~~~~~~
/home/duckerman/Games_64/Rust/opusic-sys/opus/silk/x86/NSQ_del_dec_sse4_1.c:818:41: замечание: которая вызвана здесь
  818 |                 xmm_sLTP_shp_Q14_x3x1 = _mm_mul_epi32( xmm_sLTP_shp_Q14_x3x1, xmm_gain_adj_Q16 );
      |                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/duckerman/Games_64/Rust/opusic-sys/opus/silk/x86/NSQ_del_dec_sse4_1.c:34:
/usr/lib/gcc/x86_64-pc-linux-gnu/10.1.0/include/smmintrin.h:334:1: ошибка: inlining failed in call to «always_inline» «_mm_mul_epi32»: target specific option mismatch
  334 | _mm_mul_epi32 (__m128i __X, __m128i __Y)
      | ^~~~~~~~~~~~~
make[2]: *** Ожидание завершения заданий…
/home/duckerman/Games_64/Rust/opusic-sys/opus/silk/x86/NSQ_del_dec_sse4_1.c:817:41: замечание: которая вызвана здесь
  817 |                 xmm_sLTP_shp_Q14_x2x0 = _mm_mul_epi32( xmm_sLTP_shp_Q14_x2x0, xmm_gain_adj_Q16 );
      |                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/opus.dir/build.make:1955: CMakeFiles/opus.dir/silk/x86/NSQ_del_dec_sse4_1.c.o] Ошибка 1
make[1]: *** [CMakeFiles/Makefile2:96: CMakeFiles/opus.dir/all] Ошибка 2
make: *** [Makefile:150: all] Ошибка 2
thread 'main' panicked at '
command did not execute successfully, got: exit code: 2

build script failed, must exit now', /home/duckerman/.cargo/registry/src/github.com-1ecc6299db9ec823/cmake-0.1.44/src/lib.rs:885:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

@DoumanAsh
Copy link
Owner

Uh... I have feeling that opus with its HW instructions is just broken...
it shouldn't include this code, yet it includes...

@DoumanAsh
Copy link
Owner

Okay, I'll summarize how opus detects HW instrucitons:

  • Checks presence of Xmmintrin.h headers which indicate that target is x86
  • Check if compiler has option -m<instruciton set> which means compiler supports specified instruction for target
  • Add compiler flag to use instruction set (enabling macro detection during compilation)
  • Sets <INSTRUCTON>_SUPPORTED variable
  • Checks <INSTRUCTION>_SUPPORTED to set feature <INSTRUCTION>_MAY_HAVE which means that it should try to perform runtime check before using instruction
  • Sets <INSTRUCTION>_PRESUME depending on platform which omits runtime checks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants