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

build failure using mingw32: error: 'asm' operand has impossible constraints #131

Closed
mayeut opened this issue Jan 6, 2024 · 4 comments
Closed
Assignees
Labels

Comments

@mayeut
Copy link
Contributor

mayeut commented Jan 6, 2024

The assembly code fails to build on mingw32:

cmake -B out -Werror=dev -DBASE64_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Release -DBASE64_WITH_AVX512=OFF
...
cmake --build out --config Release --verbose
Run Build Command(s): D:/a/_temp/msys64/mingw32/bin/ninja.exe -v
[1/18] D:\a\_temp\msys64\mingw32\bin\cc.exe -DBASE64_STATIC_DEFINE -ID:/a/base64/base64/include -ID:/a/base64/base64/out -O3 -DNDEBUG -std=c99 -Wall -Wextra -Wpedantic -Werror -mssse3 -MD -MT CMakeFiles/base64.dir/lib/arch/ssse3/codec.c.obj -MF CMakeFiles\base64.dir\lib\arch\ssse3\codec.c.obj.d -o CMakeFiles/base64.dir/lib/arch/ssse3/codec.c.obj -c D:/a/base64/base64/lib/arch/ssse3/codec.c
FAILED: CMakeFiles/base64.dir/lib/arch/ssse3/codec.c.obj 
D:\a\_temp\msys64\mingw32\bin\cc.exe -DBASE64_STATIC_DEFINE -ID:/a/base64/base64/include -ID:/a/base64/base64/out -O3 -DNDEBUG -std=c99 -Wall -Wextra -Wpedantic -Werror -mssse3 -MD -MT CMakeFiles/base64.dir/lib/arch/ssse3/codec.c.obj -MF CMakeFiles\base64.dir\lib\arch\ssse3\codec.c.obj.d -o CMakeFiles/base64.dir/lib/arch/ssse3/codec.c.obj -c D:/a/base64/base64/lib/arch/ssse3/codec.c
In file included from D:/a/base64/base64/lib/arch/ssse3/codec.c:29:
In function 'enc_loop_ssse3',
    inlined from 'base64_stream_encode_ssse3' at D:/a/base64/base64/lib/arch/ssse3/codec.c:42:2:
