Bug 87209 - kdecore: -mimpure-text may be needed on Solaris w/ gcc 3.x and above
Summary: kdecore: -mimpure-text may be needed on Solaris w/ gcc 3.x and above
Status: RESOLVED NOT A BUG
Alias: None
Product: kde
Classification: I don't know
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Solaris
: NOR crash
Target Milestone: ---
Assignee: Thiago Macieira
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-08-14 17:53 UTC by Christopher Layne
Modified: 2005-02-13 02:52 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christopher Layne 2004-08-14 17:53:44 UTC
Version:            (using KDE KDE 3.3.0)
Installed from:    Compiled From Sources
Compiler:          gcc 3.4.1 Reading specs from /tools/stow/solx86/tool-static-gcc-3_4_1_20040807.RELEASE.i386.solaris.5_8/bin/../lib/gcc/i386-pc-solaris2.8/3.4.1/specs  Configured with: ./configure --prefix=/usr/local --enable-threads=posix --enable-languages=c,c++,f77,f95,objc : (reconfigured) ./configure --prefix=/usr/local --enable-threads=posix  Thread model: posix  gcc version 3.4.1  
OS:                Solaris

------- Additional Comment #4 From Christopher Layne 2004-08-13 18:13 ------- 
I don't see this as entirely fixed, as perhaps mine is unrelated. 
As such, I receive the same errors on both 3.3.0rc2 and CVS (from yesterday): 

build02-sol8-x86 :: ~/src/kde/kdelibs > uname -a 
SunOS build02-sol8-x86.dev.villa.tellme.com 5.8 Generic_108529-12 i86pc i386 i86pc 
build02-sol8-x86 :: ~/src/kde/kdelibs > gcc -v 
Reading specs from /tools/stow/solx86/tool-static-gcc-3_4_1_20040807.RELEASE.i386.solaris.5_8/bin/../lib/gcc/i386-pc-solaris2.8/3.4.1/specs 
Configured with: ./configure --prefix=/usr/local --enable-threads=posix --enable-languages=c,c++,f77,f95,objc : (reconfigured) ./configure --prefix=/usr/local --enable-threads=posix 
Thread model: posix 
gcc version 3.4.1 

build02-sol8-x86 :: ~/src/kde/kdelibs > ./configure --prefix=/usr/local/kde  &> configure.log 
build02-sol8-x86 :: ~/src/kde/kdelibs > make &> make.log 

