NetBSD Problem Report #43073

From www@NetBSD.org  Mon Mar 29 13:50:03 2010
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id 7BD2463B86C
	for <gnats-bugs@gnats.NetBSD.org>; Mon, 29 Mar 2010 13:50:03 +0000 (UTC)
Message-Id: <20100329135003.2EACB63B11D@www.NetBSD.org>
Date: Mon, 29 Mar 2010 13:50:03 +0000 (UTC)
From: dennis.c.ferguson@gmail.com
Reply-To: dennis.c.ferguson@gmail.com
To: gnats-bugs@NetBSD.org
Subject: powerpc64 rescue link finds many missing symbols in /usr/lib/libcrypto.a
X-Send-Pr-Version: www-1.0

>Number:         43073
>Category:       port-powerpc
>Synopsis:       powerpc64 rescue link finds many missing symbols in /usr/lib/libcrypto.a
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    port-powerpc-maintainer
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Mar 29 13:55:00 +0000 2010
>Closed-Date:    Tue Mar 30 07:31:42 +0000 2010
>Last-Modified:  Tue Mar 30 07:31:42 +0000 2010
>Originator:     Dennis Ferguson
>Release:        very recent 5.99.24
>Organization:
>Environment:
NetBSD acer.hk.akit-ferguson.com 5.99.24 NetBSD 5.99.24 (GENERIC) #0: Sun Mar 14 17:25:30 HKT 2010  dennis@acer.hk.akit-ferguson.com:/usr/obj/sys/arch/amd64/compile/GENERIC amd64
>Description:
When building a macppc64 distribution, the link for rescue finds
many, many missing symbols in /usr/lib/libcrypto.a, e.g.:

#      link  obj/rescue
[...]
/usr/NetBSD/src/obj/destdir.macppc/usr/lib/libcrypto.a(bn_nist.o): In function `.BN_nist_mod_521':
bn_nist.c:(.text+0x2b8): undefined reference to `.bn_add_words'
bn_nist.c:(.text+0x2d0): undefined reference to `.bn_sub_words'
/usr/NetBSD/src/obj/destdir.macppc/usr/lib/libcrypto.a(bn_nist.o): In function `.BN_nist_mod_384':
bn_nist.c:(.text+0x518): undefined reference to `.bn_add_words'
bn_nist.c:(.text+0x534): undefined reference to `.bn_add_words'
bn_nist.c:(.text+0x5cc): undefined reference to `.bn_add_words'
bn_nist.c:(.text+0x658): undefined reference to `.bn_add_words'
bn_nist.c:(.text+0x6b4): undefined reference to `.bn_add_words'
/usr/NetBSD/src/obj/destdir.macppc/usr/lib/libcrypto.a(bn_nist.o):bn_nist.c:(.text+0x708): more undefined references to `.bn_add_words' follow
/usr/NetBSD/src/obj/destdir.macppc/usr/lib/libcrypto.a(bn_nist.o): In function `.BN_nist_mod_384':
bn_nist.c:(.text+0x7a4): undefined reference to `.bn_sub_words'
bn_nist.c:(.text+0x7fc): undefined reference to `.bn_sub_words'
bn_nist.c:(.text+0x844): undefined reference to `.bn_sub_words'
bn_nist.c:(.text+0x87c): undefined reference to `.bn_sub_words'
bn_nist.c:(.text+0x8b8): undefined reference to `.bn_add_words'

All the missing functions are powerpc (not 64) assembly
functions.
>How-To-Repeat:
Do a

    MACHINE=macppc64 ./build.sh distribution
>Fix:
For macppc64 builds we end up with the following two settings
for the cpu-related defines:

    MACHINE_ARCH=  "powerpc64"
    MACHINE_CPU=   "powerpc"

