Details
-
Bug
-
Resolution: Won't Fix
-
Major
-
master, 5.5.0
-
None
-
Untriaged
-
Unknown
Description
I have jemalloc installed system-wide without the je_ prefix. When I try to compile indexer it fails as follows:
gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -o $WORK/github.com/couchbase/nitro/mm/_obj/_cgo_.o $WORK/github.com/couchbase/nitro/mm/_obj/_cgo_main.o $WORK/github.com/couchbase/nitro/mm/_obj/_cgo_export.o $WORK/github.com/couchbase/nitro/mm/_obj/build.cgo2.o $WORK/github.com/couchbase/nitro/mm/_obj/malloc.cgo2.o $WORK/github.com/couchbase/nitro/mm/_obj/malloc.o -L /home/shaleny/dev/membase/repo-master/build/forestdb -L /home/shaleny/dev/membase/repo-master/build/sigar/src -L /home/shaleny/dev/membase/repo-master/build/platform -L /usr/lib -L /home/shaleny/dev/membase/repo-master/install/lib -ljemalloc
|
|
# github.com/couchbase/nitro/mm
|
/tmp/go-build761750868/github.com/couchbase/nitro/mm/_obj/malloc.o: In function `doStats':
|
../../../../../../goproj/src/github.com/couchbase/nitro/mm/malloc.c:36: undefined reference to `je_malloc_stats_print'
|
/tmp/go-build761750868/github.com/couchbase/nitro/mm/_obj/malloc.o: In function `mm_size':
|
../../../../../../goproj/src/github.com/couchbase/nitro/mm/malloc.c:82: undefined reference to `je_mallctl'
|
../../../../../../goproj/src/github.com/couchbase/nitro/mm/malloc.c:84: undefined reference to `je_mallctl'
|
/tmp/go-build761750868/github.com/couchbase/nitro/mm/_obj/malloc.o: In function `mm_free2os':
|
../../../../../../goproj/src/github.com/couchbase/nitro/mm/malloc.c:96: undefined reference to `je_mallctl'
|
../../../../../../goproj/src/github.com/couchbase/nitro/mm/malloc.c:98: undefined reference to `je_mallctl'
|
/tmp/go-build761750868/github.com/couchbase/nitro/mm/_obj/malloc.o: In function `mm_malloc':
|
../../../../../../goproj/src/github.com/couchbase/nitro/mm/malloc.c:45: undefined reference to `je_malloc'
|
/tmp/go-build761750868/github.com/couchbase/nitro/mm/_obj/malloc.o: In function `mm_free':
|
../../../../../../goproj/src/github.com/couchbase/nitro/mm/malloc.c:53: undefined reference to `je_free'
|
/tmp/go-build761750868/github.com/couchbase/nitro/mm/_obj/malloc.o: In function `mm_sizeat':
|
../../../../../../goproj/src/github.com/couchbase/nitro/mm/malloc.c:69: undefined reference to `je_sallocx'
|
collect2: error: ld returned 1 exit status
|
As seen, simply -ljemalloc is passed to gcc, which means that it will use the library found in standard global library paths over the one installed in $PREFIX/install/lib. We should path the full path to jemalloc here and also set the rpath instead.
Note, I do see this in go-install.cmake:
# QQQ TOTAL HACK to enable CGO binaries to find Couchbase-built shared
|
# libraries. This will clearly only work on Linux ELF-based systems,
|
# and only for those libraries which are installed in the correct path
|
# relative to the installed location of the Go executable. I'm still
|
# trying to figure out how to handle this correctly.
|
SET (ENV{LD_RUN_PATH} "$ORIGIN/../lib")
|
So this sort of works at run-time.