[snippet] 
/bin/ksh ../libtool --silent --mode=link --tag=CXX g++   -Wnon-virtual-dtor -Wno-long-long -Wundef -Wall -W -Wpointer-arith -Wwrite-strings -O2 -fno-exceptions -fno-check-new -fno-common  -DQT_CLEAN_NAMESPACE -DQT_NO_ASCII_CAST -DQT_NO_STL -DQT_NO_COMPAT -DQT_NO_TRANSLATION    -o libkdecore.la -rpath /usr/local/kde/lib -L/usr/local/lib -R /usr/local/kde/lib -R /usr/local/lib -R /usr/local/X11R6/lib  -L/usr/local/X11R6/lib  -version-info 6:0:2 -no-undefined  libintl.lo kapplication.lo kdebug.lo  netwm.lo kconfigbase.lo kconfig.lo ksimpleconfig.lo  kconfigbackend.lo kmanagerselection.lo kdesktopfile.lo  kstandarddirs.lo ksock.lo kpty.lo kprocess.lo kprocctrl.lo  klocale.lo krfcdate.lo kiconeffect.lo kicontheme.lo  kiconloader.lo kwin.lo kwinmodule.lo krootprop.lo kcharsets.lo  kckey.lo kshortcut.lo kkeynative_x11.lo kkeyserver_x11.lo  kaccelaction.lo kshortcutmenu.lo kaccelbase.lo kaccel.lo  kglobalaccel_x11.lo kglobalaccel.lo kstdaccel.lo  kshortcutlist.lo kcrash.lo kurl.lo kregexp.lo kglobal.lo  kglobalsettings.lo kallocator.lo kvmallocator.lo  kmimesourcefactory.lo kinstance.lo kpalette.lo kipc.lo  klibloader.lo ktempfile.lo kuniqueapplication.lo  kaccelmanager.lo ksavefile.lo krandomsequence.lo  kstringhandler.lo kcompletion.lo kcmdlineargs.lo kaboutdata.lo  kcompletionbase.lo knotifyclient.lo kaudioplayer.lo  kdcoppropertyproxy.lo ksockaddr.lo kextsock.lo netsupp.lo  kprocio.lo kbufferedio.lo kpixmapprovider.lo kurldrag.lo  kmdcodec.lo ksocks.lo fakes.lo vsnprintf.lo ksycoca.lo  ksycocadict.lo ksycocafactory.lo kxmessages.lo kstartupinfo.lo  kcatalogue.lo kasyncio.lo kmultipledrag.lo kstaticdeleter.lo  kappdcopiface.lo kclipboard.lo kcheckaccelerators.lo  kdeversion.lo kdebugdcopiface.lo kcalendarsystem.lo  kcalendarsystemgregorian.lo kcalendarsystemhijri.lo  kcalendarsystemhebrew.lo kcalendarsystemfactory.lo  kmacroexpander.lo kidna.lo ktempdir.lo kshell.lo  kmountpoint.lo kcalendarsystemjalali.lo  kprotocolinfo_kdecore.lo kprotocolinfofactory.lo  kxerrorhandler.lo kuser.lo kconfigskeleton.lo  kconfigdialogmanager.lo klockfile.lo ksycoca_skel.lo kappdcopiface_skel.lo kdebugdcopiface_skel.lo malloc/libklmalloc.la network/libkdecorenetwork.la svgicons/libkdesvgicons.la ../dcop/libDCOP.la ../libltdl/libltdlc.la -lXext -lresolv  -L/usr/local/lib -lart_lgpl_2 -lm  ../kdefx/libkdefx.la 
Text relocation remains                         referenced 
    against symbol                  offset      in file 
KNetwork::Internal::initStandardWorkers()    0x43f      .libs/libkdecore.lax/libkdecorenetwork.a/kresolvermanager.o 
KNetwork::Internal::initStandardWorkers()    0x577      .libs/libkdecore.lax/libkdecorenetwork.a/kresolvermanager.o 
KNetwork::Internal::KResolverManager::manager()   0x49b         .libs/libkdecore.lax/libkdecorenetwork.a/kresolver.o 
KNetwork::Internal::KResolverManager::manager()   0x4e7         .libs/libkdecore.lax/libkdecorenetwork.a/kresolver.o 
KNetwork::Internal::KResolverManager::manager()   0x533         .libs/libkdecore.lax/libkdecorenetwork.a/kresolver.o 
KNetwork::Internal::KResolverManager::manager()   0x817         .libs/libkdecore.lax/libkdecorenetwork.a/kresolver.o 
KNetwork::Internal::KResolverManager::manager()   0x203a        .libs/libkdecore.lax/libkdecorenetwork.a/kresolver.o 
KNetwork::Internal::KResolverManager::manager()   0x2072        .libs/libkdecore.lax/libkdecorenetwork.a/kresolver.o 
KNetwork::Internal::KResolverManager::manager()   0x212c        .libs/libkdecore.lax/libkdecorenetwork.a/kresolver.o 
KNetwork::Internal::KResolverManager::manager()   0x299         .libs/libkdecore.lax/libkdecorenetwork.a/kresolverworkerbase.o 
KNetwork::Internal::KResolverManager::manager()   0x2cc         .libs/libkdecore.lax/libkdecorenetwork.a/kresolverworkerbase.o 
KNetwork::Internal::KResolverManager::manager()   0x41d         .libs/libkdecore.lax/libkdecorenetwork.a/kreverseresolver.o 
ld: fatal: relocations remain against allocatable but non-writable sections 
collect2: ld returned 1 exit status 
*** Error code 1 
make: Fatal error: Command failed for target `libkdecore.la' 
Current working directory /home/clayne/src/kde/kdelibs/kdecore 
*** Error code 1 
make: Fatal error: Command failed for target `all-recursive' 
Current working directory /home/clayne/src/kde/kdelibs/kdecore 
*** Error code 1 
make: Fatal error: Command failed for target `all-recursive' 
Current working directory /home/clayne/src/kde/kdelibs 
*** Error code 1 
make: Fatal error: Command failed for target `all' 
-- 


