Last Comment Bug 303169 - link error with gcc on Solaris Sparc in debug mode
: link error with gcc on Solaris Sparc in debug mode
Status: RESOLVED FIXED
:
Product: NSPR
Classification: Components
Component: NSPR (show other bugs)
: 4.6
: Sun Solaris
: P2 normal (vote)
: 4.6.1
Assigned To: Wan-Teh Chang
: Wan-Teh Chang
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2005-08-02 17:20 PDT by Julien Pierre
Modified: 2005-08-08 22:01 PDT (History)
1 user (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---


Attachments
Proposed workaround (1.53 KB, patch)
2005-08-03 18:50 PDT, Wan-Teh Chang
julien.pierre: review+
Details | Diff | Splinter Review

Description Julien Pierre 2005-08-02 17:20:25 PDT
When setting NS_USE_GCC to 1 and not setting BUILD_OPT, and doing a "gmake
build_nspr" from mozilla/security/nss, I get the following link error :

rm -f libnspr4.so
gcc -shared -Wl,-h,libnspr4.so,-z,combreloc,-z,defs
-Wl,-f,\$ORIGIN/cpu/\$ISALIST/libnspr_flt4.so -o libnspr4.so
-Wl,-M,./nsprmap.sun ./prvrsion.o io/./prfdcach.o io/./prmwait.o io/./prmapopt.o
io/./priometh.o io/./pripv6.o io/./prlayer.o io/./prlog.o io/./prmmap.o
io/./prpolevt.o io/./prprf.o io/./prscanf.o io/./prstdio.o threads/./prcmon.o
threads/./prrwlock.o threads/./prtpd.o linking/./prlink.o malloc/./prmem.o
md/./prosdep.o memory/./prshm.o memory/./prshma.o memory/./prseg.o
misc/./pralarm.o misc/./pratom.o misc/./prcountr.o misc/./prdtoa.o
misc/./prenv.o misc/./prerr.o misc/./prerror.o misc/./prerrortable.o
misc/./prinit.o misc/./prinrval.o misc/./pripc.o misc/./prlog2.o misc/./prlong.o
misc/./prnetdb.o misc/./prolock.o misc/./prrng.o misc/./prsystem.o
misc/./prthinfo.o misc/./prtpool.o misc/./prtrace.o misc/./prtime.o
malloc/./prmalloc.o pthreads/./ptsynch.o pthreads/./ptio.o pthreads/./ptthread.o
pthreads/./ptmisc.o md/unix/./unix.o md/unix/./unix_errors.o
md/unix/./uxproces.o md/unix/./uxrng.o md/unix/./uxshm.o md/unix/./uxwrap.o
md/unix/./solaris.o md/unix/./os_SunOS.o -lpthread -lthread -lposix4 -lsocket
-lnsl -ldl -lc
ld: fatal: relocation error: R_SPARC_32: file md/unix/./os_SunOS.o: symbol
<unknown>: offset 0xfe6b6c02 is non-aligned
ld: fatal: relocation error: R_SPARC_32: file md/unix/./os_SunOS.o: symbol
<unknown>: offset 0xfe6e4d26 is non-aligned
collect2: ld returned 1 exit status
gmake[3]: *** [libnspr4.so] Error 1
gmake[3]: Leaving directory
`/h/monstre/export/home/nss/newtip/mozilla/nsprpub/SunOS5.10_gcc_DBG.OBJ/pr/src'
gmake[2]: *** [export] Error 2
gmake[2]: Leaving directory
`/h/monstre/export/home/nss/newtip/mozilla/nsprpub/SunOS5.10_gcc_DBG.OBJ/pr'
gmake[1]: *** [export] Error 2
gmake[1]: Leaving directory
`/h/monstre/export/home/nss/newtip/mozilla/nsprpub/SunOS5.10_gcc_DBG.OBJ'
gmake: *** [build_nspr] Error 2

And with USE_64 set to 1 :

gcc -m64 -shared -Wl,-h,libnspr4.so,-z,combreloc,-z,defs -o libnspr4.so
-Wl,-M,./nsprmap.sun ./prvrsion.o io/./prfdcach.o io/./prmwait.o io/./prmapopt.o
io/./priometh.o io/./pripv6.o io/./prlayer.o io/./prlog.o io/./prmmap.o
io/./prpolevt.o io/./prprf.o io/./prscanf.o io/./prstdio.o threads/./prcmon.o
threads/./prrwlock.o threads/./prtpd.o linking/./prlink.o malloc/./prmem.o
md/./prosdep.o memory/./prshm.o memory/./prshma.o memory/./prseg.o
misc/./pralarm.o misc/./pratom.o misc/./prcountr.o misc/./prdtoa.o
misc/./prenv.o misc/./prerr.o misc/./prerror.o misc/./prerrortable.o
misc/./prinit.o misc/./prinrval.o misc/./pripc.o misc/./prlog2.o misc/./prlong.o
misc/./prnetdb.o misc/./prolock.o misc/./prrng.o misc/./prsystem.o
misc/./prthinfo.o misc/./prtpool.o misc/./prtrace.o misc/./prtime.o
malloc/./prmalloc.o pthreads/./ptsynch.o pthreads/./ptio.o pthreads/./ptthread.o
pthreads/./ptmisc.o md/unix/./unix.o md/unix/./unix_errors.o
md/unix/./uxproces.o md/unix/./uxrng.o md/unix/./uxshm.o md/unix/./uxwrap.o
md/unix/./solaris.o md/unix/./os_SunOS.o md/unix/./os_SunOS_sparcv9.o  -lpthread
-lthread -lposix4 -lsocket -lnsl -ldl -lc
ld: fatal: relocation error: R_SPARC_32: file md/unix/./os_SunOS.o: symbol
<unknown>: offset 0xffffffff790c6bc2 is non-aligned
ld: fatal: relocation error: R_SPARC_64: file md/unix/./os_SunOS.o: symbol
<unknown>: offset 0xffffffff790c6bcc is non-aligned
ld: fatal: relocation error: R_SPARC_64: file md/unix/./os_SunOS.o: symbol
<unknown>: offset 0xffffffff790c6bd4 is non-aligned
ld: fatal: relocation error: R_SPARC_64: file md/unix/./os_SunOS.o: symbol
<unknown>: offset 0xffffffff790f656e is non-aligned
ld: fatal: relocation error: R_SPARC_32: file md/unix/./os_SunOS.o: symbol
<unknown>: offset 0xffffffff79101cc6 is non-aligned
collect2: ld returned 1 exit status
gmake[3]: *** [libnspr4.so] Error 1
gmake[3]: Leaving directory
`/h/monstre/export/home/nss/pkix/mozilla/nsprpub/SunOS5.10_gcc_64_DBG.OBJ/pr/src'
gmake[2]: *** [export] Error 2
gmake[2]: Leaving directory
`/h/monstre/export/home/nss/pkix/mozilla/nsprpub/SunOS5.10_gcc_64_DBG.OBJ/pr'
gmake[1]: *** [export] Error 2
gmake[1]: Leaving directory
`/h/monstre/export/home/nss/pkix/mozilla/nsprpub/SunOS5.10_gcc_64_DBG.OBJ'
gmake: *** [build_nspr] Error 2

Interestingly, these errors don't appear when setting BUILD_OPT to 1, which
makes me think this may be related to debug flags in some way.
Comment 1 Wan-Teh Chang 2005-08-02 17:30:41 PDT
I remember running into this problem before when I built
NSPR with gcc on Solaris 10.  I am surprised that you didn't
do NSPR debug builds with gcc until now :-)

