OpenNMT / CTranslate2

Fast inference engine for Transformer models
https://opennmt.net/CTranslate2
MIT License
3.15k stars 277 forks source link

Clang unusual switches wrongly hardcoded in resulting setup.py #1704

Open Manamama opened 3 months ago

Manamama commented 3 months ago

After compiling manually (cmake and make with many switches and changes to CmakeList.txt file), Python kvetches that:

clang++: error: unknown argument: '-fno-openmp-implicit-rpath'                                              clang++: error: unknown argument: '-fno-openmp-implicit-rpath'                                          error: command '/data/data/com.termux/files/usr/bin/clang++' failed with exit code 1                error: subprocess-exited-with-error

amd:

clang++: error: unknown argument: '-fno-openmp-implicit-rpath'

Grep shows it hardcoded:

~/.../CTranslate2/python $ grep visibility . -r      ./setup.py:cflags = ["-std=c++17", "-fvisibility=hidden"]

...
~/.../CTranslate2/python $ grep rpath . -r           ./setup.py:    ldflags.append("-Wl,-rpath,/usr/local/lib")                                                ~/.../CTranslate2/python $

so we must trim it to: ./setup.py:cflags = ["-std=c++17"] etc.

-> Do change.

With fixes:

~/.../CTranslate2/python $ pip install -v .          Using pip 24.0 from /data/data/com.termux/files/usr/lib/python3.11/site-packages/pip (python 3.11)
...
clang -DNDEBUG -g -fwrapv -O3 -Wall -fstack-protector-strong -O3 -fstack-protector-strong -O3 -fuse-ld=lld -pthread -g -march=armv8-a -mtune=cortex-a53 -Wall -Wextra -fPIC -I/data/data/com.termux/files/usr/lib/python3.11/site-packages/pybind11/include -I/data/data/com.termux/files/usr/include/python3.11 -c cpp/mpi.cc -o build/temp.linux-aarch64-cpython-311/cpp/mpi.o -std=c++17
...

etc and installs.

My box: Compiler:

Python Environment:

minhthuc2502 commented 2 months ago

Not sure what your problem is and how to reproduce this. Please explain more clearly.

Manamama commented 2 months ago

(On mobile, so pithy.) As I have found the same error: -fno-openmp-implicit-rpath in also another package, I have spent half an hour since then asking Ms Perplexity AI about root cause. In short, quoth she:

The clang 17.0.2 in NDK supports fopenmp-implicit-rpath option but clang 18.1.5 in termux-packages does not support that, so (here a Python script to change smth in pychache follows, which works for all such cases).

In very short: it may be specific to that config above, and yet removing this (hard-coded) switch may help all.

Manamama commented 2 months ago

Seemingly solved since by Python upgrade itself, see: https://github.com/termux/termux-packages/issues/20714