I have the updated kresolverstandardworkers.cpp: 

shell01 :: ~/src/kde/kdelibs > tail kdecore/network/kresolverstandardworkers.cpp       
  // register the workers in the order we want them to be tried 
  // note the no-resolving worker isn't registered. It's handled as a 
  // special case in KResolverManager::findWorker 

  KResolverWorkerFactoryBase::registerNewWorker(new KResolverWorkerFactory<KStandardWorker>); 

#ifdef HAVE_GETADDRINFO 
  KResolverWorkerFactoryBase::registerNewWorker(new KResolverWorkerFactory<KGetAddrinfoWorker>); 
#endif 
} 


I'll attach both configure.log and make.log as well. 


------- Additional Comment #5 From Christopher Layne 2004-08-13 18:16 ------- 
Created an attachment (id=7097) 
configure.log 


------- Additional Comment #6 From Christopher Layne 2004-08-13 18:17 ------- 
Created an attachment (id=7098) 
make.log 


------- Additional Comment #7 From Christopher Layne 2004-08-13 18:18 ------- 
BTW: buried in make.log: 

kresolverstandardworkers.cpp: In function `void KNetwork::Internal::initStandardWorkers()': 
kresolverstandardworkers.cpp:877: warning: visibility attribute not supported in this configuration; ignored 


------- Additional Comment #8 From Thiago Macieira 2004-08-13 19:17 ------- 
Hello Christopher, 

I cannot interpret the error message that you're getting. I don't know why the linker is complaining about "relocations remain against allocatable but non-wriable sections". 

Even if initStandardWorkers() is a problem, I don't see how that could influence KResolverManager::manager(). It's a simple, static function inside a class. 

As for the visibility problem, it's not an issue. It's there just to make the symbol disappear from the resulting libkdecore.so. 


------- Additional Comment #9 From Christopher Layne 2004-08-13 19:23 ------- 
Before chasing this down, let me do a couple rebuilds of binutils, glibc, and gcc; just to make sure. 


------- Additional Comment #10 From Christopher Layne 2004-08-13 19:25 ------- 
Thanks for the quick reply Thiago, I'll pursue and let you know what I figure out.. 

AFAIK, the visibility warning shouldn't cause a build failure, right? 


------- Additional Comment #11 From Christopher Layne 2004-08-13 19:35 ------- 
Okay, did some research. 

I'll try forcing -fPIC via -with-pic with configure. 

If that doesn't work, I'll examine the possibility of: 

`-mimpure-text' 
      `-mimpure-text', used in addition to `-shared', tells the compiler 
      to not pass `-z text' to the linker when linking a shared object. 
      Using this option, you can link position-dependent code into a 
      shared object. 
  
      `-mimpure-text' suppresses the "relocations remain against 
      allocatable but non-writable sections" linker error message. 
      However, the necessary relocations will trigger copy-on-write, and 
      the shared object is not actually shared across processes. 
      Instead of using `-mimpure-text', you should compile all source 
      code with `-fpic' or `-fPIC'. 
  
      This option is only available on SunOS and Solaris. 


------- Additional Comment #12 From Christopher Layne 2004-08-13 20:34 ------- 
Hmmm... 

--with-pic (configure flag): no change. 

-mimpure-text (gcc flag): "fixed" it, but I don't know why it was even required in the first place. Solaris 8 x86 is not exactly unexplored, and I would figure gcc 3.4.1 was fairly mapped out by now. 

BUT, I did upgrade binutils right before starting a kde build (I had built native gcc-3.4.1 on the machine and have been using it for a while). I'm going to regress to the previous version of binutils and see how another kdecore build goes. 


