link error with gcc on Solaris Sparc in debug mode

RESOLVED FIXED in 4.6.1

Status

NSPR
NSPR
P2
normal
RESOLVED FIXED
12 years ago
12 years ago

People

(Reporter: Julien Pierre, Assigned: Wan-Teh Chang)

Tracking

4.6.1
Sun
Solaris

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

12 years ago
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.
(Assignee)

Comment 1

12 years ago
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.
(Reporter)

Comment 2

12 years ago
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 ?

(Reporter)

Comment 3

12 years ago
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 .
(Reporter)

Updated

12 years ago
Priority: -- → P2
Target Milestone: --- → 4.6.1
(Assignee)

Comment 4

12 years ago
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
Status: NEW → ASSIGNED
(Reporter)

Comment 5

12 years ago
Wan-Teh,

I just checked and these changes worked.
Summary: link error with gcc on Solaris in debug mode → link error with gcc on Solaris Sparc in debug mode
(Assignee)

Comment 6

12 years ago
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.
Attachment #191556 - Flags: review?(julien.pierre.bugs)
(Reporter)

Comment 7

12 years ago
Comment on attachment 191556 [details] [diff] [review]
Proposed workaround

All 8 builds on Solaris sparc worked with these changes.
Attachment #191556 - Flags: review?(julien.pierre.bugs) → review+
(Assignee)

Comment 8

12 years ago
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
Status: ASSIGNED → RESOLVED
Last Resolved: 12 years ago
OS: SunOS → Solaris
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.