intelxed / xed

The X86 Encoder Decoder (XED), is a software library for encoding and decoding X86 (IA32 and Intel64) instructions
https://intelxed.github.io/
Apache License 2.0
1.38k stars 146 forks source link

Fix clang compile. #283

Closed Inori closed 2 years ago

Inori commented 2 years ago

-Wno-language-extension-token need to be added, or the there will be compile errors when using clang, at least version 13.0.0 is tested.

marjevan commented 2 years ago

Hi, and thanks for your contribution. Can you specify the exact compilation errors?

Inori commented 2 years ago

This is part of the errors without -Wno-language-extension-token:

[MBUILD WARNING] Command execution failed. Waiting for remaining jobs and exiting.
R: 3 P: 79 C: 31 E: 1 / 3 secs
[COMMAND     ] clang -I./include/private -I./include/public/xed -I./include/public -Iobj -Iobj/include-private        -m64  -std=c99  -pedantic  -Wall -Wunused -Werror -Wno-long-long -Wno-unknown-pragmas -fmessage-length=0 -pipe -fomit-frame-pointer -fno-exceptions -Wformat-security -Wformat -Wstrict-prototypes -Wwrite-strings -Wredundant-decls -DXED_GIT_VERSION="12.0.1-73-g10d3e87" -DXED_AMD_ENABLED -DXED_VIA_ENABLED -DXED_AVX -DXED_SUPPORTS_AVX512 -DXED_MPX -DXED_CET -DXED_SUPPORTS_SHA -DXED_SUPPORTS_WBNOINVD -DXED_DECODER -DXED_ENCODER -DXED_SUPPORTS_LZCNT_TZCNT -DXED_BUILD -c -o obj/xed-operand-action.o D:/Code/xed/src/common/xed-operand-action.c
[EXIT_STATUS ] 1
[STDERR]
In file included from D:/Code/xed/src/common/xed-operand-action.c:22:
In file included from ./include/public/xed\xed-operand-action.h:24:
./include/public/xed/xed-types.h:58:9: error: extension used [-Werror,-Wlanguage-extension-token]
typedef xed_uint64_t xed_addr_t;
        ^
./include/public/xed/xed-types.h:43:33: note: expanded from macro 'xed_uint64_t'
#  define xed_uint64_t unsigned __int64
                                ^
./include/public/xed/xed-types.h:65:4: error: extension used [-Werror,-Wlanguage-extension-token]
   xed_uint8_t   byte[2];
   ^
./include/public/xed/xed-types.h:40:33: note: expanded from macro 'xed_uint8_t'
#  define xed_uint8_t  unsigned __int8
                                ^
./include/public/xed/xed-types.h:69:5: error: extension used [-Werror,-Wlanguage-extension-token]
    xed_uint8_t b0; /*low 8 bits*/
    ^
./include/public/xed/xed-types.h:40:33: note: expanded from macro 'xed_uint8_t'
#  define xed_uint8_t  unsigned __int8
                                ^
./include/public/xed/xed-types.h:70:5: error: extension used [-Werror,-Wlanguage-extension-token]
    xed_uint8_t b1; /*high 8 bits*/
    ^
./include/public/xed/xed-types.h:40:33: note: expanded from macro 'xed_uint8_t'
#  define xed_uint8_t  unsigned __int8
                                ^
./include/public/xed/xed-types.h:73:3: error: extension used [-Werror,-Wlanguage-extension-token]

Additionally I found we also need to add -Wno-unused-function C++ flag, or there will be compile error when build examples.

[MBUILD WARNING] Command execution failed. Waiting for remaining jobs and exiting.
R: 3 P: 15 C: 33 E: 1 / 6 secs
[COMMAND     ] clang++ -Iobj/wkit/examples -Iobj/wkit/include        -m64  -Wall -Wunused -Werror -Wno-long-long -Wno-unknown-pragmas -fmessage-length=0 -pipe -fomit-frame-pointer -fno-exceptions -Wformat-security -Wformat -DXED_GIT_VERSION="12.0.1-73-g10d3e87" -DXED_AMD_ENABLED -DXED_VIA_ENABLED -DXED_AVX -DXED_SUPPORTS_AVX512 -DXED_MPX -DXED_CET -DXED_SUPPORTS_SHA -DXED_SUPPORTS_WBNOINVD -DXED_DECODER -DXED_ENCODER -DXED_SUPPORTS_LZCNT_TZCNT  -c -o obj/wkit/examples/obj/xed-disas-pecoff.o D:/Code/xed/obj/wkit/examples/xed-disas-pecoff.cpp
[EXIT_STATUS ] 1
[ELAPSED_TIME] 2 secs
[STDERR]
D:/Code/xed/obj/wkit/examples/xed-disas-pecoff.cpp:88:12: error: unused function 'find_wow64_redir' [-Werror,-Wunused-function]
static int find_wow64_redir(fptr_t* disable, fptr_t* revert) {
           ^
1 error generated.
marjevan commented 2 years ago

Thanks for the PR. The fix will be available on the next external release.