From patchwork Fri Aug 21 14:07:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Lamparter X-Patchwork-Id: 509493 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id CDE5F1402A9 for ; Sat, 22 Aug 2015 00:07:58 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=googlemail.com header.i=@googlemail.com header.b=t8SvsLEP; dkim-atps=neutral Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 37DB728BFC0; Fri, 21 Aug 2015 16:07:02 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=unavailable version=3.3.2 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id E07382844A3 for ; Fri, 21 Aug 2015 16:06:54 +0200 (CEST) X-policyd-weight: using cached result; rate: -8.5 Received: from mail-wi0-f179.google.com (mail-wi0-f179.google.com [209.85.212.179]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Fri, 21 Aug 2015 16:06:54 +0200 (CEST) Received: by wicne3 with SMTP id ne3so20906366wic.1 for ; Fri, 21 Aug 2015 07:07:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:date:message-id:user-agent:in-reply-to :references:mime-version:content-transfer-encoding:content-type; bh=uFvKoghoHGYOdle0gPvczOJHT8PeRBegJK/fscA8BdY=; b=t8SvsLEPtnLpdrRCRnG8I2Rm+7E1jAib18QwT3AN5vsVRBcsJBxiSszMtHG2Cmt3nJ u7kp97sHFMTGpEYY2+3XhH4eGUjtVrwb9kILkZm/Nwa6FbSJwRsawbwpF7y8eQeZKLh6 NualDh5x9dE+YiD3gPbl0nRqu/ThklHknBr7iAheXYJS5kQ+LhrJ2ZHeluoUW/1iKggc uL6xXeocLc6mBvRJ0JRdD4Gs2HH4PtBhHDlQptoBpj4bMD6rpqunPJfmaX49RqtAuq2x c4I4iI5SnGdBFFgM1u2jw+IoBBGv3iAig977Rwu9Gp+BlXbALfxxWsByiJYkd83IsNS+ ZHmg== X-Received: by 10.194.117.199 with SMTP id kg7mr15285339wjb.49.1440166063710; Fri, 21 Aug 2015 07:07:43 -0700 (PDT) Received: from debian64.daheim (p5B2E6B85.dip0.t-ipconnect.de. [91.46.107.133]) by smtp.googlemail.com with ESMTPSA id k4sm3109898wix.19.2015.08.21.07.07.42 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Aug 2015 07:07:42 -0700 (PDT) Received: from localhost.daheim ([127.0.0.1] helo=debian64.localnet) by debian64.daheim with esmtps (TLS1.0:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.86) (envelope-from ) id 1ZSmyr-0005zO-D8; Fri, 21 Aug 2015 16:07:41 +0200 From: Christian Lamparter To: musl@lists.openwall.com Date: Fri, 21 Aug 2015 16:07:39 +0200 Message-ID: <6159471.3UQWOnjUZP@debian64> User-Agent: KMail/4.14.2 (Linux/4.2.0-rc6-wl+; KDE/4.14.10; x86_64; ; ) In-Reply-To: <4450715.CJV8mqCvIO@debian64> References: <5769061.FLTLqujSyv@debian64> <20150820030402.GT32742@brightrain.aerifal.cx> <4450715.CJV8mqCvIO@debian64> MIME-Version: 1.0 Cc: Bobby Bingham , Rich Felker , openwrt-devel@lists.openwrt.org Subject: Re: [OpenWrt-Devel] [musl] SuperH conflict of arch/sh/__set_thread_area vs thread/__set_thread_area X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" (Added Openwrt-dev - since this isn't a musl issue) On Thursday, August 20, 2015 12:21:55 PM Christian Lamparter wrote: > On Wednesday, August 19, 2015 11:04:02 PM Rich Felker wrote: > > On Thu, Aug 20, 2015 at 02:44:11AM +0200, Christian Lamparter wrote: > > > I'm trying to add a port for a SH4-like ARCH to OpenWRT, which uses the latest > > > musl-1.1.10 as the default libc. I'm having the following problem when building > > > the toolchain: > > > > > > During the final linker-step, the symbol "__set_thread_area" declared twice. > > > This is because the SH architecture provides a separate __set_thread_area [0], > > > (other archs use the standard syscall wrapper from [1]). > > > > > > Obviously, I want this issue fixed. However I'm new to SuperH and musl, that's > > > why I need advise :-D. For now, I defined the src/thread/__set_thread_area as > > > a weak symbol. Now, that's just a crude hack, what would be better solution? > > > (I can make and post the patch if necessary - But sadly, I can't test it on the > > > hardware yet)? > > > > Bobby Bingham's reply explains what the issue is. Did you make a new > > arch name rather than using the existing sh arch for your port? > Initially, yes I did. I had the ARCH at "sh4". This was because OpenWRT > already had infrastructure for some sh-(sub)targets (sh3, sh3eb, sh4, sh4eb) > in place. But they seem to be unused and untested. The only target which has > support for SuperH is UserModeLinux. However, it will probably run into the > same issue. > > Now, I've changed ARCH to "sh" and set the CPU_TYPE to sh4 [toolchain > dir changed to toolchain-sh_sh4_gcc-5.2.0_musl-1.1.10]. But still no > luck, the original error code remains the same. > > src/thread/__set_thread_area.lo: In function `__set_thread_area': > __set_thread_area.c:(.text+0x0): multiple definition of `__set_thread_area' > arch/sh/src/__set_thread_area.lo:__set_thread_area.c:(.text+0x0): first defined here > collect2: error: ld returned 1 exit status > Makefile:142: recipe for target 'lib/libc.so' failed Ok, I have a update and I fixed this issue with __set_thread_area.s. The reason why this didn't work and was harder to debug than usual is because of the involvement of the "patch" utility with the -E flag (--remove-empty-files). Openwrt adds a number of patches to the musl-1.1.10.tar.gz [0] (actually they seem to be cherry-picked from musl git). Now, one of the patches "001-git-2015-07-22.patch" contains: commit f9d84554bae0fa17c9a1d724549c4408022228a5 [1] Author: Rich Felker Date: Tue Jun 16 14:28:30 2015 +0000 add support for sh2 interrupt-masking-based atomics to sh port This commit reduces the "src/thread/sh/__set_thread_area.s" to an empty file (but it doesn't remove it). But due to bad luck, the script that patches the file [2] (it's called patch-kernel.sh, but it's used to patch the toolchain as well) uses the pesky "-E" flag (line 40): [...] ${PATCH:-patch} -f -p1 -E -d ${targetdir} ^^ ==> And that's why the __set_thread_area.s file disappears. I came up with two possible fixes for OpenWRT, unless you want to fix this in musl (via non-empty __set_thread_area) instead: 1. have some content in __set_thread_area.s to prevent it from being removed. --- --- Does anyone have any preferences? I'm opting for "patch patch-kernel" (and I will send a proper patch next week to OpenWRT even if no one cares now :-D ) Regards, Christian [0] [1] [2] --- a/src/thread/sh/__set_thread_area.s +++ b/src/thread/sh/__set_thread_area.s @@ -0,0 +1,1 @@ +/* the patch utility might remove empty files */ --- 2. patch patch-kernel.sh --- --- a/scripts/patch-kernel.sh +++ b/scripts/patch-kernel.sh @@ -37,7 +37,7 @@ for i in ${patchdir}/${patchpattern} ; do [ -d "${i}" ] && echo "Ignoring subdirectory ${i}" && continue echo "" echo "Applying ${i} using ${type}: " - ${uncomp} ${i} | ${PATCH:-patch} -f -p1 -E -d ${targetdir} + ${uncomp} ${i} | ${PATCH:-patch} -f -p1 -d ${targetdir} if [ $? != 0 ] ; then echo "Patch failed! Please fix $i!" exit 1