Skip to content

Conversation

@L33TSP34KER
Copy link

The commit fixes a simple compilation warning

@L33TSP34KER L33TSP34KER changed the title llama: fix compilation warning (#323) llama: fix compilation warning (#464) Jun 16, 2025
@CISC
Copy link
Collaborator

CISC commented Jun 16, 2025

What compilation warning?

@L33TSP34KER
Copy link
Author

[ 20%] Building CXX object src/CMakeFiles/llama.dir/llama-quant.cpp.o
/home/morgan/github/llama.cpp/src/llama-quant.cpp:589:66: warning: absolute value function 'abs' given an argument of type 'const int64_t' (aka 'const long') but has parameter of type 'int' w
hich may cause truncation of value [-Wabsolute-value]
  589 |                 gguf_set_val_u32(ctx_out.get(), o.key, (uint32_t)abs(o.val_i64));
      |                                                                  ^
/home/morgan/github/llama.cpp/src/llama-quant.cpp:589:66: note: use function 'std::abs' instead
  589 |                 gguf_set_val_u32(ctx_out.get(), o.key, (uint32_t)abs(o.val_i64));
      |                                                                  ^~~
      |                                                                  std::abs
1 warning generated.

@CISC
Copy link
Collaborator

CISC commented Jun 16, 2025

What platform/compiler is this?

@L33TSP34KER
Copy link
Author

i'm on gentoo

clang version 20.1.4
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm/20/bin
Configuration file: /etc/clang/20/x86_64-pc-linux-gnu-clang.cfg
System configuration file directory: /etc/clang/20
User configuration file directory: /home/morgan/.config/clang
Selected GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/14
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
 "/usr/bin/x86_64-pc-linux-gnu-ld.bfd" --hash-style=gnu --eh-frame-hdr -m elf_x86_64 -pie -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o a.out /usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../lib64/Scrt1.o /usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../lib64/crti.o /usr/lib/gcc/x86_64-pc-linux-gnu/14/crtbeginS.o -L/usr/lib/gcc/x86_64-pc-linux-gnu/14 -L/usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../x86_64-pc-linux-gnu/lib -L/lib -L/usr/lib -z relro -z now -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-pc-linux-gnu/14/crtendS.o /usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../lib64/crtn.o
/usr/bin/x86_64-pc-linux-gnu-ld.bfd: /usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../lib64/Scrt1.o: in function `_start':
(.text+0x1b): undefined reference to `main'
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/14/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-pc-linux-gnu
Configured with: /var/tmp/portage/sys-devel/gcc-14.2.1_p20241221/work/gcc-14-20241221/configure --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/14 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/14/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/14 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/14/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/14/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/14/include/g++-v14 --disable-silent-rules --disable-dependency-tracking --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/14/python --enable-languages=c,c++,fortran --enable-obsolete --enable-secureplt --disable-werror --with-system-zlib --enable-nls --without-included-gettext --disable-libunwind-exceptions --enable-checking=release --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo 14.2.1_p20241221 p7' --with-gcc-major-version-only --enable-libstdcxx-time --enable-lto --disable-libstdcxx-pch --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-multilib --with-multilib-list=m32,m64 --disable-fixed-point --enable-targets=all --enable-offload-defaulted --enable-offload-targets=nvptx-none --enable-libgomp --disable-libssp --disable-libada --enable-cet --disable-systemtap --disable-valgrind-annotations --disable-vtable-verify --disable-libvtv --with-zstd --without-isl --enable-default-pie --enable-host-pie --enable-host-bind-now --enable-default-ssp --disable-fixincludes
--with-build-config=bootstrap-cet
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.2.1 20241221 (Gentoo 14.2.1_p20241221 p7)
Linux gentoo 6.14.6-gentoo-dist #1 SMP PREEMPT_DYNAMIC Fri May  9 13:27:26 -00 2025 x86_64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz GenuineIntel GNU/Linux

@CISC
Copy link
Collaborator

CISC commented Jun 16, 2025

Very strange.

None of our CIs generate this warning, and I can't reproduce, either way I don't think your suggestion is correct. Would be nice to know why you get the warning though...

@L33TSP34KER
Copy link
Author

After reclaiming and rebuilding, it still happens.
It might be because I'm using LLVM stuff. It usually gives more warnings.

@CISC
Copy link
Collaborator

CISC commented Jun 17, 2025

After reclaiming and rebuilding, it still happens. It might be because I'm using LLVM stuff. It usually gives more warnings.

But it's incorrect, the cmath abs function should be overloaded to the correct type, so something seems to be wrong in your env.

@kaetemi
Copy link
Contributor

kaetemi commented Aug 18, 2025

Same warning reproduces here on Ubuntu 22.04 LTS, but PR seems incorrect.

Just need to replace abs with std::abs and nothing else. :)

Based on the C++ standard, the global namespace is implementation defined when the C++ style <c___> headers are included, and may or may not mirror the standard functions from the std:: namespace, which means the overloads or any and all the functions may be missing in the global namespace, and only the std:: namespace is required to be declared.

@CISC
Copy link
Collaborator

CISC commented Aug 18, 2025

Just need to replace abs with std::abs and nothing else. :)

Please make a new PR as this one is immutable.

@CISC
Copy link
Collaborator

CISC commented Oct 30, 2025

#16853

@CISC CISC closed this Oct 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants