Project

General

Profile

Actions

Bug #20500

closed

Non-system directories are not searched when checking for jemalloc headers and libs, and building `enc`

Added by lish82 (Hiroki Katagiri) about 1 month ago. Updated about 1 month ago.

Status:
Closed
Target version:
-
[ruby-core:117957]

Description

I found a problem similar to #20494 on jemalloc
It's similar to #20494, but it has a few more issues

Problems:

  • Non-system directories (specified by --with-opt-dir) are not searched when checking jemalloc headers (almost the same as #20494)
  • Non-system directories are not searched when checking jemalloc libs
  • Non-system directories are not searched when building the enc directory sources

I have confirmed that this problem can be fixed by applying the following patch:

diff --git a/configure.ac b/configure.ac
index 169662c..b2dce70 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1392,6 +1392,8 @@ AC_ARG_WITH([jemalloc],
   [with_jemalloc=$withval], [with_jemalloc=no])
 AS_IF([test "x$with_jemalloc" != xno],[
   # find jemalloc header first
+  save_CPPFLAGS="${CPPFLAGS}"
+  CPPFLAGS="${INCFLAGS} ${CPPFLAGS}"
   malloc_header=
   AC_CHECK_HEADER(jemalloc/jemalloc.h, [malloc_header=jemalloc/jemalloc.h], [
     AC_CHECK_HEADER(jemalloc.h, [malloc_header=jemalloc.h])
@@ -1423,6 +1425,8 @@ AS_IF([test "x$with_jemalloc" != xno],[
       done
     done
   ])
+  CPPFLAGS="${save_CPPFLAGS}"
+  unset save_CPPFLAGS
   with_jemalloc=${rb_cv_jemalloc_library}
   AS_CASE(["$with_jemalloc"],
   [no],
diff --git a/enc/Makefile.in b/enc/Makefile.in
index 6920bc9..ce93fdd 100644
--- a/enc/Makefile.in
+++ b/enc/Makefile.in
@@ -52,7 +52,7 @@ optflags = @optflags@
 debugflags = @debugflags@
 warnflags = @warnflags@
 CCDLFLAGS = @CCDLFLAGS@
-INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(top_srcdir)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(top_srcdir) @incflags@
 DEFS = @DEFS@
 CPPFLAGS = @CPPFLAGS@ -DONIG_ENC_REGISTER=rb_enc_register
 LDFLAGS = @LDFLAGS@

On a side note, I think there might be other parts affected by the changes bellow:
https://github.com/ruby/ruby/pull/8449

I thought it might be a good idea to review everything thoroughly

Updated by mame (Yusuke Endoh) about 1 month ago

  • Assignee set to nobu (Nobuyoshi Nakada)

Updated by nobu (Nobuyoshi Nakada) about 1 month ago

Or use RUBY_CHECK_HEADER instead of AC_CHECK_HEADER?
A question, does enc use jemalloc?

Updated by lish82 (Hiroki Katagiri) about 1 month ago

I don't know if enc uses jemalloc actually
But the build of enc fails because -ljemalloc is specified when building enc

Updated by lish82 (Hiroki Katagiri) about 1 month ago

It might be correct to fix it so that -ljemalloc is not specified when building enc

Updated by lish82 (Hiroki Katagiri) about 1 month ago ยท Edited

Or use RUBY_CHECK_HEADER instead of AC_CHECK_HEADER?

I think it's enough to solve the first problem (Non-system directories are not searched when checking jemalloc headers)

But the process that checks jemalloc has a process that checks about library (I'm sorry but I don't know its details),
which expects jemalloc headers to be included in the search path.

So I think that just RUBY_CHECK_HEADER might not solve the second problem (Non-system directories are not searched when checking jemalloc libs)

Actions #7

Updated by nobu (Nobuyoshi Nakada) about 1 month ago

  • Status changed from Open to Closed

Applied in changeset git|5fa6ba9568e87e43e08a4daeba1572254c589fb1.


[Bug #20500] Search non-default directories for jemalloc

Co-Authored-by: lish82 (Hiroki Katagiri)

Updated by lish82 (Hiroki Katagiri) about 1 month ago

Thank you for your fix!

Also, I think this change needs to be backported to 3.2.x as well:
https://bugs.ruby-lang.org/issues/20494#note-7

I hope you can change the Backport field If the above is correct

Actions #9

Updated by nobu (Nobuyoshi Nakada) about 1 month ago

  • Backport changed from 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN to 3.1: UNKNOWN, 3.2: REQUIRED, 3.3: REQUIRED

Updated by k0kubun (Takashi Kokubun) about 1 month ago

  • Backport changed from 3.1: UNKNOWN, 3.2: REQUIRED, 3.3: REQUIRED to 3.1: UNKNOWN, 3.2: REQUIRED, 3.3: DONE
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0