classification
Title: Build errors when using LDFLAGS="-Wl,--no-undefined"
Type: compile error Stage: resolved
Components: Build Versions: Python 2.6
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, fundawang, iritkatriel
Priority: normal Keywords:

Created on 2009-06-08 02:26 by fundawang, last changed 2020-11-15 23:25 by iritkatriel. This issue is now closed.

Files
File name Uploaded Description Edit
build.0.20090608003719.log.bz2 fundawang, 2009-06-08 02:26 detail build log
Messages (6)
msg89066 - (view) Author: Funda Wang (fundawang) Date: 2009-06-08 02:26
============================
gcc -pthread -Wl,--as-needed -Wl,--no-undefined -Wl,-z,relro -lstdc++ -
Xlinker -export-dynamic -o python \
                        Modules/python.o \
                        -L. -lpython2.6 -lpthread -ldl  -lutil   -lm
build/temp.linux-i686-2.6/home/fwang/rpm/BUILD/Python-2.6.2/Modules/
_ctypes/_ctypes_test.o: In function `my_sqrt':
/home/fwang/rpm/BUILD/Python-2.6.2/Modules/_ctypes/_ctypes_test.c:83: 
undefined reference to `sqrt'
collect2: ld returned 1 exit status
build/temp.linux-i686-2.6/home/fwang/rpm/BUILD/Python-2.6.2/Modules/
audioop.o: In function `audioop_rms':
/home/fwang/rpm/BUILD/Python-2.6.2/Modules/audioop.c:419: undefined 
reference to `sqrt'
collect2: ld returned 1 exit status
build/temp.linux-i686-2.6/home/fwang/rpm/BUILD/Python-2.6.2/Modules/
dlmodule.o: In function `dl_open':
/home/fwang/rpm/BUILD/Python-2.6.2/Modules/dlmodule.c:187: undefined 
reference to `dlopen'
/home/fwang/rpm/BUILD/Python-2.6.2/Modules/dlmodule.c:189: undefined 
reference to `dlerror'
build/temp.linux-i686-2.6/home/fwang/rpm/BUILD/Python-2.6.2/Modules/
dlmodule.o: In function `dl_close':
/home/fwang/rpm/BUILD/Python-2.6.2/Modules/dlmodule.c:49: undefined 
reference to `dlclose'
build/temp.linux-i686-2.6/home/fwang/rpm/BUILD/Python-2.6.2/Modules/
dlmodule.o: In function `dl_sym':
/home/fwang/rpm/BUILD/Python-2.6.2/Modules/dlmodule.c:68: undefined 
reference to `dlsym'
build/temp.linux-i686-2.6/home/fwang/rpm/BUILD/Python-2.6.2/Modules/
dlmodule.o: In function `dl_call':
/home/fwang/rpm/BUILD/Python-2.6.2/Modules/dlmodule.c:96: undefined 
reference to `dlsym'
/home/fwang/rpm/BUILD/Python-2.6.2/Modules/dlmodule.c:100: undefined 
reference to `dlerror'
build/temp.linux-i686-2.6/home/fwang/rpm/BUILD/Python-2.6.2/Modules/
dlmodule.o: In function `dl_dealloc':
/home/fwang/rpm/BUILD/Python-2.6.2/Modules/dlmodule.c:41: undefined 
reference to `dlclose'
collect2: ld returned 1 exit status

============================

build/temp.linux-i686-2.6/home/fwang/rpm/BUILD/Python-2.6.2/Modules/
_ctypes/_ctypes.o: In function `CDataType_in_dll':
/home/fwang/rpm/BUILD/Python-2.6.2/Modules/_ctypes/_ctypes.c:600: 
undefined reference to `dlsym'
/home/fwang/rpm/BUILD/Python-2.6.2/Modules/_ctypes/_ctypes.c:608: 
undefined reference to `dlerror'
build/temp.linux-i686-2.6/home/fwang/rpm/BUILD/Python-2.6.2/Modules/
_ctypes/_ctypes.o: In function `CFuncPtr_FromDll':
/home/fwang/rpm/BUILD/Python-2.6.2/Modules/_ctypes/_ctypes.c:3285: 
undefined reference to `dlsym'
/home/fwang/rpm/BUILD/Python-2.6.2/Modules/_ctypes/_ctypes.c:3293: 
undefined reference to `dlerror'
/usr/bin/ld: Dwarf Error: Offset (2614) greater than or equal 
to .debug_str size (815).
build/temp.linux-i686-2.6/home/fwang/rpm/BUILD/Python-2.6.2/Modules/
_ctypes/callproc.o: In function `py_dl_sym':
/home/fwang/rpm/BUILD/Python-2.6.2/Modules/_ctypes/callproc.c:1448: 
undefined reference to `dlsym'
/home/fwang/rpm/BUILD/Python-2.6.2/Modules/_ctypes/callproc.c:1451: 
undefined reference to `dlerror'
build/temp.linux-i686-2.6/home/fwang/rpm/BUILD/Python-2.6.2/Modules/
_ctypes/callproc.o: In function `py_dl_close':
/home/fwang/rpm/BUILD/Python-2.6.2/Modules/_ctypes/callproc.c:1430: 
undefined reference to `dlclose'
/home/fwang/rpm/BUILD/Python-2.6.2/Modules/_ctypes/callproc.c:1432: 
undefined reference to `dlerror'
build/temp.linux-i686-2.6/home/fwang/rpm/BUILD/Python-2.6.2/Modules/
_ctypes/callproc.o: In function `py_dl_open':
/home/fwang/rpm/BUILD/Python-2.6.2/Modules/_ctypes/callproc.c:1412: 
undefined reference to `dlopen'
/home/fwang/rpm/BUILD/Python-2.6.2/Modules/_ctypes/callproc.c:1414: 
undefined reference to `dlerror'
collect2: ld returned 1 exit status

============================


Failed to find the necessary bits to build these modules:
bsddb185           sunaudiodev
To find the necessary bits, look in setup.py in detect_modules() for 
the module's name.


Failed to build these modules:
_ctypes            _ctypes_test       audioop
dl

============================

I've attached the detail build log.
msg89278 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2009-06-12 13:42
I can't reproduce it, even after adding "-Wl,--as-needed". Did you
activate --enable-shared?

I suppose it would do no harm to add the libraries
"-lm" to _ctypes_test and audioop,
and "-ldl" to _ctypes and dl modules,
even if they are not needed in the standard case.
msg89281 - (view) Author: Funda Wang (fundawang) Date: 2009-06-12 15:40
Regarding python binary target, the actual command when linking is:
gcc -pthread -Wl,--as-needed -Wl,--no-undefined -Wl,-z,relro -lstdc++ -
Xlinker -export-dynamic -o python \
Modules/python.o \
-LL. -lpython2.6 -lpthread -ldl  -lutil   -lm

The linking order is wrong. "-lstdc++" is LIBADD, it should appear 
after OBJECTS such as Modules/python.o. The same applies to -pthread.

The command should looks like:
gcc -Wl,--as-needed -Wl,--no-undefined -Wl,-z,relro -Xlinker -export-
dynamic -o python \
Modules/python.o \
-LL. -lpython2.6 -lpthread -ldl  -lutil   -lm  -lstdc++
msg89776 - (view) Author: Funda Wang (fundawang) Date: 2009-06-28 16:18
How is this issue going?
msg189600 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2013-05-19 15:23
Is this build issue still a problem some four years on?
msg381045 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2020-11-15 23:25
Closing as out of date because it's from 14 years ago and the OP did not reply to Mark's ping. 

If this is an issue in Python 3 please open a new issue for that.
History
Date User Action Args
2020-11-15 23:25:28iritkatrielsetstatus: open -> closed

nosy: + iritkatriel
messages: + msg381045

resolution: out of date
stage: resolved
2014-02-03 18:29:12BreamoreBoysetnosy: - BreamoreBoy
2013-05-19 15:23:24BreamoreBoysetnosy: + BreamoreBoy
messages: + msg189600
2009-06-28 16:18:57fundawangsetmessages: + msg89776
2009-06-12 15:40:37fundawangsetmessages: + msg89281
2009-06-12 13:42:05amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg89278
2009-06-08 02:26:49fundawangcreate