Home
Solus
Search
Configure Global Search
Log In
Transactions
T7561
Change Details
Change Details
Old
New
Diff
I tried to use `clang` as the compiler to build a C++ extension library for python. It failed with the following error message: ``` ld.lld: error: unknown argument: --copy-dt-needed-entries ld.lld: error: unknown argument: --copy-dt-needed-entries clang-7: error: linker command failed with exit code 1 (use -v to see invocation) error: command 'clang++' failed with exit status 1 ``` This behavior can be easily reproduced with the following setup: Create a cpp file named `demo.cpp` with the following content: ```cpp // demo.cpp #include <stdio.h> int main() { return 0; } ``` In the same directory, create `setup.py` with the following content: ```python from distutils.core import setup, Extension module1 = Extension('demo', sources = ['demo.cpp']) setup (name = 'PackageName', version = '1.0', description = 'This is a demo package', ext_modules = [module1]) ``` Then build the extension with the following command: ``` CC=clang CXX=clang++ python3 setup.py build ``` The output on my laptop is as follows: ``` running build running build_ext building 'demo' extension creating build creating build/temp.linux-x86_64-3.6 clang -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -mtune=generic -march=x86-64 -g2 -O2 -pipe -fPIC -Wformat -Wformat-security -D_FORTIFY_SOURCE=2 -fstack-protector-strong --param ssp-buffer-size=32 -fasynchronous-unwind-tables -ftree-vectorize -feliminate-unused-debug-types -Wall -Wno-error -Wp,-D_REENTRANT -I/usr/include -mtune=generic -march=x86-64 -g2 -O2 -pipe -fPIC -Wformat -Wformat-security -D_FORTIFY_SOURCE=2 -fstack-protector-strong --param ssp-buffer-size=32 -fasynchronous-unwind-tables -ftree-vectorize -feliminate-unused-debug-types -Wall -Wno-error -Wp,-D_REENTRANT -fPIC -I/usr/include/python3.6m -c demo.cpp -o build/temp.linux-x86_64-3.6/demo.o creating build/lib.linux-x86_64-3.6 clang++ -pthread -shared -Wl,--copy-dt-needed-entries -Wl,-O1 -Wl,-z,relro -Wl,-z,now -Wl,-z,max-page-size=0x1000 -Wl,-Bsymbolic-functions -Wl,--copy-dt-needed-entries -Wl,-O1 -Wl,-z,relro -Wl,-z,now -Wl,-z,max-page-size=0x1000 -Wl,-Bsymbolic-functions build/temp.linux-x86_64-3.6/demo.o -L/usr/lib64 -lpython3.6m -o build/lib.linux-x86_64-3.6/demo.cpython-36m-x86_64-linux-gnu.so ld.lld: error: unknown argument: --copy-dt-needed-entries ld.lld: error: unknown argument: --copy-dt-needed-entries clang-7: error: linker command failed with exit code 1 (use -v to see invocation) error: command 'clang++' failed with exit status 1 ``` I spent some time understanding what could cause the issue. It seems that this is because the flag `--copy-dt-needed-entries` was used when we compile `python` and `python3` package on Solus. When `setuptools` compile C and C++ extensions, this flag is carried over.
I tried to use `clang` as the compiler to build a C++ extension library for python. It failed with the following error message: ``` ld.lld: error: unknown argument: --copy-dt-needed-entries ld.lld: error: unknown argument: --copy-dt-needed-entries clang-7: error: linker command failed with exit code 1 (use -v to see invocation) error: command 'clang++' failed with exit status 1 ``` This behavior can be easily reproduced with the following setup: Create a cpp file named `demo.cpp` with the following content: ``` // demo.cpp #include <stdio.h> int main() { return 0; } ``` In the same directory, create `setup.py` with the following content: ``` from distutils.core import setup, Extension module1 = Extension('demo', sources = ['demo.cpp']) setup (name = 'PackageName', version = '1.0', description = 'This is a demo package', ext_modules = [module1]) ``` Then build the extension with the following command: ``` CC=clang CXX=clang++ python3 setup.py build ``` The output on my laptop is as follows: ``` running build running build_ext building 'demo' extension creating build creating build/temp.linux-x86_64-3.6 clang -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -mtune=generic -march=x86-64 -g2 -O2 -pipe -fPIC -Wformat -Wformat-security -D_FORTIFY_SOURCE=2 -fstack-protector-strong --param ssp-buffer-size=32 -fasynchronous-unwind-tables -ftree-vectorize -feliminate-unused-debug-types -Wall -Wno-error -Wp,-D_REENTRANT -I/usr/include -mtune=generic -march=x86-64 -g2 -O2 -pipe -fPIC -Wformat -Wformat-security -D_FORTIFY_SOURCE=2 -fstack-protector-strong --param ssp-buffer-size=32 -fasynchronous-unwind-tables -ftree-vectorize -feliminate-unused-debug-types -Wall -Wno-error -Wp,-D_REENTRANT -fPIC -I/usr/include/python3.6m -c demo.cpp -o build/temp.linux-x86_64-3.6/demo.o creating build/lib.linux-x86_64-3.6 clang++ -pthread -shared -Wl,--copy-dt-needed-entries -Wl,-O1 -Wl,-z,relro -Wl,-z,now -Wl,-z,max-page-size=0x1000 -Wl,-Bsymbolic-functions -Wl,--copy-dt-needed-entries -Wl,-O1 -Wl,-z,relro -Wl,-z,now -Wl,-z,max-page-size=0x1000 -Wl,-Bsymbolic-functions build/temp.linux-x86_64-3.6/demo.o -L/usr/lib64 -lpython3.6m -o build/lib.linux-x86_64-3.6/demo.cpython-36m-x86_64-linux-gnu.so ld.lld: error: unknown argument: --copy-dt-needed-entries ld.lld: error: unknown argument: --copy-dt-needed-entries clang-7: error: linker command failed with exit code 1 (use -v to see invocation) error: command 'clang++' failed with exit status 1 ``` I spent some time understanding what could cause the issue. It seems that this is because the flag `--copy-dt-needed-entries` was used when we compile `python` and `python3` package on Solus. When `setuptools` compile C and C++ extensions, this flag is carried over.
I tried to use `clang` as the compiler to build a C++ extension library for python. It failed with the following error message: ``` ld.lld: error: unknown argument: --copy-dt-needed-entries ld.lld: error: unknown argument: --copy-dt-needed-entries clang-7: error: linker command failed with exit code 1 (use -v to see invocation) error: command 'clang++' failed with exit status 1 ``` This behavior can be easily reproduced with the following setup: Create a cpp file named `demo.cpp` with the following content: ```
cpp
// demo.cpp #include <stdio.h> int main() { return 0; } ``` In the same directory, create `setup.py` with the following content: ```
python
from distutils.core import setup, Extension module1 = Extension('demo', sources = ['demo.cpp']) setup (name = 'PackageName', version = '1.0', description = 'This is a demo package', ext_modules = [module1]) ``` Then build the extension with the following command: ``` CC=clang CXX=clang++ python3 setup.py build ``` The output on my laptop is as follows: ``` running build running build_ext building 'demo' extension creating build creating build/temp.linux-x86_64-3.6 clang -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -mtune=generic -march=x86-64 -g2 -O2 -pipe -fPIC -Wformat -Wformat-security -D_FORTIFY_SOURCE=2 -fstack-protector-strong --param ssp-buffer-size=32 -fasynchronous-unwind-tables -ftree-vectorize -feliminate-unused-debug-types -Wall -Wno-error -Wp,-D_REENTRANT -I/usr/include -mtune=generic -march=x86-64 -g2 -O2 -pipe -fPIC -Wformat -Wformat-security -D_FORTIFY_SOURCE=2 -fstack-protector-strong --param ssp-buffer-size=32 -fasynchronous-unwind-tables -ftree-vectorize -feliminate-unused-debug-types -Wall -Wno-error -Wp,-D_REENTRANT -fPIC -I/usr/include/python3.6m -c demo.cpp -o build/temp.linux-x86_64-3.6/demo.o creating build/lib.linux-x86_64-3.6 clang++ -pthread -shared -Wl,--copy-dt-needed-entries -Wl,-O1 -Wl,-z,relro -Wl,-z,now -Wl,-z,max-page-size=0x1000 -Wl,-Bsymbolic-functions -Wl,--copy-dt-needed-entries -Wl,-O1 -Wl,-z,relro -Wl,-z,now -Wl,-z,max-page-size=0x1000 -Wl,-Bsymbolic-functions build/temp.linux-x86_64-3.6/demo.o -L/usr/lib64 -lpython3.6m -o build/lib.linux-x86_64-3.6/demo.cpython-36m-x86_64-linux-gnu.so ld.lld: error: unknown argument: --copy-dt-needed-entries ld.lld: error: unknown argument: --copy-dt-needed-entries clang-7: error: linker command failed with exit code 1 (use -v to see invocation) error: command 'clang++' failed with exit status 1 ``` I spent some time understanding what could cause the issue. It seems that this is because the flag `--copy-dt-needed-entries` was used when we compile `python` and `python3` package on Solus. When `setuptools` compile C and C++ extensions, this flag is carried over.
Continue