D:/a/base64/base64/lib/arch/ssse3/enc_loop_asm.c:160:9: error: 'asm' operand has impossible constraints
  160 |         __asm__ volatile (
      |         ^~~~~~~
[2/18] D:\a\_temp\msys64\mingw32\bin\cc.exe -DBASE64_STATIC_DEFINE -ID:/a/base64/base64/include -ID:/a/base64/base64/out -O3 -DNDEBUG -std=c99 -Wall -Wextra -Wpedantic -Werror -msse4.1 -MD -MT CMakeFiles/base64.dir/lib/arch/sse41/codec.c.obj -MF CMakeFiles\base64.dir\lib\arch\sse41\codec.c.obj.d -o CMakeFiles/base64.dir/lib/arch/sse41/codec.c.obj -c D:/a/base64/base64/lib/arch/sse41/codec.c
FAILED: CMakeFiles/base64.dir/lib/arch/sse41/codec.c.obj 
D:\a\_temp\msys64\mingw32\bin\cc.exe -DBASE64_STATIC_DEFINE -ID:/a/base64/base64/include -ID:/a/base64/base64/out -O3 -DNDEBUG -std=c99 -Wall -Wextra -Wpedantic -Werror -msse4.1 -MD -MT CMakeFiles/base64.dir/lib/arch/sse41/codec.c.obj -MF CMakeFiles\base64.dir\lib\arch\sse41\codec.c.obj.d -o CMakeFiles/base64.dir/lib/arch/sse41/codec.c.obj -c D:/a/base64/base64/lib/arch/sse41/codec.c
In file included from D:/a/base64/base64/lib/arch/sse41/codec.c:27:
In function 'enc_loop_ssse3',
    inlined from 'base64_stream_encode_sse41' at D:/a/base64/base64/lib/arch/sse41/codec.c:40:2:
D:/a/base64/base64/lib/arch/ssse3/enc_loop_asm.c:160:9: error: 'asm' operand has impossible constraints
  160 |         __asm__ volatile (
      |         ^~~~~~~
[3/18] D:\a\_temp\msys64\mingw32\bin\cc.exe -DBASE64_STATIC_DEFINE -ID:/a/base64/base64/include -ID:/a/base64/base64/out -O3 -DNDEBUG -std=c99 -Wall -Wextra -Wpedantic -Werror -MD -MT CMakeFiles/base64.dir/lib/codec_choose.c.obj -MF CMakeFiles\base64.dir\lib\codec_choose.c.obj.d -o CMakeFiles/base64.dir/lib/codec_choose.c.obj -c D:/a/base64/base64/lib/codec_choose.c
[4/18] D:\a\_temp\msys64\mingw32\bin\cc.exe -DBASE64_STATIC_DEFINE -ID:/a/base64/base64/include -ID:/a/base64/base64/out -O3 -DNDEBUG -std=c99 -Wall -Wextra -Wpedantic -Werror -MD -MT CMakeFiles/base64.dir/lib/tables/tables.c.obj -MF CMakeFiles\base64.dir\lib\tables\tables.c.obj.d -o CMakeFiles/base64.dir/lib/tables/tables.c.obj -c D:/a/base64/base64/lib/tables/tables.c
[5/18] D:\a\_temp\msys64\mingw32\bin\cc.exe -DBASE64_STATIC_DEFINE -ID:/a/base64/base64/include -ID:/a/base64/base64/out -O3 -DNDEBUG -std=c99 -Wall -Wextra -Wpedantic -Werror -MD -MT CMakeFiles/base64.dir/lib/lib.c.obj -MF CMakeFiles\base64.dir\lib\lib.c.obj.d -o CMakeFiles/base64.dir/lib/lib.c.obj -c D:/a/base64/base64/lib/lib.c
[6/18] D:\a\_temp\msys64\mingw32\bin\cc.exe -DBASE64_STATIC_DEFINE -ID:/a/base64/base64/include -ID:/a/base64/base64/out -O3 -DNDEBUG -std=c99 -Wall -Wextra -Wpedantic -Werror -MD -MT CMakeFiles/base64.dir/lib/arch/generic/codec.c.obj -MF CMakeFiles\base64.dir\lib\arch\generic\codec.c.obj.d -o CMakeFiles/base64.dir/lib/arch/generic/codec.c.obj -c D:/a/base64/base64/lib/arch/generic/codec.c
ninja: build stopped: subcommand failed.
@aklomp
Copy link
Owner

aklomp commented Jan 6, 2024

Hm, constraint errors happen when compiling the SSSE3 asm implementation on a 32-bit CPU, because 32-bit CPUs with SSE support do not have the same number of SIMD registers as 64-bit CPUs. (Such crazy hardware exists in the wild, for example the Atom N270.) It's a known limitation and therefore the asm implementation is only used when BASE64_WORDSIZE == 64.

So what I think is happening is that mingw32 somehow sets BASE64_WORDSIZE to 64, yet compiles code in 32-bit mode. That would mean that the cause is somewhere in this block. Could it be that mingw32 defines __x86_64__?

@mayeut
Copy link
Contributor Author

mayeut commented Jan 7, 2024

Given Windows is targeted, I could check that #123 / #125 fixes the issue (only checked #125 but same underlying issue fixed by both PR).

@aklomp
Copy link
Owner

aklomp commented Jan 8, 2024

@mayeut #125 is now merged, can you confirm that it fixed this issue?

@mayeut
Copy link
Contributor Author

mayeut commented Jan 8, 2024

Fixed by 88607fe

@mayeut mayeut closed this as completed Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants