NetBSD Problem Report #48775

From www@NetBSD.org  Thu May  1 07:02:57 2014
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 0524CA5818
	for <gnats-bugs@gnats.NetBSD.org>; Thu,  1 May 2014 07:02:57 +0000 (UTC)
Message-Id: <20140501070255.2B4C1A583D@mollari.NetBSD.org>
Date: Thu,  1 May 2014 07:02:55 +0000 (UTC)
From: netbsd@marino.st
Reply-To: netbsd@marino.st
To: gnats-bugs@NetBSD.org
Subject: devel/binutils: linker doesn't handle PIC properly; can't build lang/gcc-aux
X-Send-Pr-Version: www-1.0

>Number:         48775
>Category:       pkg
>Synopsis:       devel/binutils: linker doesn't handle PIC properly; can't build lang/gcc-aux
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu May 01 07:05:01 +0000 2014
>Originator:     John Marino
>Release:        NetBSD 6.1.4 - amd64
>Organization:
>Environment:
>Description:
The lang/gcc-aux package is the first gcc 4.9-based package in pkgsrc as far as I can tell.

I can't find this documented, but apparently gcc 4.9 requires a version of binutils newer than the version 2.21 that comes with NetBSD 6.  It builds fine with the base linker and assembler, and mostly seems to work, but while linking devel/gps, the linker completely malfunctions.

The theory that the culprit is the base binutils is supported by devel/gps building just fine on NetBSD 6.99 which has binutils 2.23 in base.

However, adding devel/binutils as a dependency as see in other gcc packages (e.g. lang/gcc47) results in lang/gcc-aux breaking during the build of libstdc++, specifically the c++98 convenience static library which is built with -fPIC.  During linking, an error occurs stating that the object file should have been produced with -fPIC.  logs clearly show that it was.

So my conclusion is that there is either something wrong with devel/binutils or something in base is preventing the linker from working correctly
>How-To-Repeat:
On NetBSD 6.1.4 (or any release of NetBSD 6 presumably)

"cd lang/gcc-aux && make" after applying the following patch: 

--- Makefile.orig       2014-05-01 06:39:48.000000000 +0000
+++ Makefile    2014-05-01 06:41:44.000000000 +0000
@@ -63,6 +63,7 @@
 .endif
 BOOTSTRAP_COMPILER=    ada-bootstrap.${GARCH}.netbsd.614.tar.bz2
 BLD_TARGET=            ${MACHINE_ARCH}-aux-netbsd${NELF}${NSUFF}
+MODERN_BINUTILS=       yes
 .endif

 .if ${OPSYS} == "SunOS"


Alternatively to skip modifying the makefile, use:
  cd lang/gcc-aux && make MODERN_BINUTILS=yes


Assuming the problem is reproducible, the build should break on the libstdc++ target, with specific complaints about the convenience library not being built with PIC.  Obviously this is false because lang/gcc-aux builds fine (with PIC) with the base linker and assembler.

devel/gps has been disabled on NetBSD 5 and 6 due to being unable to configure lang/gcc-aux to use ${PREFIX}/bin/gld
>Fix:

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.