NetBSD Problem Report #49074

From root@db.soft.iwate-pu.ac.jp  Tue Aug  5 09:56:34 2014
Return-Path: <root@db.soft.iwate-pu.ac.jp>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id E1690A9455
	for <gnats-bugs@gnats.NetBSD.org>; Tue,  5 Aug 2014 09:56:34 +0000 (UTC)
Message-Id: <20140805085159.633AD7CF8@balalaika.db.soft.iwate-pu.ac.jp>
Date: Tue,  5 Aug 2014 17:51:58 +0900 (JST)
From: nobu-s@iwate-pu.ac.jp
Reply-To: nobu-s@iwate-pu.ac.jp
To: gnats-bugs@NetBSD.org
Subject: undefined reference to `__atomic_compare_exchange_4' on sparc port
X-Send-Pr-Version: 3.95

>Number:         49074
>Category:       toolchain
>Synopsis:       lang/ruby21-base fails to link due to undefined reference to `__atomic_compare_exchange_4'
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    martin
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Aug 05 10:00:01 +0000 2014
>Closed-Date:    Mon Jun 04 05:29:32 +0000 2018
>Last-Modified:  Mon Jun 04 05:29:32 +0000 2018
>Originator:     Nobuyoshi SATO
>Release:        NetBSD 6.99.49, on July 30, 2014, pkgsrc 2014Q2 and 2014Q1
>Organization:
Faculty of Software and Information Sciences,
Iwate Prefectural University, Japan.
>Environment:
System: NetBSD balalaika.db.soft.iwate-pu.ac.jp 6.99.49 NetBSD 6.99.49 (BALALAIKA) #0: Sun Aug  3 01:02:35 JST 2014  nobu-s@balalaika.db.soft.iwate-pu.ac.jp:/import/leech/1/netbsd/7/obj-sparc/sys/arch/sparc/compile/BALALAIKA sparc
Architecture: sparc
Machine: sparc
>Description:
Building pkgsrc lang/ruby21-base fails to build as following error, 
for targetting sparc port. Targetting for amd64 works fine. 
Targetting other ports were not tested.

----in case of cross build on NetBSD/amd64, pkgsrc 2014Q2----
compiling main.c
linking static-library libruby212-static.a
verifying static-library libruby212-static.a
libruby212-static.a(gc.o): In function `objspace_malloc_increase.isra.54':
gc.c:(.text+0x9c9c): undefined reference to `__atomic_compare_exchange_4'
gc.c:(.text+0x9cdc): undefined reference to `__atomic_compare_exchange_4'
libruby212-static.a(io.o): In function `rb_update_max_fd':
io.c:(.text+0x29f0): undefined reference to `__atomic_compare_exchange_4'
libruby212-static.a(iseq.o): In function `rb_iseq_load':
iseq.c:(.text+0x3514): undefined reference to `__atomic_compare_exchange_4'
libruby212-static.a(vm_trace.o): In function `postponed_job_register':
vm_trace.c:(.text+0xf4c): undefined reference to `__atomic_compare_exchange_4'
libruby212-static.a(vm_trace.o):vm_trace.c:(.text+0x2934): more undefined references to `__atomic_compare_exchange_4' follow
collect2: error: ld returned 1 exit status
*** Error code 1
----end here----

----in case of straight build on NetBSD/sparc, pkgsrc 2014Q1----
compiling main.c
linking miniruby
gc.o: In function `objspace_malloc_increase.isra.54':
gc.c:(.text+0x9d60): undefined reference to `__atomic_compare_exchange_4'
gc.c:(.text+0x9da0): undefined reference to `__atomic_compare_exchange_4'
io.o: In function `rb_update_max_fd':
io.c:(.text+0x29f0): undefined reference to `__atomic_compare_exchange_4'
iseq.o: In function `rb_iseq_load':
iseq.c:(.text+0x3514): undefined reference to `__atomic_compare_exchange_4'
vm_trace.o: In function `postponed_job_register':
vm_trace.c:(.text+0xf4c): undefined reference to `__atomic_compare_exchange_4'
vm_trace.o:vm_trace.c:(.text+0x2934): more undefined references to `__atomic_compare_exchange_4' follow
*** Error code 1

Stop.
make: stopped in /import/leech/2/netbsd/7/pkgsrc/lang/ruby21-base/work/ruby-2.1.1
*** Error code 1
----end here----

lang/ruby21 could be built for sparc port in NetBSD 6.99.44.

>How-To-Repeat:
Just "make build" on lang/ruby21-base (and ruby200 too) for sparc port
in recent -current. This can be reproduced by both of cross building 
on NetBSD/amd64 and straight building on NetBSD/sparc.

Note that cross building lang/ruby21 for NetBSD/sparc on amd64 
requieres working ruby which is natively installed. So, point that
the error occurs differs from cross and straight building.

>Fix:
No idea since I have no knowledge on internal of gcc and libc.

This seem to be related to src/common/lib/libc/atomic/ and
src/common/lib/libc/arch/sparc/atomic/.

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: port-sparc-maintainer->toolchain-manager
Responsible-Changed-By: martin@NetBSD.org
Responsible-Changed-When: Tue, 05 Aug 2014 12:09:15 +0000
Responsible-Changed-Why:
This is a more broad issue, we need to add support for all the
__sync* builtins for the C++ memory model
listed in /usr/src/external/gpl3/gcc/dist/gcc/sync-builtins.def
and treat them like we did with the __sync_* stuff (including a test
case and fixing all build breakage)
.


