github: clang: Test i386 Interlocked functions The existing CI tests i686 and x86_64 but not i386. Add a step in the testcases-clang job that compiles t_intrinc.c with -march=i386 using the i686 llvm-mingw toolchain. LLVM's x86 backend does not model the absence of CMPXCHG and XADD on i386, so without kernel32 fallback in intrin-impl.h it silently lowers __sync_* builtins to i486+ instructions even with -march=i386. Verify the object contains no CMPXCHG or XADD instructions to ensure kernel32 fallback is being used. Then link and run the test to confirm the Interlocked functions return correct values. Signed-off-by: Jaeden Amero <jaeden@patater.com> Signed-off-by: LIU Hao <lh_mouse@126.com>
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 847fdce..0f5158a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml
@@ -623,6 +623,18 @@ make -j$(nproc) make -j$(nproc) install make -j$(nproc) check -k -O --no-print-directory TESTS= + - name: Test i386 Interlocked functions + if: matrix.arch == 'i686' + run: | + export PATH=/llvm-mingw/bin:$PATH + ${{matrix.arch}}-w64-mingw32-clang -std=c99 -march=i386 -c -o t_intrinc.o mingw-w64-crt/testcases/t_intrinc.c + if ${{matrix.arch}}-w64-mingw32-objdump -d t_intrinc.o | grep -qiE 'cmpxchg|xadd'; then + echo "Error: i386 object contains i486+ instructions:" + ${{matrix.arch}}-w64-mingw32-objdump -d t_intrinc.o | grep -iE 'cmpxchg|xadd' + exit 1 + fi + ${{matrix.arch}}-w64-mingw32-clang -std=c99 -march=i386 -o t_intrinc.exe mingw-w64-crt/testcases/t_intrinc.c + ./t_intrinc.exe - name: Run mingw-w64-crt testcases if: matrix.arch != 'armv7' run: |