My workaround was to not assemble os_SunOS.s.  There is nothing
we need in that file.
Comment 2 Julien Pierre 2005-08-02 17:41:57 PDT
Wan-Teh,

I had done NSPR builds with gcc before, just not debug builds, so I never ran
into this problem ;)

If we don't need os_SunOS.s at all, can we just remove it from CVS and
configure/configure.in ? Or is it needed in some cases but not others ?

Comment 3 Julien Pierre 2005-08-02 20:23:57 PDT
I removed os_SunOS.s from configure and configure.in, and built all 8 possible
combinations on sparc - OPT/DBG * 32/64 * gcc/studio .  All builds were successful.

I gather that this file is only needed for the legacy pre-POSIX "Solaris
threads" implementation. Am I correct this dead code, as is md/unix/solaris.c ?

My recommendation is that we drop it as well as os_SunOS.s, and remove the
reference to this from configure/configure.in .
Comment 4 Wan-Teh Chang 2005-08-03 17:32:35 PDT
Among the functions defined in os_SunOS.s, only
sol_curthread is used, and it is only used by the
"_PR_GLOBAL_THREADS_ONLY" configuration.

Please try the follwing change in
mozilla/nsprpub/configure.in and configure:

from

    PR_MD_ASFILES=os_SunOS.s

to

    if test -n "$USE_NATIVE_THREADS"; then
        PR_MD_ASFILES=os_SunOS.s
    fi
Comment 5 Julien Pierre 2005-08-03 17:38:11 PDT
Wan-Teh,

I just checked and these changes worked.
Comment 6 Wan-Teh Chang 2005-08-03 18:50:30 PDT
Created attachment 191556 [details] [diff] [review]
Proposed workaround

Please review and test this patch with 32-bit and 64-bit
SPARC debug builds.  No need to test AMD64 or x86 builds
or optimized builds.

I list os_SunOS_sparcv9.so before os_SunOS.s to imply that
os_SunOS_sparcv9.so is more important.
Comment 7 Julien Pierre 2005-08-03 19:01:06 PDT
Comment on attachment 191556 [details] [diff] [review]
Proposed workaround

All 8 builds on Solaris sparc worked with these changes.
Comment 8 Wan-Teh Chang 2005-08-03 19:05:52 PDT
Thanks.  I checked in the patch on the NSPR trunk for NSPR 4.6.1.

Checking in configure;
/cvsroot/mozilla/nsprpub/configure,v  <--  configure
new revision: 1.192; previous revision: 1.191
done
Checking in configure.in;
/cvsroot/mozilla/nsprpub/configure.in,v  <--  configure.in
new revision: 1.194; previous revision: 1.193
done

Note You need to log in before you can comment on or make changes to this bug.