Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Tests failing when compiling with portage (ebuild)
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
Wadewilson
n00b
n00b


Joined: 09 Nov 2022
Posts: 56

PostPosted: Sat Feb 15, 2025 5:43 am    Post subject: Tests failing when compiling with portage (ebuild) Reply with quote

Following is the ebuild file for llama.cpp repo that I would like to install to my system:

Code:
# Copyright 1999-2024 wadewilson619
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit cmake-multilib cuda git-r3

EGIT_REPO_URI="https://github.com/ggerganov/llama.cpp.git"

DESCRIPTION="Inference of Meta's LLaMA model (and others) in pure C/C++"
HOMEPAGE="https://github.com/ggerganov/llama.cpp"

LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64"
IUSE="
address-sanitize
blas
ccache
cuda
curl
hostonly
lto
tests
thread-sanitize
undefined-sanitize
unified-memory
"
CPU_FLAGS_X86=( aes avx avx2 f16c fma3 mmx mmxext pclmul popcnt rdrand sse sse2 sse3 sse4_1 sse4_2 ssse3 )

DEPEND="blas?    ( sci-libs/openblas:= )
      cuda?    ( dev-util/nvidia-cuda-toolkit )
      curl?    ( net-misc/curl )
      ccache? ( dev-util/ccache )"
RDEPEND="${DEPEND}"
BDEPEND="${DEPEND}"

S="${WORKDIR}/${P}"

src_prepare() {
   if use cuda; then
      cuda_src_prepare
   fi
   cmake_src_prepare
}

src_configure() {

   if use cuda ; then
      export NVCC_CCBIN="$(cuda_gccdir)"
      export GGML_CUDA_ENABLE_UNIFIED_MEMORY="$(usex unified-memory)"
   fi

   local mycmakeargs=(
      -DGGML_BLAS="$(usex blas)"
      -DGGML_CUDA="$(usex cuda)"
      -DGGML_LTO="$(usex lto)"
      -DLLAMA_BUILD_TESTS="$(usex tests)"
      -DLLAMA_SANITIZE_THREAD="$(usex thread-sanitize)"
      -DLLAMA_SANITIZE_ADDRESS="$(usex address-sanitize)"
      -DLLAMA_SANITIZE_UNDEFINED="$(usex undefined-sanitize)"
      -DLLAMA_CURL="$(usex curl)"
      -DCMAKE_INSTALL_PREFIX=${EPREFIX}/opt/${PN}
      -DCMAKE_CUDA_ARCHITECTURES="75"
      -DGGML_CCACHE="$(usex ccache)"
   )

   cuda_add_sandbox
   cmake-multilib_src_configure
}

src_test() {
   cuda_add_sandbox
   export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"${BUILD_DIR}/bin"
   export LD_PRELOAD=/usr/lib/gcc/x86_64-pc-linux-gnu/13/libasan.so.8.0.0:$LD_PRELOAD
   cmake-multilib_src_test
}


When running
Quote:
ebuild ./llama-cpp-9999.ebuild manifest clean unpack test install

tests are failing because of errors raised by Address sanitizer (ASAN) but when I manually compile the repo with address sanitize enabled and run the tests I don't see errors. Why does this happen in portage build system sandbox?

Error thrown by portage build system:
Code:
=================================================================
==259==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 1 byte(s) in 1 object(s) allocated from:
    #0 0x7fe113edc33f in malloc (/usr/lib/gcc/x86_64-pc-linux-gnu/13/libasan.so.8.0.0+0xdc33f)
    #1 0x563d0c891df8  (/bin/gsed+0x10df8)
    #2 0x563d0c892ecc  (/bin/gsed+0x11ecc)
    #3 0x7fe113ca0156  (/lib64/libc.so.6+0x8d156)

SUMMARY: AddressSanitizer: 1 byte(s) leaked in 1 allocation(s).
 *
 * If you need support, post the output of `emerge --info '=dev-cpp/llama-cpp-9999::greninja'`,
 * the complete build log and the output of `emerge -pqv '=dev-cpp/llama-cpp-9999::greninja'`.
 * The complete build log is located at '/var/tmp/portage/dev-cpp/llama-cpp-9999/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/dev-cpp/llama-cpp-9999/temp/environment'.
 * Working directory: '/var/tmp/portage/dev-cpp/llama-cpp-9999/work/llama-cpp-9999_build-abi_x86_64.amd64'
 * S: '/var/tmp/portage/dev-cpp/llama-cpp-9999/work/llama-cpp-9999'

=================================================================
==297==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 43914 byte(s) in 26 object(s) allocated from:
    #0 0x7f8f3f8dc33f in malloc (/usr/lib/gcc/x86_64-pc-linux-gnu/13/libasan.so.8.0.0+0xdc33f)
    #1 0x7f8f3f336daa  (/usr/lib64/libpython3.12.so.1.0+0x136daa)

Indirect leak of 88953 byte(s) in 100 object(s) allocated from:
    #0 0x7f8f3f8dc33f in malloc (/usr/lib/gcc/x86_64-pc-linux-gnu/13/libasan.so.8.0.0+0xdc33f)
    #1 0x7f8f3f336daa  (/usr/lib64/libpython3.12.so.1.0+0x136daa)

SUMMARY: AddressSanitizer: 132867 byte(s) leaked in 126 allocation(s).


The specific issue that I am seeing in the logs is "odr-violation" raised by ASAN. Now, I want to understand why the same issue or error is not seen when I compile the repo manually with ASAN enabled.

Also, if I disable address sanitize, all tests are running fine in portage build system sandbox. Before I merge the package I want to be sure if the build is stable, hence I am running the tests.

Log file for failing test case because of ASAN :- https://0x0.st/8N9g.log
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum