Bug 10261 - Text relocation remains referenced
Text relocation remains referenced
Status: RESOLVED FIXED
Product: Samba 4.1 and newer
Classification: Unclassified
Component: Build
4.1.0
Sparc Solaris
: P5 normal
: ---
Assigned To: Björn Jacke
Samba QA Contact
:
Depends on: 11073
Blocks:
  Show dependency treegraph
 
Reported: 2013-11-11 14:22 UTC by Ralf Weinert
Modified: 2015-03-13 08:31 UTC (History)
2 users (show)

See Also:


Attachments
result of Make (1.07 KB, application/x-gzip)
2013-11-11 14:22 UTC, Ralf Weinert
no flags Details
Patch to correctly check for fvisibility=hidden (579 bytes, patch)
2014-09-11 17:44 UTC, Tom Schulz
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ralf Weinert 2013-11-11 14:22:31 UTC
Created attachment 9405 [details]
result of Make

Building  Samba 4.1.0 or Samba 4.1.1 always ends with an error when linking libpytalloc-util.so. A lot of text relocation are remaining. I add a compressed logfile with some examples. This problem exists on Solaris 5.8 and Solaris 5.10.  On Solaris 5.10 Python 2.7.5 is installed while on Solaris 5.8 exists Python 2.6.5.
Comment 1 Tom Schulz 2014-02-03 17:59:41 UTC
I ran into the same problem. The problem is caused by building Python
without specifying --enable-shared to configure. This causes Python
to be compiled without the PIC (position independent code) flag.
Code that is not PIC can not be linked into a shared library. I had to
delete the installed libpythin*.a library to properly rebuild Python.

After that I ran into a similar problem with Samba's included tdb and
ntdb. This is caused by specifying '-fvisibility=hidden' to the gcc
compiler or including '__attribute__((visibility("hidden")))' in the
source code when gcc is used. This causes the linker to be unable to
find and relocate symbols.

To work around the second problem I edited lib/replace/wscript to comment
out the code defining HAVE_VISIBILITY_ATTR as follows:

#    if conf.CHECK_CFLAGS('-fvisibility=hidden'):
#        conf.env.VISIBILITY_CFLAGS = '-fvisibility=hidden'
#        conf.CHECK_CODE('''void vis_foo1(void) {}
#                           __attribute__((visibility("default"))) void vis_foo2
(void) {}''',
#                        cflags=conf.env.VISIBILITY_CFLAGS,
#                        define='HAVE_VISIBILITY_ATTR')

Conclusions:
The Samba configure process should check for the existence of libpython*.a
without also finding libpython*.so and consider that a fatal error.
The Samba configure process should not define HAVE_VISIBILITY_ATTR on
a Solaris system.
Comment 2 Tom Schulz 2014-03-11 17:29:52 UTC
The test for -fvisibility=hidden on Solaris produces:

[1/1] Compiling test.c
../test.c: In function 'main':
../test.c:1:1: warning: visibility attribute not supported in this
configuration; ignored [-Wattributes]
['/opt/local/bin/gcc', '-I/opt/local/include', '-fvisibility=hidden', '-MD',
'-I/usr/local/include', '-D_SAMBA_BUILD_=4', '-DHAVE_CONFIG_H=1',
'-D_GNU_SOURCE=1', '-D_XOPEN_SOURCE_EXTENDED=1', '../test.c', '-c', '-o',
'default/test_1.o']
yes

But, despite the message saying ignored, the result can not be linked into a
shared library. Adding -Werror=attributes to the gcc command would turn this
into an error. So I tried editing lib/replace/wscript and changing

if conf.CHECK_CFLAGS('-fvisibility=hidden'):

to

if conf.CHECK_CFLAGS('-fvisibility=hidden -Werror=attributes')

but that passes -fvisibility=hidden -Werror=attributes as a single string which
causes gcc to mis-parse the command line. Perhaps someone who understands the
build system better than I do could see how to make this change.
Comment 3 Tom Schulz 2014-09-11 17:44:41 UTC
Created attachment 10283 [details]
Patch to correctly check for fvisibility=hidden

As mentioned above, when using gcc 4.7.2 on Solaris, -fvisibility=hidden causes gcc to issue the warning

warning: visibility attribute not supported in this configuration; ignored

but then it proceeds to produce object files that can not be linked. Patching lib/replace/wscript to change

if conf.CHECK_CFLAGS('-fvisibility=hidden'):
to
if conf.CHECK_CFLAGS(['-fvisibility=hidden', '-Werror=attributes']):

changes the warning to an error and causes configure to not configure -fvisibility=hidden. That fixes this part of the problem. Detecting an incorrectly built Python (see comment 1) remains to be done.
Comment 4 Tom Schulz 2014-09-17 17:37:10 UTC
Should I open a new bug about the -fvisibility=hidden gcc compiler problem so that this bug can be just about the incorrectly built Python library problem?

It looks like the way to detect an incorrectly built Python library would be to have the test program call a Python routine and then link the result as a shared library instead of an executable. You would then get an error if the Python library did not contain position independent code.

It looks to me that the current test is in
buildtools/wafadmin/Tools/config_c.py.
Comment 5 Ralf Weinert 2014-09-18 06:24:10 UTC
Hi,
there is no need to open a new bug. I got Python built and it works fine. Thanks and
Best regards,
Ralf 

-----Ursprüngliche Nachricht-----
Von: samba-bugs@samba.org [mailto:samba-bugs@samba.org] 
Gesendet: Mittwoch, 17. September 2014 19:37
An: Weinert, Ralf
Betreff: [Bug 10261] Text relocation remains referenced

https://bugzilla.samba.org/show_bug.cgi?id=10261

--- Comment #4 from Tom Schulz <schulz@adi.com> 2014-09-17 17:37:10 UTC --- Should I open a new bug about the -fvisibility=hidden gcc compiler problem so that this bug can be just about the incorrectly built Python library problem?

It looks like the way to detect an incorrectly built Python library would be to have the test program call a Python routine and then link the result as a shared library instead of an executable. You would then get an error if the Python library did not contain position independent code.

It looks to me that the current test is in buildtools/wafadmin/Tools/config_c.py.

--
Configure bugmail: https://bugzilla.samba.org/userprefs.cgi?tab=email
------- You are receiving this mail because: ------- You are on the CC list for the bug.
You reported the bug.
Comment 6 Tom Schulz 2015-01-05 18:48:55 UTC
By reporting the problem caused by -fvisibility=hidden in this bug, we ended up with two different bugs being reported in one bug report.The error messages are the same, but the causes are not really related.

I have now created Bug 11031 about the -fvisibility=hidden problem, so this bug can go back to just being about detecting an incorrectly built Python.
Comment 7 Stefan Metzmacher 2015-03-13 08:31:57 UTC
Fixed in bug #11073.