From: Nobuyoshi SATO <nobu-s@iwate-pu.ac.jp>
To: gnats-bugs@NetBSD.org, martin@NetBSD.org
Cc: toolchain-manager@netbsd.org, port-sparc-maintainer@netbsd.org,
        netbsd-bugs@netbsd.org, gnats-admin@netbsd.org, nobu-s@iwate-pu.ac.jp
Subject: Re: toolchain/49074 (lang/ruby21-base fails to link due to
 undefined reference to `__atomic_compare_exchange_4')
Date: Thu, 28 Aug 2014 18:19:36 +0900 (JST)

 On Tue,  5 Aug 2014 12:09:15 +0000 (UTC),
 martin@NetBSD.org wrote:

 > Synopsis: lang/ruby21-base fails to link due to undefined reference to `__atomic_compare_exchange_4'
 > 
 > Responsible-Changed-From-To: port-sparc-maintainer->toolchain-manager
 > Responsible-Changed-By: martin@NetBSD.org
 > Responsible-Changed-When: Tue, 05 Aug 2014 12:09:15 +0000
 > Responsible-Changed-Why:
 > This is a more broad issue, we need to add support for all the
 > __sync* builtins for the C++ memory model
 > listed in /usr/src/external/gpl3/gcc/dist/gcc/sync-builtins.def
 > and treat them like we did with the __sync_* stuff (including a test
 > case and fixing all build breakage)
 > .

 Based on infomation from @obache via twitter, I added checks
 __atomic_compare_exchange_n into ruby's configure script as
 following:

 ----8<--------8<--------8<--------8<--------8<----
 --- configure.orig-pkgsrc-patched	2014-08-28 17:16:21.000000000 +0900
 +++ configure	2014-08-28 17:28:28.000000000 +0900
 @@ -13115,6 +13115,7 @@
  	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
  /* end confdefs.h.  */
  unsigned char atomic_var;
 +unsigned char atomic_var2;
  int
  main ()
  {
 @@ -13123,6 +13124,8 @@
  			__atomic_exchange_n(&atomic_var, 1, __ATOMIC_SEQ_CST);
  			__atomic_fetch_add(&atomic_var, 1, __ATOMIC_SEQ_CST);
  			__atomic_fetch_sub(&atomic_var, 1, __ATOMIC_SEQ_CST);
 +			__atomic_compare_exchange_n(&atomic_var, &atomic_var2, 0, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
 +			__atomic_compare_exchange_n(&atomic_var, &atomic_var2, 1, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);

    ;
    return 0;
 ----8<--------8<--------8<--------8<--------8<----

 This let result of "checking for __atomic builtins..." be no,
 and use of these builtin function is avoided. Tested on 
 netbsd-7 branch, synchronized end of last week.

 Note: __atomic_exchange_n, __atomic_fetch_add and __atomic_fetch_sub
 exist for sparc port, so the result of check for these builtin 
 functions is yes regularly.

 This seem to be not a good way to solve the problem, however, 
 this evades the problem that lang/ruby212 cannot be built in
 sparc port.

 I cannot judge this problem is NetBSD's toolchain problem
 or ruby's configfure script is irresponsible. 

 Anyway, I report the newest trying result.


 Lecturer / Faculty of Software & Info. Sci., Iwate Prefectural Univ.
 Nobuyoshi Sato, Ph.D / nobu-s@iwate-pu.ac.jp / +81-19-694-2612

From: Martin Husemann <martin@duskware.de>
To: Nobuyoshi SATO <nobu-s@iwate-pu.ac.jp>
Cc: gnats-bugs@NetBSD.org, martin@NetBSD.org, toolchain-manager@netbsd.org,
	port-sparc-maintainer@netbsd.org, netbsd-bugs@netbsd.org,
	gnats-admin@netbsd.org
Subject: Re: toolchain/49074 (lang/ruby21-base fails to link due to undefined reference to `__atomic_compare_exchange_4')
Date: Thu, 28 Aug 2014 11:23:25 +0200

 On Thu, Aug 28, 2014 at 06:19:36PM +0900, Nobuyoshi SATO wrote:
 > I cannot judge this problem is NetBSD's toolchain problem

 It is a NetBSD problem.

 Martin

From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/49074 CVS commit: src/tests/lib/libc/sync
Date: Sat, 11 Oct 2014 14:52:16 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Sat Oct 11 14:52:16 UTC 2014

 Modified Files:
 	src/tests/lib/libc/sync: Makefile
 Added Files:
 	src/tests/lib/libc/sync: cpp_atomic_ops_linkable.cc

 Log Message:
 Add a link time test to catch missing symbols in libc, as pointed
 out in PR toolchain/49074.


 To generate a diff of this commit:
 cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/sync/Makefile
 cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/sync/cpp_atomic_ops_linkable.cc

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

Responsible-Changed-From-To: toolchain-manager->martin
Responsible-Changed-By: maya@NetBSD.org
Responsible-Changed-When: Sun, 03 Jun 2018 21:57:34 +0000
Responsible-Changed-Why:
Asking martin for feedback.


State-Changed-From-To: open->feedback
State-Changed-By: maya@NetBSD.org
State-Changed-When: Sun, 03 Jun 2018 21:57:34 +0000
State-Changed-Why:
Given that we now test that the function exists on all ports, it should no longer be an issue. Is this correct?


State-Changed-From-To: feedback->closed
State-Changed-By: martin@NetBSD.org
State-Changed-When: Mon, 04 Jun 2018 05:29:32 +0000
State-Changed-Why:
While we do not verbatim check for this function, we do check
__sync_bool_compare_and_swap_2, and also we have __atomic_compare_exchange_{1,2,4}
in sparc's libc.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.