------- Additional Comment #13 From Christopher Layne 2004-08-13 21:35 ------- 
Well, after thinking about it, binutils shouldn't even make a difference as I'm using the Sol8 ld anyways. Regardless I, 

Downgraded binutils: no difference. 
Restored previous version and then disabled "--silent" in the libtool calls and verified -fPIC -DPIC were present, but also: no change. 

Linked *just* knetwork library with "-mimpure-text" and left the rest alone: no change. 

Linked knetwork normally (no special flags other then what was generated), but then specified -mimpure-text during kdecore library linking: This Fixed It (as mentioned before). 

But the weird thing is that the only other KDE bug I found that required -mimpure-text was this one from 2.2.2 in 2001: 

Bug 35809: dbsearengine module does not compile correctly without libtool modification. 

What I don't get is that the gcc man dictates: 

"      Instead of using `-mimpure-text', you should compile all source 
      code with `-fpic' or `-fPIC'. " 

Which we're using. 

Anyone else out there with sol8-x86, qt 3.3.2, and gcc 3.4.1? This is not present in only CVS releases, it's in 3.3.0RC2, as well. Something about knetwork lib is tripping it up - as no other sub libraries had issues. 


------- Additional Comment #14 From Christopher Layne 2004-08-13 21:49 ------- 
BTW: To developers, this may be useful. Diff's between gcc spec's involving -mimpure-text: 

build02-sol8-x86 :: ~ > diff specs.3.3.1 specs.3.4.1  | grep impure-text 
build02-sol8-x86 :: ~ > diff specs.2.95 specs.3.4.1 | grep impure-text 
< %{h*} %{v:-V}    %{b} %{Wl,*:%*}    %{static:-dn -Bstatic}   %{shared:-G -dy -z text}    %{symbolic:-Bsymbolic -G -dy -z text}    %{G:-G}    %{YP,*}    %{R*}    %{compat-bsd:      %{!YP,*:%{pg:-Y P,/usr/ucblib:/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib}      %{!pg:%{p:-Y P,/usr/ucblib:/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib}        %{!p:-Y P,/usr/ucblib:/usr/ccs/lib:/usr/lib}}}      -R /usr/ucblib}    %{!compat-bsd:      %{!YP,*:%{pg:-Y P,/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib}      %{!pg:%{p:-Y P,/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib}        %{!p:-Y P,/usr/ccs/lib:/usr/lib}}}}    %{Qy:} %{!Qn:-Qy} 
> %{h*} %{v:-V}    %{b} %{Wl,*:%*}    %{static:-dn -Bstatic}    %{shared:-G -dy %{!mimpure-text:-z text}}    %{symbolic:-Bsymbolic -G -dy -z text}    %(link_arch)    %{Qy:} %{!Qn:-Qy} 

-- 

No changes between 3.3.1 to 3.4.1, but definitely a change from 2.95 to 3.4.1 


------- Additional Comment #15 From Christopher Layne 2004-08-14 09:26 ------- 
Another one needing -mimpure-text on Solaris w/ gcc3: 

Text relocation remains                         referenced 
    against symbol                  offset      in file 
