Closed Bug 323196 Opened 19 years ago Closed 15 years ago

NSS 3.11 does not build on RHEL21

Categories

(NSS :: Build, defect, P2)

3.11
x86
Linux
defect

Tracking

(Not tracked)

RESOLVED FIXED
3.11.1

People

(Reporter: christophe.ravel.bugs, Assigned: christophe.ravel.bugs)

Details

Attachments

(4 files, 3 obsolete files)

We added "-z defs" to the linker command line for NSS 3.11. It looks like a bug in the RHEL 2.1 linker is blocking the build.
We should remove this option (in mozilla/security/coreconf/Linux.mk) and add it only for Linux 2.6 until we find a fix for the linker.

The build error is:
gcc -shared  -z defs -Wl,-soname -Wl,libfreebl3.so -Wl,--version-script,Linux2.4_x86_glibc_PTH_DBG.OBJ/Linux_SINGLE_SHLIB/freebl.def -o Linux2.4_x86_glibc_PTH_DBG.OBJ/Linux_SINGLE_SHLIB/libfreebl3.so Linux2.4_x86_glibc_PTH_DBG.OBJ/Linux_SINGLE_SHLIB/freeblver.o Linux2.4_x86_glibc_PTH_DBG.OBJ/Linux_SINGLE_SHLIB/ldvector.o Linux2.4_x86_glibc_PTH_DBG.OBJ/Linux_SINGLE_SHLIB/prng_fips1861.o Linux2.4_x86_glibc_PTH_DBG.OBJ/Linux_SINGLE_SHLIB/sysrand.o Linux2.4_x86_glibc_PTH_DBG.OBJ/Linux_SINGLE_SHLIB/sha_fast.o Linux2.4_x86_glibc_PTH_DBG.OBJ/Linux_SINGLE_SHLIB/md2.o Linux2.4_x86_glibc_PTH_DBG.OBJ/Linux_SINGLE_SHLIB/md5.o Linux2.4_x86_glibc_PTH_DBG.OBJ/Linux_SINGLE_SHLIB/sha512.o Linux2.4_x86_glibc_PTH_DBG.OBJ/Linux_SINGLE_SHLIB/alghmac.o Linux2.4_x86_glibc_PTH_DBG.OBJ/Linux_SINGLE_SHLIB/rawhash.o Linux2.4_x86_glibc_PTH_DBG.OBJ/Linux_SINGLE_SHLIB/alg2268.o Linux2.4_x86_glibc_PTH_DBG.OBJ/Linux_SINGLE_SHLIB/arcfour.o Linux2.4_x86_glibc_PTH_DBG.OBJ/Linux_SINGLE_SHLIB/arcfive.o Linux2.4_x86_glibc_PTH_DBG.OBJ/Linux_SINGLE_SHLIB/desblapi.o Linux2.4_x86_glibc_PTH_DBG.OBJ/Linux_SINGLE_SHLIB/des.o Linux2.4_x86_glibc_PTH_DBG.OBJ/Linux_SINGLE_SHLIB/rijndael.o Linux2.4_x86_glibc_PTH_DBG.OBJ/Linux_SINGLE_SHLIB/aeskeywrap.o Linux2.4_x86_glibc_PTH_DBG.OBJ/Linux_SINGLE_SHLIB/dh.o Linux2.4_x86_glibc_PTH_DBG.OBJ/Linux_SINGLE_SHLIB/ec.o Linux2.4_x86_glibc_PTH_DBG.OBJ/Linux_SINGLE_SHLIB/pqg.o Linux2.4_x86_glibc_PTH_DBG.OBJ/Linux_SINGLE_SHLIB/dsa.o Linux2.4_x86_glibc_PTH_DBG.OBJ/Linux_SINGLE_SHLIB/rsa.o Linux2.4_x86_glibc_PTH_DBG.OBJ/Linux_SINGLE_SHLIB/shvfy.o Linux2.4_x86_glibc_PTH_DBG.OBJ/Linux_SINGLE_SHLIB/tlsprfalg.o Linux2.4_x86_glibc_PTH_DBG.OBJ/Linux_SINGLE_SHLIB/mpprime.o Linux2.4_x86_glibc_PTH_DBG.OBJ/Linux_SINGLE_SHLIB/mpmontg.o Linux2.4_x86_glibc_PTH_DBG.OBJ/Linux_SINGLE_SHLIB/mplogic.o Linux2.4_x86_glibc_PTH_DBG.OBJ/Linux_SINGLE_SHLIB/mpi.o Linux2.4_x86_glibc_PTH_DBG.OBJ/Linux_SINGLE_SHLIB/mp_gf2m.o Linux2.4_x86_glibc_PTH_DBG.OBJ/Linux_SINGLE_SHLIB/mpcpucache.o Linux2.4_x86_glibc_PTH_DBG.OBJ/Linux_SINGLE_SHLIB/mpi_x86.o   ../../../../dist/Linux2.4_x86_glibc_PTH_DBG.OBJ/lib/libsecutil.a -L../../../../dist/Linux2.4_x86_glibc_PTH_DBG.OBJ/lib -lplc4 -lplds4 -lnspr4  -lpthread  -ldl -lc
/lib/libc.so.6: undefined reference to `_dl_lazy@GLIBC_2.1.1'
/lib/libc.so.6: undefined reference to `_dl_dst_substitute@GLIBC_2.1.1'
/lib/libc.so.6: undefined reference to `_dl_out_of_memory@GLIBC_2.2'
/lib/libc.so.6: undefined reference to `_dl_relocate_object@GLIBC_2.0'
/lib/libc.so.6: undefined reference to `_dl_clktck@GLIBC_2.2'
/lib/libc.so.6: undefined reference to `__libc_enable_secure@GLIBC_2.0'
/lib/libc.so.6: undefined reference to `_dl_catch_error@GLIBC_2.0'
/lib/libc.so.6: undefined reference to `_dl_platformlen@GLIBC_2.1.1'
/lib/libc.so.6: undefined reference to `_dl_lookup_versioned_symbol_skip@GLIBC_2.0'
/lib/libc.so.6: undefined reference to `_dl_lookup_versioned_symbol@GLIBC_2.0'
/lib/libc.so.6: undefined reference to `_dl_mcount@GLIBC_2.1'
/lib/libc.so.6: undefined reference to `_dl_dst_count@GLIBC_2.1.1'
/lib/libc.so.6: undefined reference to `_dl_initial_searchlist@GLIBC_2.1'
/lib/libc.so.6: undefined reference to `_dl_start_profile@GLIBC_2.1'
/lib/libc.so.6: undefined reference to `_dl_lookup_symbol@GLIBC_2.0'
/lib/libc.so.6: undefined reference to `__libc_stack_end@GLIBC_2.1'
/lib/libc.so.6: undefined reference to `_dl_argv@GLIBC_2.2'
/usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../libpthread.so: undefined reference to `_dl_cpuclock_offset'
/lib/libc.so.6: undefined reference to `_dl_loaded@GLIBC_2.1'
/lib/libc.so.6: undefined reference to `_dl_origin_path@GLIBC_2.1.1'
/lib/libc.so.6: undefined reference to `_dl_check_map_versions@GLIBC_2.2'
/lib/libc.so.6: undefined reference to `_dl_map_object@GLIBC_2.0'
/lib/libc.so.6: undefined reference to `_dl_main_searchlist@GLIBC_2.1'
/lib/libc.so.6: undefined reference to `_dl_debug_mask@GLIBC_2.2.3'
/lib/libc.so.6: undefined reference to `_dl_load_lock@GLIBC_2.2'
/lib/libc.so.6: undefined reference to `_dl_profile@GLIBC_2.1'
/lib/libc.so.6: undefined reference to `_dl_debug_state@GLIBC_2.0'
/lib/libc.so.6: undefined reference to `_dl_init_all_dirs@GLIBC_2.2'
/lib/libc.so.6: undefined reference to `_r_debug@GLIBC_2.0'
/lib/libc.so.6: undefined reference to `_dl_unload_cache@GLIBC_2.1'
/lib/libc.so.6: undefined reference to `_dl_signal_error@GLIBC_2.0'
/lib/libc.so.6: undefined reference to `_dl_debug_printf@GLIBC_2.2.3'
/lib/libc.so.6: undefined reference to `_dl_init@GLIBC_2.2'
/lib/libc.so.6: undefined reference to `_dl_all_dirs@GLIBC_2.2'
/lib/libc.so.6: undefined reference to `_dl_map_object_deps@GLIBC_2.0'
/lib/libc.so.6: undefined reference to `_dl_nloaded@GLIBC_2.2'
/lib/libc.so.6: undefined reference to `_dl_profile_map@GLIBC_2.1'
/lib/libc.so.6: undefined reference to `_dl_profile_output@GLIBC_2.1'
/lib/libc.so.6: undefined reference to `_dl_pagesize@GLIBC_2.2'
/lib/libc.so.6: undefined reference to `_dl_lookup_symbol_skip@GLIBC_2.0'
/lib/libc.so.6: undefined reference to `_dl_fpu_control@GLIBC_2.1'
/usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../libdl.so: undefined reference to `_dl_catch_error'
/lib/libc.so.6: undefined reference to `_dl_global_scope_alloc@GLIBC_2.1'
collect2: ld returned 1 exit status
gmake[3]: *** [Linux2.4_x86_glibc_PTH_DBG.OBJ/Linux_SINGLE_SHLIB/libfreebl3.so] Error 1
Build tested on RHEL21 (Linux 2.4) and RHEL40 (Linux 2.6).

on RHEL21:
gcc -shared  -Wl,-soname -Wl,libfreebl3.so -Wl,--version-script,Linux2.4_x86_glibc_PTH_DBG.OBJ/Linux_SINGLE_SHLIB/freebl.def -o Linux2.4_x86_glibc_PTH_DBG.OBJ/Linux_SINGLE_SHLIB/libfreebl3.so Linux2.4_x86_glibc_PTH_DBG.OBJ/Linux_SINGLE_SHLIB/freeblver.o ...

on RHEL40:
gcc -shared -m32 -z defs -Wl,-soname -Wl,libfreebl3.so -Wl,--version-script,Linux2.6_x86_glibc_PTH_DBG.OBJ/Linux_SINGLE_SHLIB/freebl.def -o Linux2.6_x86_glibc_PTH_DBG.OBJ/Linux_SINGLE_SHLIB/libfreebl3.so Linux2.6_x86_glibc_PTH_DBG.OBJ/Linux_SINGLE_SHLIB/freeblver.o ...
Assignee: wtchang → christophe.ravel.bugs
Status: NEW → ASSIGNED
Attachment #208285 - Flags: superreview?(wtchang)
Attachment #208285 - Flags: review?(julien.pierre.bugs)
Comment on attachment 208285 [details] [diff] [review]
Remove "-z defs" from Linux.mk and add it to Linux2.6.mk

Note: this is only for NSS_3_11_BRANCH (not the tip).
Attachment #208285 - Flags: superreview?(wtchang) → superreview+
I can reproduce these "undefined reference" linker errors
with a simple test case.

The test case is a simple shared library libfoo.so
consisting of a single source file foo.c.

$ cat foo.c
#include <stdio.h>

size_t foo_strlen(const char *s)
{
    if (s == NULL)
        return 0;
    return strlen(s);
}
$ gcc -fPIC -c foo.c
$ gcc -shared -o libfoo.so -z defs foo.o
/lib/libc.so.6: undefined reference to `_dl_lazy@GLIBC_2.1.1'
/lib/libc.so.6: undefined reference to `_dl_dst_substitute@GLIBC_2.1.1'
[...omitted for brevity...]
/lib/libc.so.6: undefined reference to `_dl_global_scope_alloc@GLIBC_2.1'
collect2: ld returned 1 exit status
$ gcc -shared -o libfoo.so -z defs foo.o -lc
/lib/libc.so.6: undefined reference to `_dl_lazy@GLIBC_2.1.1'
/lib/libc.so.6: undefined reference to `_dl_dst_substitute@GLIBC_2.1.1'
[...omitted for brevity...]
/lib/libc.so.6: undefined reference to `_dl_global_scope_alloc@GLIBC_2.1'
collect2: ld returned 1 exit status
$ gcc -shared -o libfoo.so -z defs foo.o -lc /lib/ld-linux.so.2
$ gcc -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs
gcc version 2.96 20000731 (Red Hat Linux 7.2 2.96-108.1)
$ ld -v
GNU ld version 2.11.90.0.8 (with BFD 2.11.90.0.8)
$ ld -V
GNU ld version 2.11.90.0.8 (with BFD 2.11.90.0.8)
  Supported emulations:
   elf_i386
   i386linux
$ uname -a
Linux cmslinux 2.4.9-e.3 #1 Fri May 3 17:02:43 EDT 2002 i686 unknown
$ cat /etc/redhat-release
Red Hat Linux Advanced Server release 2.1AS (Pensacola)
$ 
Comment on attachment 208285 [details] [diff] [review]
Remove "-z defs" from Linux.mk and add it to Linux2.6.mk

Unfortunately, this patch causes -z defs to also not be used on RHEL3, which uses a 2.4 kernel, even though -z defs works properly on that platform. We need some way to differentiate RHEL2.1 from RHEL3 .
Attachment #208285 - Flags: review?(julien.pierre.bugs) → review-
(In reply to comment #4)
> (From update of attachment 208285 [details] [diff] [review] [edit])
> Unfortunately, this patch causes -z defs to also not be used on RHEL3, which
> uses a 2.4 kernel, even though -z defs works properly on that platform. We need
> some way to differentiate RHEL2.1 from RHEL3 .
> 

But that's the solution we agreed on during the meeting this morning. We said that we could spend more time and try de detect the actual version of RHEL, but we agreed it was not worth it. Is there a misunderstanding ?
Yes, there is, I don't think we agreed to remove -z defs on anything but RHEL2.1 . Doing this was the alternative was to patch the ld on the machine which was considered to be too troublesome to do today.

Isn't there a test for something that is only true on RHEL2.1 that we could put in an ifeq rule in Linux2.4.mk ?
The linker ld is in the binutils package.  According to the
RHEL 2.1 AS errata page (http://rhn.redhat.com/errata/rh21as-errata.html),
there are only two updates for binutils:
http://rhn.redhat.com/errata/RHSA-2005-763.html
http://rhn.redhat.com/errata/RHBA-2004-171.html

Neither of them seems related to this bug.

To tell RHEL 2.1 from RHEL 3, you need to parse
/etc/redhat-release (as shown at the end of comment 3).
But I want to reiterate the points I made in the
conference call this morning.

1. We can get the benefit of -z defs by using it on
just one Linux version.  Most of us regularly build
NSS on a Linux distribution with the 2.6 kernel, such
as RHEL 4 or Fedora Core 3 or later, where -z defs
works.

2. With the amount of NSS work on our plates, we should
not spend too much time researching this issue.  I'd
rather see us working on crypto and PKI than becoming
GNU binutils gurus.  In spite of that, I've shown my
good will and spent some time researching this issue.
You can also test the ld version.  Here is the ld
version and /etc/redhat-release contents for RHEL 3.

$ ld -v
GNU ld version 2.14.90.0.4 20030523
$ ld -V
GNU ld version 2.14.90.0.4 20030523
  Supported emulations:
   elf_i386
   i386linux
$ cat /etc/redhat-release
Red Hat Enterprise Linux AS release 3 (Taroon Update 3)

Developer time is not free.  Christophe's simple test using
the kernel version makes the right trade-off.
Maybe we could use this fix today but leave the bug open and find a better solution for the future.
What do you think ?
OK. This can go in to today's build, but we are going to have to find a better solution that doesn't break RHEL3 . Engineering time will be needed to resolve this anyway, even if not today . I'd like to see this fixed by the time 3.11.1 is RTM.

Christophe, you should be able to build a rule using the $if and $findstring functions of gmake to check for the ld version string and take appropriate action. There is a prior usage of these together in coreconf that checks for a ":" string in the output of $PWD -  search for the string "abspath" in rules.mk . Doing this will slow the build down somewhat since each Makefile will execute it once, so I recommend that this test be done only in Linux2.4.mk so it doesn't affect RHEL4 builds.
patch #1 committed on NSS_3_11_BRANCH.

Checking in Linux.mk;
/cvsroot/mozilla/security/coreconf/Linux.mk,v  <--  Linux.mk
new revision: 1.27.2.1; previous revision: 1.27
done
Checking in Linux2.6.mk;
/cvsroot/mozilla/security/coreconf/Linux2.6.mk,v  <--  Linux2.6.mk
new revision: 1.5.2.1; previous revision: 1.5
done
Fixed the indentation.

A note on the ld version I test for in this patch.

The version of the original binutils on RHEL 2.1 is:
$ rpm -q binutils
binutils-2.11.90.0.8-12

If you apply the latest binutils update
(http://rhn.redhat.com/errata/RHSA-2005-763.html),
the version becomes 2.11.90.0.8-12.5.

This is why I think we can just test for version
2.11.90.0.8.  ("ld -v" does not report the "-12".)
Attachment #208342 - Attachment is obsolete: true
Wan-Teh,

Thank you very much for taking this on !

FYI, the version on one of our RHEL2.1 boxes that exhibits the problem is :
GNU ld version 2.11.90.0.8 (with BFD 2.11.90.0.8)

It would be better if this test was in Linux2.4.mk only, vs Linux.mk.
Comment on attachment 208285 [details] [diff] [review]
Remove "-z defs" from Linux.mk and add it to Linux2.6.mk

Christophe, I need to improve your interim patch
for the NSS_3_11_BRANCH to say

>+DSO_LDOPTS      += -Wl,-z,defs

instead of

>+DSO_LDOPTS      += -z defs

Is this OK?  The gcc compiler on Linux/ppc doesn't
recognize the -z defs linker flag (I don't know why),
so we need to use the -Wl compiler flag to pass
-z defs to the linker.
[cltbld@balsa tinderbox]$ ld -v
GNU ld version 2.11.90.0.8 (with BFD 2.11.90.0.8)
[cltbld@balsa tinderbox]$ ld -V
GNU ld version 2.11.90.0.8 (with BFD 2.11.90.0.8)
  Supported emulations:
   elf_i386
   i386linux
   elf_i386_glibc21
The above is the output of "ld -v" and "ld -V"
on Red Hat Linux 7.2, whose ld also has this problem
with -z defs.  Since RHEL 2.1 is very close to
Red Hat Linux 7.2, this is not surprising.
(In reply to comment #15)
> (From update of attachment 208285 [details] [diff] [review] [edit])
> Christophe, I need to improve your interim patch
> for the NSS_3_11_BRANCH to say
> 
> >+DSO_LDOPTS      += -Wl,-z,defs
> 
> instead of
> 
> >+DSO_LDOPTS      += -z defs
> 
> Is this OK?  The gcc compiler on Linux/ppc doesn't
> recognize the -z defs linker flag (I don't know why),
> so we need to use the -Wl compiler flag to pass
> -z defs to the linker.
> 

Sure, go on.
I checked in this change (required for bug 317858) on
the NSS_3_11_BRANCH.

Checking in Linux2.6.mk;
/cvsroot/mozilla/security/coreconf/Linux2.6.mk,v  <--  Linux2.6.mk
new revision: 1.5.2.2; previous revision: 1.5.2.1
done
Attached patch Test the ld version, v2 (obsolete) — Splinter Review
I want to avoid using Linux2.*.mk because I plan to
merge them back into Linux.mk so that we don't need
to add a new Linux2.x.mk file whenever a new Linux
kernel is released.

This patch is one way to avoid doing the ld version
test when it's not necessary.  By using the GNU make
if function, we only do the ld version test in the
directories where we make SHARED_LIBRARY.  Note that
we will still do the ld version test on the 2.6 kernel
where it is not necessary.  It should be cheap to run
"ld -v", so I think it's fine to do it once in each
directories where we make SHARED_LIBRARY.

I also updated the comments to include Red Hat Linux 7.2,
which has the same problem with -z defs.
Attachment #208343 - Attachment is obsolete: true
Although the patch "Test the ld version, v2" works,
the commas in "-Wl,-z,defs" worry me because commas
separate the then-part and else-part in the if function.

In this patch I store -Wl,-z,defs in the ZDEFS_FLAG
variable and use $(ZDEFS_FLAG) in the if function.

Christophe, Julien, my patches should give you enough
ideas to write the patch you like, so please take it
over from here.
Attachment #208417 - Attachment is obsolete: true
I suggest that we just use Christophe's interim fix
and close this bug.
Target Milestone: 3.11 → 3.11.1
Christophe, Is this bug resolved now?  
Priority: -- → P2
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
Christophe: we didn't check in any fix for this bug on
the NSS trunk (3.12).  Are you not building the NSS
trunk on RHEL 2.1?
We don't build the Trunk on RHEL 2.1 (we only build NSS_3_11_BRANCH on RHEL 2.1).
We have to build the Trunk on RHEL 2.1 again. I am reopening this bug so we can apply the same fix on the Trunk.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
I think we don't want to apply the exact same fix.  
We should somehow make it use -z,defs when it can, and not when it cannot.
Agreed. I think attachment 208425 [details] [diff] [review] is a better fix for the trunk.
Comment on attachment 208425 [details] [diff] [review]
Test the ld version, v2.1

For the trunk
Attachment #208425 - Flags: review?(julien.pierre.boogz)
Attachment #208425 - Flags: review?(julien.pierre.boogz) → review+
Attachment #390867 - Flags: review?(christophe.ravel.bugs)
Attachment #390867 - Flags: review?(christophe.ravel.bugs) → review+
Checking in pk11mode.c;
/cvsroot/mozilla/security/nss/cmd/pk11mode/pk11mode.c,v  <--  pk11mode.c
new revision: 1.27; previous revision: 1.26
done
QA Contact: wtc → build
Checking in Linux.mk;
/cvsroot/mozilla/security/coreconf/Linux.mk,v  <--  Linux.mk
new revision: 1.40; previous revision: 1.39
done
Status: REOPENED → RESOLVED
Closed: 18 years ago15 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: