From: "lish82 (Hiroki Katagiri) via ruby-core" <ruby-core@...> Date: 2024-05-19T01:49:10+00:00 Subject: [ruby-core:117918] [Ruby master Bug#20494] Non-default directories are not searched when checking for a gmp header Issue #20494 has been reported by lish82 (Hiroki Katagiri). ---------------------------------------- Bug #20494: Non-default directories are not searched when checking for a gmp header https://bugs.ruby-lang.org/issues/20494 * Author: lish82 (Hiroki Katagiri) * Status: Open * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- This is my very first issue submission I would be happy to know if I missed anything --- I found that the ruby installed with `ruby-build` is not linked to the gmp library Environment: - OS: macOS Sonoma 14.5 - Directory that gmp is installed: /opt/homebrew (= installed via homebrew) I believe it was able to link to gmp before, so I tried to investigate the cause of the problem As a result, I found the followings: - During the execution of `./configure`, `checking for gmp.h...` is showing `no` - Specifying `--with-gmp-dir=/opt/homebrew` does not work - It has been occurring since 3.2.3 - When I built it on linux, it was successfully linked to gmp - gmp was installed in the default directory (`/usr/include`) - Revert the following changes and the problem goes away - https://github.com/ruby/ruby/pull/8449 Based on these observations, I believe the issue is that the directories specified with `--with-opt-dir` or `--with-gmp-dir` are not being included in the search path when checking for the gmp header I was able to solve the problem by changing the build process as follows ```patch diff --git a/configure.ac b/configure.ac index 18b4247..a440de6 100644 --- a/configure.ac +++ b/configure.ac @@ -1363,7 +1363,11 @@ AS_CASE("$target_cpu", [x64|x86_64|i[3-6]86*], [ RUBY_UNIVERSAL_CHECK_HEADER([x86_64, i386], x86intrin.h) AS_IF([test "x$with_gmp" != xno], - [AC_CHECK_HEADERS(gmp.h) + [original_CPPFLAGS="${CPPFLAGS}" + CPPFLAGS="${INCFLAGS} ${CPPFLAGS}" + AC_CHECK_HEADERS(gmp.h) + CPPFLAGS="${original_CPPFLAGS}" + unset original_CPPFLAGS AS_IF([test "x$ac_cv_header_gmp_h" != xno], AC_SEARCH_LIBS([__gmpz_init], [gmp], [AC_DEFINE(HAVE_LIBGMP, 1)]))]) ``` However, I am not familiar with ruby's build process or autotools, so I'm not sure if this is the correct approach --- I would appreciate it if someone could consider resolving this issue -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/