getValueName(unsigned short)        0x1640      .libs/libkhtml.lax/libkhtmlcss.a/css_valueimpl.o 
fastZoomSizeCount                   0xd7d       .libs/khtml_ext.o 
fastZoomSizeCount                   0x129c      .libs/khtml_ext.o 
fastZoomSizeCount                   0x12ca      .libs/khtml_ext.o 
fastZoomSizes                       0x14317     .libs/khtml_part.o 
fastZoomSizes                       0x143df     .libs/khtml_part.o 
fastZoomSizes                       0xdb2       .libs/khtml_ext.o 
fastZoomSizes                       0x12b1      .libs/khtml_ext.o 
getTagName(unsigned short)          0x52ac      .libs/libkhtml.lax/libkhtmlxml.a/dom_docimpl.o 
getTagName(unsigned short)          0x29a       .libs/libkhtml.lax/libkhtmlhtml.a/html_elementimpl.o 
getTagName(unsigned short)          0x420       .libs/libkhtml.lax/libkhtmlhtml.a/html_elementimpl.o 
getTagName(unsigned short)          0x21d4      .libs/libkhtml.lax/libkhtmlrender.a/render_object.o 
getTagName(unsigned short)          0x2f14      .libs/libkhtml.lax/libkhtmlrender.a/render_object.o 
getTagName(unsigned short)          0x12e1      .libs/libkhtml.lax/libkhtmlcss.a/css_base.o 
getAttrName(unsigned short)         0x5374      .libs/libkhtml.lax/libkhtmlxml.a/dom_docimpl.o 
getAttrName(unsigned short)         0x14c0      .libs/libkhtml.lax/libkhtmlcss.a/css_base.o 
DOM::getPropertyID(char const*, int)0x5e0       .libs/libkhtml.lax/libkjs_html.a/kjs_css.o 
DOM::getPropertyID(char const*, int)0x798       .libs/libkhtml.lax/libkjs_html.a/kjs_css.o 
DOM::getPropertyID(char const*, int)0xa238      .libs/libkhtml.lax/libkjs_html.a/kjs_css.o 
DOM::getPropertyID(char const*, int)0x71d       .libs/libkhtml.lax/libkhtmldom.a/html_element.o 
DOM::getPropertyID(char const*, int)0x859       .libs/libkhtml.lax/libkhtmldom.a/html_element.o 
DOM::getPropertyID(char const*, int)0x28d       .libs/libkhtml.lax/libkhtmldom.a/css_value.o 
DOM::getPropertyID(char const*, int)0x3c6       .libs/libkhtml.lax/libkhtmldom.a/css_value.o 
DOM::getPropertyID(char const*, int)0x4c1       .libs/libkhtml.lax/libkhtmldom.a/css_value.o 
DOM::getPropertyID(char const*, int)0x5a1       .libs/libkhtml.lax/libkhtmldom.a/css_value.o 
DOM::getPropertyID(char const*, int)0x6f0       .libs/libkhtml.lax/libkhtmldom.a/css_value.o 
getPropertyName(unsigned short)     0x935       .libs/libkhtml.lax/libkhtmlcss.a/css_valueimpl.o 
getPropertyName(unsigned short)     0x127e      .libs/libkhtml.lax/libkhtmlcss.a/css_valueimpl.o 
getPropertyName(unsigned short)     0x28ce      .libs/libkhtml.lax/libkhtmlcss.a/css_valueimpl.o 
ld: fatal: relocations remain against allocatable but non-writable sections 
collect2: ld returned 1 exit status 
make[1]: *** [libkhtml.la] Error 1 
make[1]: Leaving directory `/home/clayne/src/kde/kdelibs/khtml' 
make: *** [all-recursive] Error 1 


------- Additional Comment #16 From Thiago Macieira 2004-08-14 16:06 ------- 
Christopher, I believe you should open a new bug report. The one this bug was created for has now been fixed and is apparently not related to your problem.
Comment 1 Christopher Layne 2004-08-14 17:56:04 UTC
Thiago,

Opened (this one).
Comment 2 Christopher Layne 2004-08-16 06:13:02 UTC
1. "-fPIC" is the real solution.
2. "-z defs" and "-mimpure-text" are the next in line.

More information:

List:       kde-solaris
Subject:    Re: [kde-solaris] problems building 3.2.0
From:       Stefan Teleman <steleman () nyc ! rr ! com>
Date:       2004-02-07 5:45:21
Message-ID: <200402070045.21561.steleman () nyc ! rr ! com>
[Download message RAW]

You might want to check the Makefile as well, and if -z text is 
defined in there as well, replace it with -z defs. You might also 
have to do a gmake clean at the top of the khtml directory and then 
recompile/rebuild that entire directory from scratch.

You probably want to remove all '-z text' linker arguments from all 
the Makefiles, and from all the *.la files (this -z text has most 
likely been written to *.la files as well). -z text used to be the 
old SVR4 linker argument for disallowing undefined symbols in shared 
libraries, but the SunOS linker takes -z defs for that purpose.

find . -type f -name "Makefile" - print > ./MakefileList
foreach i ( `cat ./MakefileList` )
echo "Processing $i ... "
sed -e 's#-z text#-z defs#g' $i > /tmp/foo
cp -fp /tmp/foo $i
end

Yes, editing libtool before running gmake is the right thing to do.

The errors you are getting are not undefined symbols errors, they are 
text relocation errors. -z text causes fatal errors when text 
relocations remain in the shared object against non-writeable 
sections of the text segments.

Using the SunOS linker is the right thing to do on SunOS. :-)

Let me know.

--Stefan

-----

On Friday 06 February 2004 08:50, Rob Fisher wrote:
> > in libtool, replace ' -z text' with ' -z defs'.
>
> Thanks for responding Stefan, though I found making this change did
> not make any difference to my compilation problem. I still get the
> unresolved symbol problems I had before.
>
> I edited the libtool script generated by configure, in the
> kdelibs-3.2.0 directory before running gmake. Was that the right
> thing to do? If it's a linker problem, does it matter that I'm
> using Solaris's own ld rather than gnu ld?
>
> thanks
>
>
> Rob

-- 
Stefan Teleman          'Nobody Expects the Spanish Inquisition'
steleman@nyc.rr.com                          -Monty Python
Comment 3 Christopher Layne 2004-08-17 00:47:44 UTC
-z defs nor -z text make any difference.

-mimpure-text is the only thing I have found to get past these current linking issues on Solaris.
Comment 4 Thiago Macieira 2004-08-17 00:57:15 UTC
> The errors you are getting are not undefined symbols errors, they are
> text relocation errors. -z text causes fatal errors when text 
> relocations remain in the shared object against non-writeable 
> sections of the text segments.

Do you know why there are relocations remaining against non-writeable sections of the text segments in the first place? Could there be a gcc argument to make it not generate code that causes those relocations?
Comment 5 Thiago Macieira 2004-08-17 01:17:46 UTC
Remember when I said that the visibility flag shouldn't be causing the build failure? Well, I think it does.

Here's why: even though in the Solaris arch gcc is unable to tell the linker the visibility attribute for a symbol, it is generating code that is invalid.

So, I recommend you edit kdelibs/kdecore/kdemacros.h and change KDE_NO_EXPORT to nothing. See if that fixes the problem.

It does seem to me, however, that this is a gcc bug.
Comment 6 Christopher Layne 2004-08-17 05:40:54 UTC
AFAIK,

-fPIC

But that *is* happening. I verified with libtool in non-silent mode.

Everything in kdelibs/kdecore/network is compiled with -fPIC (it's automade anyways).

-cl

On Mon, Aug 16, 2004 at 10:57:16PM -0000, Thiago Macieira wrote:
> ------- You are receiving this mail because: -------
> You reported the bug, or are watching the reporter.
> You are on the CC list for the bug, or are watching someone who is.
>       
> http://bugs.kde.org/show_bug.cgi?id=87209      
> 
> 
> 
> 
> ------- Additional Comments From thiago.macieira kdemail net  2004-08-17 00:57 -------
> > The errors you are getting are not undefined symbols errors, they are
> > text relocation errors. -z text causes fatal errors when text 
> > relocations remain in the shared object against non-writeable 
> > sections of the text segments.
> 
> Do you know why there are relocations remaining against non-writeable sections of the text segments in the first place? Could there be a gcc argument to make it not generate code that causes those relocations?

Comment 7 Christopher Layne 2004-08-17 05:42:12 UTC
Will try changing KDE_NO_EXPORT and report back.

Comment 8 Christopher Layne 2004-08-17 06:07:36 UTC
Guess what..

Undef'ing KDE_NO_EXPORT allows kdecore to link without -mimpure-text.

So perhaps they changed something between 3.2.x and 3.4.x in regards to visibility? I'll check around...
Comment 9 Thiago Macieira 2005-02-13 02:52:20 UTC
Compiler problem. Sorry, we can't fix it on our end.