On Thu, 19 Oct 2023 13:49:21 GMT, Robbin Ehn <r...@openjdk.org> wrote:
>> Hi please consider. >> >> This works with 2.30, 2.34, 2.38, 2.39, 2.40, 2.41 and current master head. >> (tested x64 and some RV) >> >> There are 4 changes in binutils we work around. >> - zstd compressed debug sections >> - libsframe added >> - init_disassemble_info() change >> - libbfd.a is only present in .lib directory in newer binutils builds (older >> it is in both directories) (I think the issue is that we never do make >> install, thus have dependency on internal artifact placement) >> >> Specific to RV, there is a bug in binutils causing the standard extensions >> not being added to disassembler if we pass in NULL. >> >> This no way near perfect, but at least we can build hsdis with any >> contemporary binutils. >> >> Todo better I think we need to build and install binutils to check the >> version and then use that version to figure out what options to use when >> re-building and re-installing binutils for hsdis. >> >> I asked tool-chain people about our issues, they said, you can't do that. >> I.e. have source dependencies on many binutils versions. >> >> As RV is new and have new instructions added to it frequently we really need >> to be able to build with bleeding-edge binutils. (capstone RV is not >> actively worked on, llvm have many more dependencies) > > Robbin Ehn has updated the pull request incrementally with one additional > commit since the last revision: > > Added back guard make/autoconf/lib-hsdis.m4 line 272: > 270: > 271: AC_MSG_CHECKING([Checking binutils API]) > 272: AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include $disasm_header],[[void > foo() {init_disassemble_info(0, 0, 0, 0);}]])], Seems to me this is not working as expected but I don't have an env to verify this. I've been working on something similar to deal with `capstone` API changes and the pattern here seemed to not compile but not for the reasons expected. For example, I created: AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include $capstone_header],[[void foo() {cs_arch test = CS_ARCH_AARCH64;}]])], And when I looked the compilation error it showed: conftest.c:27:12: error: function definition is not allowed here void foo() {cs_arch test = CS_ARCH_AARCH64;} ^ 1 error generated. configure:142919: $? = 1 configure: failed program was: | /* confdefs.h */ | #define PACKAGE_NAME "OpenJDK" | #define PACKAGE_TARNAME "openjdk" | #define PACKAGE_VERSION "openjdk" | #define PACKAGE_STRING "OpenJDK openjdk" | #define PACKAGE_BUGREPORT "build-dev@openjdk.org" | #define PACKAGE_URL "https://openjdk.org" | #define HAVE_STDIO_H 1 | #define HAVE_STDLIB_H 1 | #define HAVE_STRING_H 1 | #define HAVE_INTTYPES_H 1 | #define HAVE_STDINT_H 1 | #define HAVE_STRINGS_H 1 | #define HAVE_SYS_STAT_H 1 | #define HAVE_SYS_TYPES_H 1 | #define HAVE_UNISTD_H 1 | #define STDC_HEADERS 1 | #define HAVE_STDIO_H 1 | #define SIZEOF_INT_P 8 | #define HAVE_CUPS_CUPS_H 1 | #define HAVE_CUPS_PPD_H 1 | /* end confdefs.h. */ | #include "/Users/galder/opt/capstone/include/capstone/capstone.h" | int | main (void) | { | void foo() {cs_arch test = CS_ARCH_AARCH64;} | ; | return 0; | } So, the code was not compiling not because of the wrong `cs_arch` value but because you cannot define a method within main. Instead I made my `AC_COMPILE_IFELSE` looks like this: AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include $capstone_header],[[cs_arch test = CS_ARCH_AARCH64;]])], And that works as expected. For example, when using a `capstone` library that supports `CS_ARCH_AARCH64`, it does: configure:142754: result: 'capstone' configure:142767: checking for capstone configure:142770: result: /Users/galder/opt/capstone configure:142906: checking capstone aarch64 arch name configure:142919: /usr/bin/clang -c -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -iframework /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/System/Library/Frameworks -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -iframework /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/System/Library/Frameworks conftest.c >&5 configure:142919: $? = 0 configure:142922: result: AARCH64 And when the capstone library does not have `CS_ARCH_AARCH64`, the compilation error I get is the expected one: conftest.c:27:16: error: use of undeclared identifier 'CS_ARCH_AARCH64'; did you mean 'CS_ARCH_ARM64'? cs_arch test = CS_ARCH_AARCH64; ^~~~~~~~~~~~~~~ CS_ARCH_ARM64 /Users/galder/opt/capstone-5/include/capstone/capstone.h:76:2: note: 'CS_ARCH_ARM64' declared here CS_ARCH_ARM64, ///< ARM-64, also called AArch64 ^ 1 error generated. configure:142919: $? = 1 configure: failed program was: | /* confdefs.h */ | #define PACKAGE_NAME "OpenJDK" | #define PACKAGE_TARNAME "openjdk" | #define PACKAGE_VERSION "openjdk" | #define PACKAGE_STRING "OpenJDK openjdk" | #define PACKAGE_BUGREPORT "build-dev@openjdk.org" | #define PACKAGE_URL "https://openjdk.org" | #define HAVE_STDIO_H 1 | #define HAVE_STDLIB_H 1 | #define HAVE_STRING_H 1 | #define HAVE_INTTYPES_H 1 | #define HAVE_STDINT_H 1 | #define HAVE_STRINGS_H 1 | #define HAVE_SYS_STAT_H 1 | #define HAVE_SYS_TYPES_H 1 | #define HAVE_UNISTD_H 1 | #define STDC_HEADERS 1 | #define HAVE_STDIO_H 1 | #define SIZEOF_INT_P 8 | #define HAVE_CUPS_CUPS_H 1 | #define HAVE_CUPS_PPD_H 1 | /* end confdefs.h. */ | #include "/Users/galder/opt/capstone-5/include/capstone/capstone.h" | int | main (void) | { | cs_arch test = CS_ARCH_AARCH64; | ; | return 0; | } ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15138#discussion_r1402917476