The make machinery in src/crypto/external/bsd/openssl/lib/libcrypto/,
based on this, includes the sources and Makefile includes
from its arch/powerpc subdirectory.  While the powerpc assembly
source files included in there assemble properly for powerpc64
the two ports have different, incompatible, calling and linkage
conventions (encapsulated in ENTRY() macros for NetBSD assembly
functions but not by libcrypto assembly functions).

Since modifying the powerpc functions to work on powerpc64 as
well, while possible, doesn't make sense, I think the quick fix
is to make powerpc64 the library's C versions of the functions
for now.

To do this do the following:

    mkdir crypto/external/bsd/openssl/lib/libcrypto/powerpc64
    cat > crypto/external/bsd/openssl/lib/libcrypto/powerpc64/des.inc
    .include "${.CURDIR}/des.inc"
    ^D

(the file des.inc is for CVS, it does what the build system would
do with no arch/*/des.inc file) and then apply the attached patch
patch to srcs.inc in the libcrypto directory.  Note that, instead
of exclusively using the arch/${MACHINE_CPU} directory if it
exists, the patch makes it first check to see if an
arch/${MACHINE_ARCH} directory exists and, if so, use that
in preference.  Note that I think this is actually a small
fix to the Makefile in general: in the very few cases where
MACHINE_ARCH and MACHINE_CPU differ, MACHINE_ARCH is always a
more specific description of the target architecture, so it
an arch/${MACHINE_ARCH} directory exists at all it is almost
certainly correct to prefer it.

Index: crypto/external/bsd/openssl/lib/libcrypto/srcs.inc
===================================================================
RCS file: /cvsroot/src/crypto/external/bsd/openssl/lib/libcrypto/srcs.inc,v
retrieving revision 1.1
diff -u -r1.1 srcs.inc
--- crypto/external/bsd/openssl/lib/libcrypto/srcs.inc  19 Jul 2009 23:30:44 -0000      1.1
+++ crypto/external/bsd/openssl/lib/libcrypto/srcs.inc  29 Mar 2010 13:49:23 -0000
@@ -17,7 +17,13 @@

 CRYPTOINCS+=   man.inc

-CRYPTO_MACHINE_CPU?=   ${MACHINE_CPU}
+.if !defined(CRYPTO_MACHINE_CPU)
+.if exists(${.CURDIR}/arch/${MACHINE_ARCH})
+CRYPTO_MACHINE_CPU=    ${MACHINE_ARCH}
+.else
+CRYPTO_MACHINE_CPU=    ${MACHINE_CPU}
+.endif
+.endif

 .for cryptoinc in ${CRYPTOINCS}
 .if exists(${.CURDIR}/arch/${CRYPTO_MACHINE_CPU}/${cryptoinc})

>Release-Note:

>Audit-Trail:
From: matthew green <mrg@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/43073 CVS commit: src/crypto/external/bsd/openssl/lib/libcrypto
Date: Tue, 30 Mar 2010 07:23:52 +0000

 Module Name:	src
 Committed By:	mrg
 Date:		Tue Mar 30 07:23:51 UTC 2010

 Modified Files:
 	src/crypto/external/bsd/openssl/lib/libcrypto: srcs.inc
 Added Files:
 	src/crypto/external/bsd/openssl/lib/libcrypto/arch/powerpc64: des.inc

 Log Message:
 for now, use the C versions of bn and des, not the (32 bit) versions,
 on powerpc64.

 from dennis.c.ferguson@gmail.com in PR#43073.


 To generate a diff of this commit:
 cvs rdiff -u -r1.1 -r1.2 \
     src/crypto/external/bsd/openssl/lib/libcrypto/srcs.inc
 cvs rdiff -u -r0 -r1.1 \
     src/crypto/external/bsd/openssl/lib/libcrypto/arch/powerpc64/des.inc

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: mrg@NetBSD.org
State-Changed-When: Tue, 30 Mar 2010 07:31:42 +0000
State-Changed-Why:
changes applied largely as suggested, though i kept CRYPTO_MACHINE_CPU using ?=

thanks!


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.